3 # Copyright 2021 Google LLC
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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.
18 # A test for a coverage-gap found by the GraphicsFuzz project.
20 # Short description: A fragment shader that covers specific LLVM code paths
22 # The test passes because the shader always writes red.
24 SHADER vertex variant_vertex_shader PASSTHROUGH
26 # variant_fragment_shader is derived from the following GLSL:
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]
32 # precision highp float;
33 # precision highp int;
35 # // Contents of _GLF_uniform_float_values: 0.0
36 # layout(set = 0, binding = 0) uniform buf0
38 # float _GLF_uniform_float_values[1];
41 # // Contents of _GLF_uniform_int_values: [1, 0]
42 # layout(set = 0, binding = 1) uniform buf1
44 # int _GLF_uniform_int_values[2];
47 # // Contents of injectionSwitch: [0.0, 1.0]
48 # layout(set = 0, binding = 2) uniform buf2
50 # highp vec2 injectionSwitch;
53 # layout(location = 0) out vec4 _GLF_color;
58 # if(injectionSwitch.x > injectionSwitch.y)
66 # while(a << int(injectionSwitch.x) >= _int_0)
69 # if(injectionSwitch.x > injectionSwitch.y)
77 # if(gl_FragCoord.x < _float_0_0)
90 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
94 # _GLF_color = vec4(_int_0);
97 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
100 ; Generator: Khronos Glslang Reference Front End; 10
104 %1 = OpExtInstImport "GLSL.std.450"
105 OpMemoryModel Logical GLSL450
106 OpEntryPoint Fragment %4 "main" %60 %85
107 OpExecutionMode %4 OriginUpperLeft
111 OpMemberName %8 0 "injectionSwitch"
115 OpMemberName %41 0 "_GLF_uniform_int_values"
117 OpName %60 "gl_FragCoord"
119 OpMemberName %65 0 "_GLF_uniform_float_values"
121 OpName %85 "_GLF_color"
122 OpMemberDecorate %8 0 Offset 0
124 OpDecorate %10 DescriptorSet 0
125 OpDecorate %10 Binding 2
126 OpDecorate %40 ArrayStride 16
127 OpMemberDecorate %41 0 Offset 0
129 OpDecorate %43 DescriptorSet 0
130 OpDecorate %43 Binding 1
131 OpDecorate %60 BuiltIn FragCoord
132 OpDecorate %64 ArrayStride 16
133 OpMemberDecorate %65 0 Offset 0
135 OpDecorate %67 DescriptorSet 0
136 OpDecorate %67 Binding 0
137 OpDecorate %85 Location 0
139 %3 = OpTypeFunction %2
141 %7 = OpTypeVector %6 2
143 %9 = OpTypePointer Uniform %8
144 %10 = OpVariable %9 Uniform
146 %12 = OpConstant %11 0
148 %14 = OpConstant %13 0
149 %15 = OpTypePointer Uniform %6
150 %18 = OpConstant %13 1
152 %26 = OpTypePointer Function %11
153 %28 = OpConstant %11 1
154 %39 = OpConstant %13 2
155 %40 = OpTypeArray %11 %39
156 %41 = OpTypeStruct %40
157 %42 = OpTypePointer Uniform %41
158 %43 = OpVariable %42 Uniform
159 %44 = OpTypePointer Uniform %11
160 %58 = OpTypeVector %6 4
161 %59 = OpTypePointer Input %58
162 %60 = OpVariable %59 Input
163 %61 = OpTypePointer Input %6
164 %64 = OpTypeArray %6 %18
165 %65 = OpTypeStruct %64
166 %66 = OpTypePointer Uniform %65
167 %67 = OpVariable %66 Uniform
168 %74 = OpConstantTrue %21
169 %84 = OpTypePointer Output %58
170 %85 = OpVariable %84 Output
171 %4 = OpFunction %2 None %3
173 %27 = OpVariable %26 Function
174 %16 = OpAccessChain %15 %10 %12 %14
176 %19 = OpAccessChain %15 %10 %12 %18
178 %22 = OpFOrdGreaterThan %21 %17 %20
179 OpSelectionMerge %24 None
180 OpBranchConditional %22 %23 %24
187 OpLoopMerge %31 %32 None
191 %35 = OpAccessChain %15 %10 %12 %14
193 %37 = OpConvertFToS %11 %36
194 %38 = OpShiftLeftLogical %11 %34 %37
195 %45 = OpAccessChain %44 %43 %12 %28
197 %47 = OpSGreaterThanEqual %21 %38 %46
198 OpBranchConditional %47 %30 %31
200 %48 = OpAccessChain %15 %10 %12 %14
202 %50 = OpAccessChain %15 %10 %12 %18
204 %52 = OpFOrdGreaterThan %21 %49 %51
205 OpSelectionMerge %54 None
206 OpBranchConditional %52 %53 %54
211 %57 = OpISub %11 %56 %28
213 %62 = OpAccessChain %61 %60 %14
215 %68 = OpAccessChain %15 %67 %12 %12
217 %70 = OpFOrdLessThan %21 %63 %69
218 OpSelectionMerge %72 None
219 OpBranchConditional %70 %71 %72
223 OpSelectionMerge %76 None
224 OpBranchConditional %74 %75 %76
233 %78 = OpAccessChain %44 %43 %12 %12
235 %80 = OpSNegate %11 %79
236 %81 = OpIEqual %21 %77 %80
237 OpSelectionMerge %83 None
238 OpBranchConditional %81 %82 %99
240 %86 = OpAccessChain %44 %43 %12 %12
242 %88 = OpConvertSToF %6 %87
243 %89 = OpAccessChain %44 %43 %12 %28
245 %91 = OpConvertSToF %6 %90
246 %92 = OpAccessChain %44 %43 %12 %28
248 %94 = OpConvertSToF %6 %93
249 %95 = OpAccessChain %44 %43 %12 %12
251 %97 = OpConvertSToF %6 %96
252 %98 = OpCompositeConstruct %58 %88 %91 %94 %97
256 %100 = OpAccessChain %44 %43 %12 %28
257 %101 = OpLoad %11 %100
258 %102 = OpConvertSToF %6 %101
259 %103 = OpCompositeConstruct %58 %102 %102 %102 %102
267 # uniforms for variant
270 BUFFER variant_injectionSwitch DATA_TYPE vec2<float> STD140 DATA
273 # _GLF_uniform_int_values
274 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
277 # _GLF_uniform_float_values
278 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
282 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
284 PIPELINE graphics variant_pipeline
285 ATTACH variant_vertex_shader
286 ATTACH variant_fragment_shader
287 FRAMEBUFFER_SIZE 256 256
288 BIND BUFFER variant_framebuffer AS color LOCATION 0
289 BIND BUFFER variant_injectionSwitch AS uniform DESCRIPTOR_SET 0 BINDING 2
290 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
291 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
293 CLEAR_COLOR variant_pipeline 0 0 0 255
295 CLEAR variant_pipeline
296 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
298 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255