3 # Copyright 2020 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 calculates negation of clamped loop iterator values
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_0 _GLF_uniform_int_values[0]
29 # #define _int_1 _GLF_uniform_int_values[1]
30 # #define _int_2 _GLF_uniform_int_values[2]
31 # #define _int_3 _GLF_uniform_int_values[3]
32 # #define _int_4 _GLF_uniform_int_values[4]
33 # #define _int_5 _GLF_uniform_int_values[5]
34 # #define _int_10 _GLF_uniform_int_values[6]
35 # #define _int_15 _GLF_uniform_int_values[7]
36 # #define _int_6 _GLF_uniform_int_values[8]
37 # #define _int_7 _GLF_uniform_int_values[9]
38 # #define _int_8 _GLF_uniform_int_values[10]
39 # #define _int_9 _GLF_uniform_int_values[11]
40 # #define _int_11 _GLF_uniform_int_values[12]
41 # #define _int_12 _GLF_uniform_int_values[13]
42 # #define _int_13 _GLF_uniform_int_values[14]
43 # #define _int_14 _GLF_uniform_int_values[15]
45 # precision highp float;
46 # precision highp int;
48 # // Contents of _GLF_uniform_int_values: [0, 1, 2, 3, 4, 5, 10, 15, 6, 7, 8, 9,
50 # layout(set = 0, binding = 0) uniform buf0
52 # int _GLF_uniform_int_values[16];
55 # layout(location = 0) out vec4 _GLF_color;
61 # ref[_int_0] = _int_0;
62 # ref[_int_1] = _int_1;
63 # ref[_int_2] = _int_2;
64 # ref[_int_3] = _int_3;
65 # ref[_int_4] = _int_4;
66 # ref[_int_5] = -_int_1;
67 # ref[_int_6] = -_int_1;
68 # ref[_int_7] = -_int_1;
69 # ref[_int_8] = -_int_1;
70 # ref[_int_9] = -_int_1;
71 # ref[_int_10] = -_int_2;
72 # ref[_int_11] = -_int_2;
73 # ref[_int_12] = -_int_2;
74 # ref[_int_13] = -_int_2;
75 # ref[_int_14] = -_int_2;
77 # for (int i = 0; i < _int_5; i++)
79 # data[i] = ~clamp(~i, ~i, _int_1);
81 # for (int i = _int_5; i < _int_10; i++)
83 # data[i] = ~clamp(~i, 0, 1);
85 # for (int i = _int_10; i < _int_15; i++)
87 # data[i] = ~clamp(i, 0, 1);
89 # for (int i = _int_0; i < _int_15; i++)
91 # if (data[i] != ref[i])
93 # _GLF_color = vec4(_int_0);
98 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
100 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
103 ; Generator: Khronos Glslang Reference Front End; 8
107 %1 = OpExtInstImport "GLSL.std.450"
108 OpMemoryModel Logical GLSL450
109 OpEntryPoint Fragment %4 "main" %207
110 OpExecutionMode %4 OriginUpperLeft
115 OpMemberName %14 0 "_GLF_uniform_int_values"
122 OpName %207 "_GLF_color"
123 OpDecorate %13 ArrayStride 16
124 OpMemberDecorate %14 0 Offset 0
126 OpDecorate %16 DescriptorSet 0
127 OpDecorate %16 Binding 0
128 OpDecorate %207 Location 0
130 %3 = OpTypeFunction %2
133 %8 = OpConstant %7 15
134 %9 = OpTypeArray %6 %8
135 %10 = OpTypePointer Function %9
136 %12 = OpConstant %7 16
137 %13 = OpTypeArray %6 %12
138 %14 = OpTypeStruct %13
139 %15 = OpTypePointer Uniform %14
140 %16 = OpVariable %15 Uniform
141 %17 = OpConstant %6 0
142 %18 = OpTypePointer Uniform %6
143 %23 = OpTypePointer Function %6
144 %25 = OpConstant %6 1
145 %31 = OpConstant %6 2
146 %37 = OpConstant %6 3
147 %43 = OpConstant %6 4
148 %49 = OpConstant %6 5
149 %56 = OpConstant %6 8
150 %63 = OpConstant %6 9
151 %70 = OpConstant %6 10
152 %77 = OpConstant %6 11
153 %84 = OpConstant %6 6
154 %91 = OpConstant %6 12
155 %98 = OpConstant %6 13
156 %105 = OpConstant %6 14
157 %112 = OpConstant %6 15
159 %172 = OpConstant %6 7
160 %204 = OpTypeFloat 32
161 %205 = OpTypeVector %204 4
162 %206 = OpTypePointer Output %205
163 %207 = OpVariable %206 Output
164 %4 = OpFunction %2 None %3
166 %11 = OpVariable %10 Function
167 %119 = OpVariable %23 Function
168 %130 = OpVariable %10 Function
169 %143 = OpVariable %23 Function
170 %163 = OpVariable %23 Function
171 %183 = OpVariable %23 Function
172 %19 = OpAccessChain %18 %16 %17 %17
174 %21 = OpAccessChain %18 %16 %17 %17
176 %24 = OpAccessChain %23 %11 %20
178 %26 = OpAccessChain %18 %16 %17 %25
180 %28 = OpAccessChain %18 %16 %17 %25
182 %30 = OpAccessChain %23 %11 %27
184 %32 = OpAccessChain %18 %16 %17 %31
186 %34 = OpAccessChain %18 %16 %17 %31
188 %36 = OpAccessChain %23 %11 %33
190 %38 = OpAccessChain %18 %16 %17 %37
192 %40 = OpAccessChain %18 %16 %17 %37
194 %42 = OpAccessChain %23 %11 %39
196 %44 = OpAccessChain %18 %16 %17 %43
198 %46 = OpAccessChain %18 %16 %17 %43
200 %48 = OpAccessChain %23 %11 %45
202 %50 = OpAccessChain %18 %16 %17 %49
204 %52 = OpAccessChain %18 %16 %17 %25
206 %54 = OpSNegate %6 %53
207 %55 = OpAccessChain %23 %11 %51
209 %57 = OpAccessChain %18 %16 %17 %56
211 %59 = OpAccessChain %18 %16 %17 %25
213 %61 = OpSNegate %6 %60
214 %62 = OpAccessChain %23 %11 %58
216 %64 = OpAccessChain %18 %16 %17 %63
218 %66 = OpAccessChain %18 %16 %17 %25
220 %68 = OpSNegate %6 %67
221 %69 = OpAccessChain %23 %11 %65
223 %71 = OpAccessChain %18 %16 %17 %70
225 %73 = OpAccessChain %18 %16 %17 %25
227 %75 = OpSNegate %6 %74
228 %76 = OpAccessChain %23 %11 %72
230 %78 = OpAccessChain %18 %16 %17 %77
232 %80 = OpAccessChain %18 %16 %17 %25
234 %82 = OpSNegate %6 %81
235 %83 = OpAccessChain %23 %11 %79
237 %85 = OpAccessChain %18 %16 %17 %84
239 %87 = OpAccessChain %18 %16 %17 %31
241 %89 = OpSNegate %6 %88
242 %90 = OpAccessChain %23 %11 %86
244 %92 = OpAccessChain %18 %16 %17 %91
246 %94 = OpAccessChain %18 %16 %17 %31
248 %96 = OpSNegate %6 %95
249 %97 = OpAccessChain %23 %11 %93
251 %99 = OpAccessChain %18 %16 %17 %98
253 %101 = OpAccessChain %18 %16 %17 %31
254 %102 = OpLoad %6 %101
255 %103 = OpSNegate %6 %102
256 %104 = OpAccessChain %23 %11 %100
258 %106 = OpAccessChain %18 %16 %17 %105
259 %107 = OpLoad %6 %106
260 %108 = OpAccessChain %18 %16 %17 %31
261 %109 = OpLoad %6 %108
262 %110 = OpSNegate %6 %109
263 %111 = OpAccessChain %23 %11 %107
265 %113 = OpAccessChain %18 %16 %17 %112
266 %114 = OpLoad %6 %113
267 %115 = OpAccessChain %18 %16 %17 %31
268 %116 = OpLoad %6 %115
269 %117 = OpSNegate %6 %116
270 %118 = OpAccessChain %23 %11 %114
275 OpLoopMerge %122 %123 None
278 %125 = OpLoad %6 %119
279 %126 = OpAccessChain %18 %16 %17 %49
280 %127 = OpLoad %6 %126
281 %129 = OpSLessThan %128 %125 %127
282 OpBranchConditional %129 %121 %122
284 %131 = OpLoad %6 %119
285 %132 = OpLoad %6 %119
287 %134 = OpLoad %6 %119
289 %136 = OpAccessChain %18 %16 %17 %25
290 %137 = OpLoad %6 %136
291 %138 = OpExtInst %6 %1 SClamp %133 %135 %137
293 %140 = OpAccessChain %23 %130 %131
297 %141 = OpLoad %6 %119
298 %142 = OpIAdd %6 %141 %25
302 %144 = OpAccessChain %18 %16 %17 %49
303 %145 = OpLoad %6 %144
307 OpLoopMerge %148 %149 None
310 %151 = OpLoad %6 %143
311 %152 = OpAccessChain %18 %16 %17 %84
312 %153 = OpLoad %6 %152
313 %154 = OpSLessThan %128 %151 %153
314 OpBranchConditional %154 %147 %148
316 %155 = OpLoad %6 %143
317 %156 = OpLoad %6 %143
319 %158 = OpExtInst %6 %1 SClamp %157 %17 %25
321 %160 = OpAccessChain %23 %130 %155
325 %161 = OpLoad %6 %143
326 %162 = OpIAdd %6 %161 %25
330 %164 = OpAccessChain %18 %16 %17 %84
331 %165 = OpLoad %6 %164
335 OpLoopMerge %168 %169 None
338 %171 = OpLoad %6 %163
339 %173 = OpAccessChain %18 %16 %17 %172
340 %174 = OpLoad %6 %173
341 %175 = OpSLessThan %128 %171 %174
342 OpBranchConditional %175 %167 %168
344 %176 = OpLoad %6 %163
345 %177 = OpLoad %6 %163
346 %178 = OpExtInst %6 %1 SClamp %177 %17 %25
348 %180 = OpAccessChain %23 %130 %176
352 %181 = OpLoad %6 %163
353 %182 = OpIAdd %6 %181 %25
357 %184 = OpAccessChain %18 %16 %17 %17
358 %185 = OpLoad %6 %184
362 OpLoopMerge %188 %189 None
365 %191 = OpLoad %6 %183
366 %192 = OpAccessChain %18 %16 %17 %172
367 %193 = OpLoad %6 %192
368 %194 = OpSLessThan %128 %191 %193
369 OpBranchConditional %194 %187 %188
371 %195 = OpLoad %6 %183
372 %196 = OpAccessChain %23 %130 %195
373 %197 = OpLoad %6 %196
374 %198 = OpLoad %6 %183
375 %199 = OpAccessChain %23 %11 %198
376 %200 = OpLoad %6 %199
377 %201 = OpINotEqual %128 %197 %200
378 OpSelectionMerge %203 None
379 OpBranchConditional %201 %202 %203
381 %208 = OpAccessChain %18 %16 %17 %17
382 %209 = OpLoad %6 %208
383 %210 = OpConvertSToF %204 %209
384 %211 = OpCompositeConstruct %205 %210 %210 %210 %210
390 %213 = OpLoad %6 %183
391 %214 = OpIAdd %6 %213 %25
395 %215 = OpAccessChain %18 %16 %17 %25
396 %216 = OpLoad %6 %215
397 %217 = OpConvertSToF %204 %216
398 %218 = OpAccessChain %18 %16 %17 %17
399 %219 = OpLoad %6 %218
400 %220 = OpConvertSToF %204 %219
401 %221 = OpAccessChain %18 %16 %17 %17
402 %222 = OpLoad %6 %221
403 %223 = OpConvertSToF %204 %222
404 %224 = OpAccessChain %18 %16 %17 %25
405 %225 = OpLoad %6 %224
406 %226 = OpConvertSToF %204 %225
407 %227 = OpCompositeConstruct %205 %217 %220 %223 %226
413 # uniforms for variant
415 # _GLF_uniform_int_values
416 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
417 0 1 2 3 4 5 10 15 6 7 8 9 11 12 13 14
420 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
422 PIPELINE graphics variant_pipeline
423 ATTACH variant_vertex_shader
424 ATTACH variant_fragment_shader
425 FRAMEBUFFER_SIZE 16 16
426 BIND BUFFER variant_framebuffer AS color LOCATION 0
427 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
429 CLEAR_COLOR variant_pipeline 0 0 0 255
431 CLEAR variant_pipeline
432 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 16 16
434 EXPECT variant_framebuffer IDX 0 0 SIZE 16 16 EQ_RGBA 255 0 0 255