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 bug found by the GraphicsFuzz project.
20 # Short description: Equivalent shaders except one declares a bvec4
22 # The test passes because both shaders render the same image.
24 SHADER vertex reference_vertex_shader PASSTHROUGH
26 SHADER fragment reference_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
29 ; Generator: Khronos Glslang Reference Front End; 7
33 %1 = OpExtInstImport "GLSL.std.450"
34 OpMemoryModel Logical GLSL450
35 OpEntryPoint Fragment %4 "main" %165 %180
36 OpExecutionMode %4 OriginUpperLeft
39 OpName %15 "collision(vf2;vf4;"
42 OpName %19 "match(vf2;"
48 OpName %109 "indexable"
49 OpName %135 "indexable"
50 OpName %140 "indexable"
51 OpName %154 "indexable"
53 OpName %165 "gl_FragCoord"
55 OpMemberName %168 0 "resolution"
57 OpName %180 "_GLF_color"
61 OpDecorate %165 BuiltIn FragCoord
62 OpMemberDecorate %168 0 Offset 0
64 OpDecorate %170 DescriptorSet 0
65 OpDecorate %170 Binding 0
66 OpDecorate %180 Location 0
68 %3 = OpTypeFunction %2
70 %7 = OpTypeVector %6 2
71 %8 = OpTypePointer Function %7
72 %9 = OpTypeVector %6 4
73 %10 = OpTypePointer Function %9
75 %12 = OpTypeFunction %11 %8 %10
76 %17 = OpTypeFunction %9 %8
78 %22 = OpConstant %21 0
79 %23 = OpTypePointer Function %6
80 %31 = OpConstantFalse %11
81 %33 = OpConstant %21 1
82 %46 = OpConstant %21 2
83 %58 = OpConstant %21 3
84 %66 = OpConstantTrue %11
85 %70 = OpConstant %6 0.5
87 %72 = OpConstantComposite %9 %70 %70 %71 %71
89 %74 = OpTypePointer Function %73
90 %76 = OpConstant %73 0
91 %83 = OpConstant %73 8
92 %85 = OpConstant %21 8
93 %86 = OpTypeArray %9 %85
95 %88 = OpConstant %6 20
96 %89 = OpConstantComposite %9 %87 %87 %88 %87
97 %90 = OpConstantComposite %9 %87 %87 %87 %88
98 %91 = OpConstantComposite %9 %87 %88 %88 %87
100 %93 = OpConstantComposite %9 %88 %87 %87 %92
101 %94 = OpConstant %6 6
102 %95 = OpConstant %6 2
103 %96 = OpConstantComposite %9 %92 %94 %87 %95
104 %97 = OpConstant %6 12
105 %98 = OpConstantComposite %9 %95 %97 %95 %87
106 %99 = OpConstant %6 16
107 %100 = OpConstantComposite %9 %99 %95 %87 %87
108 %101 = OpConstant %6 22
109 %102 = OpConstantComposite %9 %97 %101 %87 %87
110 %103 = OpConstantComposite %86 %89 %90 %91 %93 %96 %98 %100 %102
111 %108 = OpTypePointer Function %86
112 %115 = OpConstant %21 16
113 %116 = OpTypeArray %9 %115
114 %117 = OpConstant %6 0
115 %118 = OpConstantComposite %9 %117 %117 %117 %71
116 %119 = OpConstantComposite %9 %70 %117 %117 %71
117 %120 = OpConstantComposite %9 %117 %70 %117 %71
118 %121 = OpConstantComposite %9 %70 %70 %117 %71
119 %122 = OpConstantComposite %9 %117 %117 %70 %71
120 %123 = OpConstantComposite %9 %70 %117 %70 %71
121 %124 = OpConstantComposite %9 %117 %70 %70 %71
122 %125 = OpConstantComposite %9 %70 %70 %70 %71
123 %126 = OpConstantComposite %9 %71 %117 %117 %71
124 %127 = OpConstantComposite %9 %117 %71 %117 %71
125 %128 = OpConstantComposite %9 %71 %71 %117 %71
126 %129 = OpConstantComposite %9 %117 %117 %71 %71
127 %130 = OpConstantComposite %9 %71 %117 %71 %71
128 %131 = OpConstantComposite %9 %117 %71 %71 %71
129 %132 = OpConstantComposite %9 %71 %71 %71 %71
130 %133 = OpConstantComposite %116 %118 %119 %120 %121 %122 %123 %124 %125 %118 %126 %127 %128 %129 %130 %131 %132
131 %146 = OpConstant %73 9
132 %149 = OpConstant %73 11
133 %151 = OpConstant %73 16
134 %153 = OpTypePointer Function %116
135 %158 = OpConstant %73 1
136 %164 = OpTypePointer Input %9
137 %165 = OpVariable %164 Input
138 %168 = OpTypeStruct %7
139 %169 = OpTypePointer Uniform %168
140 %170 = OpVariable %169 Uniform
141 %171 = OpTypePointer Uniform %7
142 %176 = OpConstant %6 32
143 %179 = OpTypePointer Output %9
144 %180 = OpVariable %179 Output
145 %184 = OpTypePointer Private %73
146 %185 = OpVariable %184 Private
147 %186 = OpTypeArray %73 %115
148 %187 = OpTypePointer Private %186
149 %188 = OpVariable %187 Private
150 %4 = OpFunction %2 None %3
152 %163 = OpVariable %8 Function
153 %181 = OpVariable %8 Function
154 %166 = OpLoad %9 %165
155 %167 = OpVectorShuffle %7 %166 %166 0 1
156 %172 = OpAccessChain %171 %170 %76
157 %173 = OpLoad %7 %172
158 %174 = OpFDiv %7 %167 %173
160 %175 = OpLoad %7 %163
161 %177 = OpVectorTimesScalar %7 %175 %176
162 %178 = OpExtInst %7 %1 Floor %177
164 %182 = OpLoad %7 %163
166 %183 = OpFunctionCall %9 %19 %181
170 %15 = OpFunction %11 None %12
171 %13 = OpFunctionParameter %8
172 %14 = OpFunctionParameter %10
174 %24 = OpAccessChain %23 %13 %22
176 %26 = OpAccessChain %23 %14 %22
178 %28 = OpFOrdLessThan %11 %25 %27
179 OpSelectionMerge %30 None
180 OpBranchConditional %28 %29 %30
184 %34 = OpAccessChain %23 %13 %33
186 %36 = OpAccessChain %23 %14 %33
188 %38 = OpFOrdLessThan %11 %35 %37
189 OpSelectionMerge %40 None
190 OpBranchConditional %38 %39 %40
194 %42 = OpAccessChain %23 %13 %22
196 %44 = OpAccessChain %23 %14 %22
198 %47 = OpAccessChain %23 %14 %46
200 %49 = OpFAdd %6 %45 %48
201 %50 = OpFOrdGreaterThan %11 %43 %49
202 OpSelectionMerge %52 None
203 OpBranchConditional %50 %51 %52
207 %54 = OpAccessChain %23 %13 %33
209 %56 = OpAccessChain %23 %14 %33
211 %59 = OpAccessChain %23 %14 %58
213 %61 = OpFAdd %6 %57 %60
214 %62 = OpFOrdGreaterThan %11 %55 %61
215 OpSelectionMerge %64 None
216 OpBranchConditional %62 %63 %64
222 %19 = OpFunction %9 None %17
223 %18 = OpFunctionParameter %8
225 %69 = OpVariable %10 Function
226 %75 = OpVariable %74 Function
227 %105 = OpVariable %8 Function
228 %107 = OpVariable %10 Function
229 %109 = OpVariable %108 Function
230 %135 = OpVariable %108 Function
231 %140 = OpVariable %108 Function
232 %154 = OpVariable %153 Function
237 OpLoopMerge %79 %80 None
241 %84 = OpSLessThan %11 %82 %83
242 OpBranchConditional %84 %78 %79
244 %104 = OpLoad %73 %75
248 %110 = OpAccessChain %10 %109 %104
249 %111 = OpLoad %9 %110
251 %112 = OpFunctionCall %11 %15 %105 %107
252 OpSelectionMerge %114 None
253 OpBranchConditional %112 %113 %114
255 %134 = OpLoad %73 %75
257 %136 = OpAccessChain %23 %135 %134 %22
258 %137 = OpLoad %6 %136
259 %138 = OpConvertFToS %73 %137
260 %139 = OpLoad %73 %75
262 %141 = OpAccessChain %23 %140 %139 %33
263 %142 = OpLoad %6 %141
264 %143 = OpConvertFToS %73 %142
265 %144 = OpIMul %73 %138 %143
266 %145 = OpLoad %73 %75
267 %147 = OpIMul %73 %145 %146
268 %148 = OpIAdd %73 %144 %147
269 %150 = OpIAdd %73 %148 %149
270 %152 = OpSMod %73 %150 %151
272 %155 = OpAccessChain %10 %154 %152
273 %156 = OpLoad %9 %155
279 %157 = OpLoad %73 %75
280 %159 = OpIAdd %73 %157 %158
289 # uniforms for reference
292 BUFFER reference_resolution DATA_TYPE vec2<float> DATA
296 BUFFER reference_framebuffer FORMAT B8G8R8A8_UNORM
298 PIPELINE graphics reference_pipeline
299 ATTACH reference_vertex_shader
300 ATTACH reference_fragment_shader
301 FRAMEBUFFER_SIZE 256 256
302 BIND BUFFER reference_framebuffer AS color LOCATION 0
303 BIND BUFFER reference_resolution AS uniform DESCRIPTOR_SET 0 BINDING 0
305 CLEAR_COLOR reference_pipeline 0 0 0 255
307 CLEAR reference_pipeline
308 RUN reference_pipeline DRAW_RECT POS 0 0 SIZE 256 256
311 SHADER vertex variant_vertex_shader PASSTHROUGH
313 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
316 ; Generator: Khronos Glslang Reference Front End; 7
320 %1 = OpExtInstImport "GLSL.std.450"
321 OpMemoryModel Logical GLSL450
322 OpEntryPoint Fragment %4 "main" %165 %180
323 OpExecutionMode %4 OriginUpperLeft
326 OpName %15 "collision(vf2;vf4;"
329 OpName %19 "match(vf2;"
335 OpName %109 "indexable"
336 OpName %135 "indexable"
337 OpName %140 "indexable"
338 OpName %154 "indexable"
340 OpName %165 "gl_FragCoord"
342 OpMemberName %168 0 "resolution"
344 OpName %180 "_GLF_color"
348 OpDecorate %165 BuiltIn FragCoord
349 OpMemberDecorate %168 0 Offset 0
350 OpDecorate %168 Block
351 OpDecorate %170 DescriptorSet 0
352 OpDecorate %170 Binding 0
353 OpDecorate %180 Location 0
355 %3 = OpTypeFunction %2
357 %7 = OpTypeVector %6 2
358 %8 = OpTypePointer Function %7
359 %9 = OpTypeVector %6 4
360 %10 = OpTypePointer Function %9
362 %12 = OpTypeFunction %11 %8 %10
363 %17 = OpTypeFunction %9 %8
365 %22 = OpConstant %21 0
366 %23 = OpTypePointer Function %6
367 %31 = OpConstantFalse %11
368 %33 = OpConstant %21 1
369 %46 = OpConstant %21 2
370 %58 = OpConstant %21 3
371 %66 = OpConstantTrue %11
372 %70 = OpConstant %6 0.5
373 %71 = OpConstant %6 1
374 %72 = OpConstantComposite %9 %70 %70 %71 %71
376 %74 = OpTypePointer Function %73
377 %76 = OpConstant %73 0
378 %83 = OpConstant %73 8
379 %85 = OpConstant %21 8
380 %86 = OpTypeArray %9 %85
381 %87 = OpConstant %6 4
382 %88 = OpConstant %6 20
383 %89 = OpConstantComposite %9 %87 %87 %88 %87
384 %90 = OpConstantComposite %9 %87 %87 %87 %88
385 %91 = OpConstantComposite %9 %87 %88 %88 %87
386 %92 = OpConstant %6 8
387 %93 = OpConstantComposite %9 %88 %87 %87 %92
388 %94 = OpConstant %6 6
389 %95 = OpConstant %6 2
390 %96 = OpConstantComposite %9 %92 %94 %87 %95
391 %97 = OpConstant %6 12
392 %98 = OpConstantComposite %9 %95 %97 %95 %87
393 %99 = OpConstant %6 16
394 %100 = OpConstantComposite %9 %99 %95 %87 %87
395 %101 = OpConstant %6 22
396 %102 = OpConstantComposite %9 %97 %101 %87 %87
397 %103 = OpConstantComposite %86 %89 %90 %91 %93 %96 %98 %100 %102
398 %108 = OpTypePointer Function %86
399 %115 = OpConstant %21 16
400 %116 = OpTypeArray %9 %115
401 %117 = OpConstant %6 0
402 %118 = OpConstantComposite %9 %117 %117 %117 %71
403 %119 = OpConstantComposite %9 %70 %117 %117 %71
404 %120 = OpConstantComposite %9 %117 %70 %117 %71
405 %121 = OpConstantComposite %9 %70 %70 %117 %71
406 %122 = OpConstantComposite %9 %117 %117 %70 %71
407 %123 = OpConstantComposite %9 %70 %117 %70 %71
408 %124 = OpConstantComposite %9 %117 %70 %70 %71
409 %125 = OpConstantComposite %9 %70 %70 %70 %71
410 %126 = OpConstantComposite %9 %71 %117 %117 %71
411 %127 = OpConstantComposite %9 %117 %71 %117 %71
412 %128 = OpConstantComposite %9 %71 %71 %117 %71
413 %129 = OpConstantComposite %9 %117 %117 %71 %71
414 %130 = OpConstantComposite %9 %71 %117 %71 %71
415 %131 = OpConstantComposite %9 %117 %71 %71 %71
416 %132 = OpConstantComposite %9 %71 %71 %71 %71
417 %133 = OpConstantComposite %116 %118 %119 %120 %121 %122 %123 %124 %125 %118 %126 %127 %128 %129 %130 %131 %132
418 %146 = OpConstant %73 9
419 %149 = OpConstant %73 11
420 %151 = OpConstant %73 16
421 %153 = OpTypePointer Function %116
422 %158 = OpConstant %73 1
423 %164 = OpTypePointer Input %9
424 %165 = OpVariable %164 Input
425 %168 = OpTypeStruct %7
426 %169 = OpTypePointer Uniform %168
427 %170 = OpVariable %169 Uniform
428 %171 = OpTypePointer Uniform %7
429 %176 = OpConstant %6 32
430 %179 = OpTypePointer Output %9
431 %180 = OpVariable %179 Output
432 %184 = OpTypePointer Private %73
433 %185 = OpVariable %184 Private
434 %186 = OpTypeArray %73 %115
435 %187 = OpTypePointer Private %186
436 %188 = OpVariable %187 Private
437 %313 = OpTypeVector %11 4
438 %363 = OpTypePointer Function %313
439 %364 = OpConstantComposite %313 %31 %31 %31 %31
440 %4 = OpFunction %2 None %3
442 %163 = OpVariable %8 Function
443 %181 = OpVariable %8 Function
444 %166 = OpLoad %9 %165
445 %167 = OpVectorShuffle %7 %166 %166 0 1
446 %172 = OpAccessChain %171 %170 %76
447 %173 = OpLoad %7 %172
448 %174 = OpFDiv %7 %167 %173
450 %175 = OpLoad %7 %163
451 %177 = OpVectorTimesScalar %7 %175 %176
452 %178 = OpExtInst %7 %1 Floor %177
454 %182 = OpLoad %7 %163
456 %183 = OpFunctionCall %9 %19 %181
460 %15 = OpFunction %11 None %12
461 %13 = OpFunctionParameter %8
462 %14 = OpFunctionParameter %10
464 %365 = OpVariable %363 Function %364
465 %24 = OpAccessChain %23 %13 %22
467 %26 = OpAccessChain %23 %14 %22
469 %28 = OpFOrdLessThan %11 %25 %27
470 OpSelectionMerge %30 None
471 OpBranchConditional %28 %29 %30
475 %34 = OpAccessChain %23 %13 %33
477 %36 = OpAccessChain %23 %14 %33
479 %38 = OpFOrdLessThan %11 %35 %37
480 OpSelectionMerge %40 None
481 OpBranchConditional %38 %39 %40
485 %42 = OpAccessChain %23 %13 %22
487 %44 = OpAccessChain %23 %14 %22
489 %47 = OpAccessChain %23 %14 %46
491 %49 = OpFAdd %6 %45 %48
492 %50 = OpFOrdGreaterThan %11 %43 %49
493 OpSelectionMerge %52 None
494 OpBranchConditional %50 %51 %52
498 %54 = OpAccessChain %23 %13 %33
500 %56 = OpAccessChain %23 %14 %33
502 %59 = OpAccessChain %23 %14 %58
504 %61 = OpFAdd %6 %57 %60
505 %62 = OpFOrdGreaterThan %11 %55 %61
506 OpSelectionMerge %64 None
507 OpBranchConditional %62 %63 %64
513 %19 = OpFunction %9 None %17
514 %18 = OpFunctionParameter %8
516 %69 = OpVariable %10 Function
517 %75 = OpVariable %74 Function
518 %105 = OpVariable %8 Function
519 %107 = OpVariable %10 Function
520 %109 = OpVariable %108 Function
521 %135 = OpVariable %108 Function
522 %140 = OpVariable %108 Function
523 %154 = OpVariable %153 Function
528 OpLoopMerge %79 %80 None
532 %84 = OpSLessThan %11 %82 %83
533 OpBranchConditional %84 %78 %79
535 %104 = OpLoad %73 %75
539 %110 = OpAccessChain %10 %109 %104
540 %111 = OpLoad %9 %110
542 %112 = OpFunctionCall %11 %15 %105 %107
543 OpSelectionMerge %114 None
544 OpBranchConditional %112 %113 %114
546 %134 = OpLoad %73 %75
548 %136 = OpAccessChain %23 %135 %134 %22
549 %137 = OpLoad %6 %136
550 %138 = OpConvertFToS %73 %137
551 %139 = OpLoad %73 %75
553 %141 = OpAccessChain %23 %140 %139 %33
554 %142 = OpLoad %6 %141
555 %143 = OpConvertFToS %73 %142
556 %144 = OpIMul %73 %138 %143
557 %145 = OpLoad %73 %75
558 %147 = OpIMul %73 %145 %146
559 %148 = OpIAdd %73 %144 %147
560 %150 = OpIAdd %73 %148 %149
561 %152 = OpSMod %73 %150 %151
563 %155 = OpAccessChain %10 %154 %152
564 %156 = OpLoad %9 %155
570 %157 = OpLoad %73 %75
571 %159 = OpIAdd %73 %157 %158
580 # uniforms for variant
583 BUFFER variant_resolution DATA_TYPE vec2<float> DATA
587 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
589 PIPELINE graphics variant_pipeline
590 ATTACH variant_vertex_shader
591 ATTACH variant_fragment_shader
592 FRAMEBUFFER_SIZE 256 256
593 BIND BUFFER variant_framebuffer AS color LOCATION 0
594 BIND BUFFER variant_resolution AS uniform DESCRIPTOR_SET 0 BINDING 0
596 CLEAR_COLOR variant_pipeline 0 0 0 255
598 CLEAR variant_pipeline
599 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
601 EXPECT reference_framebuffer EQ_HISTOGRAM_EMD_BUFFER variant_framebuffer TOLERANCE 0.005