1#!amber 2 3# Copyright 2020 Google LLC 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17 18# A test for a coverage-gap found by the GraphicsFuzz project. 19 20# Short description: A fragment shader that covers a specific floating point code path 21 22# The test passes because the shader always writes red. 23 24SHADER vertex variant_vertex_shader PASSTHROUGH 25 26# variant_fragment_shader is derived from the following GLSL: 27# #version 310 es 28# #define _int_1 _GLF_uniform_int_values[0] 29# #define _int_0 _GLF_uniform_int_values[1] 30# #define _float_0_0 _GLF_uniform_float_values[0] 31# 32# precision highp float; 33# 34# // Contents of _GLF_uniform_int_values: [1, 0] 35# layout(set = 0, binding = 0) uniform buf0 36# { 37# int _GLF_uniform_int_values[2]; 38# }; 39# 40# // Contents of _GLF_uniform_float_values: 0.0 41# layout(set = 0, binding = 1) uniform buf1 42# { 43# float _GLF_uniform_float_values[1]; 44# }; 45# 46# layout(location = 0) out vec4 _GLF_color; 47# 48# void main() 49# { 50# // This results in an undefined value, but not in undefined behavior. 51# float undefined = sinh(log2(-8.9)); 52# 53# if (1 == _int_1 || undefined > _float_0_0) 54# { 55# _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1); 56# } 57# else 58# { 59# _GLF_color = vec4(_int_0); 60# } 61# } 62SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0 63; SPIR-V 64; Version: 1.0 65; Generator: Khronos Glslang Reference Front End; 8 66; Bound: 62 67; Schema: 0 68 OpCapability Shader 69 %1 = OpExtInstImport "GLSL.std.450" 70 OpMemoryModel Logical GLSL450 71 OpEntryPoint Fragment %4 "main" %43 72 OpExecutionMode %4 OriginUpperLeft 73 OpSource ESSL 310 74 OpName %4 "main" 75 OpName %8 "undefined" 76 OpName %17 "buf0" 77 OpMemberName %17 0 "_GLF_uniform_int_values" 78 OpName %19 "" 79 OpName %31 "buf1" 80 OpMemberName %31 0 "_GLF_uniform_float_values" 81 OpName %33 "" 82 OpName %43 "_GLF_color" 83 OpDecorate %16 ArrayStride 16 84 OpMemberDecorate %17 0 RelaxedPrecision 85 OpMemberDecorate %17 0 Offset 0 86 OpDecorate %17 Block 87 OpDecorate %19 DescriptorSet 0 88 OpDecorate %19 Binding 0 89 OpDecorate %23 RelaxedPrecision 90 OpDecorate %30 ArrayStride 16 91 OpMemberDecorate %31 0 Offset 0 92 OpDecorate %31 Block 93 OpDecorate %33 DescriptorSet 0 94 OpDecorate %33 Binding 1 95 OpDecorate %43 Location 0 96 OpDecorate %45 RelaxedPrecision 97 OpDecorate %48 RelaxedPrecision 98 OpDecorate %51 RelaxedPrecision 99 OpDecorate %54 RelaxedPrecision 100 OpDecorate %59 RelaxedPrecision 101 %2 = OpTypeVoid 102 %3 = OpTypeFunction %2 103 %6 = OpTypeFloat 32 104 %7 = OpTypePointer Function %6 105 %9 = OpConstant %6 0x1.8p+128 106 %11 = OpTypeBool 107 %12 = OpTypeInt 32 1 108 %13 = OpConstant %12 1 109 %14 = OpTypeInt 32 0 110 %15 = OpConstant %14 2 111 %16 = OpTypeArray %12 %15 112 %17 = OpTypeStruct %16 113 %18 = OpTypePointer Uniform %17 114 %19 = OpVariable %18 Uniform 115 %20 = OpConstant %12 0 116 %21 = OpTypePointer Uniform %12 117 %29 = OpConstant %14 1 118 %30 = OpTypeArray %6 %29 119 %31 = OpTypeStruct %30 120 %32 = OpTypePointer Uniform %31 121 %33 = OpVariable %32 Uniform 122 %34 = OpTypePointer Uniform %6 123 %41 = OpTypeVector %6 4 124 %42 = OpTypePointer Output %41 125 %43 = OpVariable %42 Output 126 %4 = OpFunction %2 None %3 127 %5 = OpLabel 128 %8 = OpVariable %7 Function 129 %10 = OpExtInst %6 %1 Sinh %9 130 OpStore %8 %10 131 %22 = OpAccessChain %21 %19 %20 %20 132 %23 = OpLoad %12 %22 133 %24 = OpIEqual %11 %13 %23 134 %25 = OpLogicalNot %11 %24 135 OpSelectionMerge %27 None 136 OpBranchConditional %25 %26 %27 137 %26 = OpLabel 138 %28 = OpLoad %6 %8 139 %35 = OpAccessChain %34 %33 %20 %20 140 %36 = OpLoad %6 %35 141 %37 = OpFOrdGreaterThan %11 %28 %36 142 OpBranch %27 143 %27 = OpLabel 144 %38 = OpPhi %11 %24 %5 %37 %26 145 OpSelectionMerge %40 None 146 OpBranchConditional %38 %39 %57 147 %39 = OpLabel 148 %44 = OpAccessChain %21 %19 %20 %20 149 %45 = OpLoad %12 %44 150 %46 = OpConvertSToF %6 %45 151 %47 = OpAccessChain %21 %19 %20 %13 152 %48 = OpLoad %12 %47 153 %49 = OpConvertSToF %6 %48 154 %50 = OpAccessChain %21 %19 %20 %13 155 %51 = OpLoad %12 %50 156 %52 = OpConvertSToF %6 %51 157 %53 = OpAccessChain %21 %19 %20 %20 158 %54 = OpLoad %12 %53 159 %55 = OpConvertSToF %6 %54 160 %56 = OpCompositeConstruct %41 %46 %49 %52 %55 161 OpStore %43 %56 162 OpBranch %40 163 %57 = OpLabel 164 %58 = OpAccessChain %21 %19 %20 %13 165 %59 = OpLoad %12 %58 166 %60 = OpConvertSToF %6 %59 167 %61 = OpCompositeConstruct %41 %60 %60 %60 %60 168 OpStore %43 %61 169 OpBranch %40 170 %40 = OpLabel 171 OpReturn 172 OpFunctionEnd 173END 174 175# uniforms for variant 176 177# _GLF_uniform_float_values 178BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA 179 0.0 180END 181# _GLF_uniform_int_values 182BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA 183 1 0 184END 185 186BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM 187 188PIPELINE graphics variant_pipeline 189 ATTACH variant_vertex_shader 190 ATTACH variant_fragment_shader 191 FRAMEBUFFER_SIZE 256 256 192 BIND BUFFER variant_framebuffer AS color LOCATION 0 193 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1 194 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0 195END 196CLEAR_COLOR variant_pipeline 0 0 0 255 197 198CLEAR variant_pipeline 199RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256 200 201EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255 202