3 # Copyright 2022 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:
29 # #define _int_0 _GLF_uniform_int_values[0]
30 # #define _int_1 _GLF_uniform_int_values[1]
31 # #define _int_20 _GLF_uniform_int_values[2]
32 # #define _int_4 _GLF_uniform_int_values[3]
34 # precision highp float;
35 # precision highp int;
37 # // Contents of _GLF_uniform_int_values: [0, 1, 20, 4]
38 # layout(set = 0, binding = 0) uniform buf0
40 # int _GLF_uniform_int_values[4];
43 # const int _GLF_global_loop_bound = 10;
44 # int _GLF_global_loop_count = 0;
46 # // Contents of zero: 0
47 # layout(set = 0, binding = 1) uniform buf1
52 # // Contents of two: 2
53 # layout(set = 0, binding = 2) uniform buf2
58 # layout(location = 0) out vec4 _GLF_color;
62 # int arr[10] = int[10](_int_0, _int_0, _int_0, _int_0, _int_0, _int_0, _int_0, _int_0, _int_0, _int_0);
64 # // Iterates ten times because of the global loop bound.
65 # for(int i = 0; i < _int_20 && _GLF_global_loop_count < _GLF_global_loop_bound; (zero < _int_1) ? i++ : _int_1)
67 # _GLF_global_loop_count++;
75 # // True when i == 0.
78 # arr[i / _int_4] = _int_1;
85 # if(arr[_int_0] == _int_1)
87 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
91 # _GLF_color = vec4(_int_0);
94 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
97 ; Generator: Khronos Glslang Reference Front End; 10
101 %1 = OpExtInstImport "GLSL.std.450"
102 OpMemoryModel Logical GLSL450
103 OpEntryPoint Fragment %4 "main" %121
104 OpExecutionMode %4 OriginUpperLeft
107 OpName %8 "_GLF_global_loop_count"
110 OpMemberName %17 0 "_GLF_uniform_int_values"
114 OpMemberName %62 0 "two"
117 OpMemberName %88 0 "zero"
119 OpName %121 "_GLF_color"
120 OpDecorate %16 ArrayStride 16
121 OpMemberDecorate %17 0 Offset 0
123 OpDecorate %19 DescriptorSet 0
124 OpDecorate %19 Binding 0
125 OpMemberDecorate %62 0 Offset 0
127 OpDecorate %64 DescriptorSet 0
128 OpDecorate %64 Binding 2
129 OpMemberDecorate %88 0 Offset 0
131 OpDecorate %90 DescriptorSet 0
132 OpDecorate %90 Binding 1
133 OpDecorate %121 Location 0
135 %3 = OpTypeFunction %2
137 %7 = OpTypePointer Private %6
138 %8 = OpVariable %7 Private
141 %11 = OpConstant %10 10
142 %12 = OpTypeArray %6 %11
143 %13 = OpTypePointer Function %12
144 %15 = OpConstant %10 4
145 %16 = OpTypeArray %6 %15
146 %17 = OpTypeStruct %16
147 %18 = OpTypePointer Uniform %17
148 %19 = OpVariable %18 Uniform
149 %20 = OpTypePointer Uniform %6
150 %42 = OpTypePointer Function %6
151 %50 = OpConstant %6 2
153 %56 = OpConstant %6 10
154 %60 = OpConstant %6 1
155 %62 = OpTypeStruct %6
156 %63 = OpTypePointer Uniform %62
157 %64 = OpVariable %63 Uniform
158 %74 = OpConstant %6 4
159 %81 = OpConstant %6 3
160 %88 = OpTypeStruct %6
161 %89 = OpTypePointer Uniform %88
162 %90 = OpVariable %89 Uniform
163 %118 = OpTypeFloat 32
164 %119 = OpTypeVector %118 4
165 %120 = OpTypePointer Output %119
166 %121 = OpVariable %120 Output
167 %4 = OpFunction %2 None %3
169 %14 = OpVariable %13 Function
170 %43 = OpVariable %42 Function
171 %96 = OpVariable %42 Function
173 %21 = OpAccessChain %20 %19 %9 %9
175 %23 = OpAccessChain %20 %19 %9 %9
177 %25 = OpAccessChain %20 %19 %9 %9
179 %27 = OpAccessChain %20 %19 %9 %9
181 %29 = OpAccessChain %20 %19 %9 %9
183 %31 = OpAccessChain %20 %19 %9 %9
185 %33 = OpAccessChain %20 %19 %9 %9
187 %35 = OpAccessChain %20 %19 %9 %9
189 %37 = OpAccessChain %20 %19 %9 %9
191 %39 = OpAccessChain %20 %19 %9 %9
193 %41 = OpCompositeConstruct %12 %22 %24 %26 %28 %30 %32 %34 %36 %38 %40
198 OpLoopMerge %46 %47 None
202 %51 = OpAccessChain %20 %19 %9 %50
204 %54 = OpSLessThan %53 %49 %52
206 %57 = OpSLessThan %53 %55 %56
207 %58 = OpLogicalAnd %53 %54 %57
208 OpBranchConditional %58 %45 %46
211 %61 = OpIAdd %6 %59 %60
213 %65 = OpAccessChain %20 %64 %9
215 %67 = OpAccessChain %20 %19 %9 %60
217 %69 = OpSLessThanEqual %53 %66 %68
218 OpSelectionMerge %71 None
219 OpBranchConditional %69 %70 %71
224 %75 = OpSDiv %6 %73 %74
226 %77 = OpIEqual %53 %75 %76
227 OpSelectionMerge %79 None
228 OpBranchConditional %77 %78 %79
231 %82 = OpAccessChain %20 %19 %9 %81
233 %84 = OpSDiv %6 %80 %83
234 %85 = OpAccessChain %20 %19 %9 %60
236 %87 = OpAccessChain %42 %14 %84
242 %91 = OpAccessChain %20 %90 %9
244 %93 = OpAccessChain %20 %19 %9 %60
246 %95 = OpSLessThan %53 %92 %94
247 OpSelectionMerge %98 None
248 OpBranchConditional %95 %97 %101
251 %100 = OpIAdd %6 %99 %60
256 %102 = OpAccessChain %20 %19 %9 %60
257 %103 = OpLoad %6 %102
263 %104 = OpAccessChain %20 %19 %9 %60
264 %105 = OpLoad %6 %104
265 %106 = OpAccessChain %42 %14 %105
266 %107 = OpLoad %6 %106
267 %108 = OpIAdd %6 %107 %60
269 %109 = OpAccessChain %20 %19 %9 %9
270 %110 = OpLoad %6 %109
271 %111 = OpAccessChain %42 %14 %110
272 %112 = OpLoad %6 %111
273 %113 = OpAccessChain %20 %19 %9 %60
274 %114 = OpLoad %6 %113
275 %115 = OpIEqual %53 %112 %114
276 OpSelectionMerge %117 None
277 OpBranchConditional %115 %116 %135
279 %122 = OpAccessChain %20 %19 %9 %60
280 %123 = OpLoad %6 %122
281 %124 = OpConvertSToF %118 %123
282 %125 = OpAccessChain %20 %19 %9 %9
283 %126 = OpLoad %6 %125
284 %127 = OpConvertSToF %118 %126
285 %128 = OpAccessChain %20 %19 %9 %9
286 %129 = OpLoad %6 %128
287 %130 = OpConvertSToF %118 %129
288 %131 = OpAccessChain %20 %19 %9 %60
289 %132 = OpLoad %6 %131
290 %133 = OpConvertSToF %118 %132
291 %134 = OpCompositeConstruct %119 %124 %127 %130 %133
295 %136 = OpAccessChain %20 %19 %9 %9
296 %137 = OpLoad %6 %136
297 %138 = OpConvertSToF %118 %137
298 %139 = OpCompositeConstruct %119 %138 %138 %138 %138
306 # uniforms for variant
309 BUFFER variant_zero DATA_TYPE int32 STD140 DATA
313 BUFFER variant_two DATA_TYPE int32 STD140 DATA
316 # _GLF_uniform_int_values
317 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
321 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
323 PIPELINE graphics variant_pipeline
324 ATTACH variant_vertex_shader
325 ATTACH variant_fragment_shader
326 FRAMEBUFFER_SIZE 32 32
327 BIND BUFFER variant_framebuffer AS color LOCATION 0
328 BIND BUFFER variant_zero AS uniform DESCRIPTOR_SET 0 BINDING 1
329 BIND BUFFER variant_two AS uniform DESCRIPTOR_SET 0 BINDING 2
330 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
332 CLEAR_COLOR variant_pipeline 0 0 0 255
334 CLEAR variant_pipeline
335 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
337 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255