Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / spv-stable-bifurcation-Os-mutate-var-vector-shuffle.amber
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 bug found by the GraphicsFuzz project.
19
20 # Short description: Three shaders diff: mutate var, vector shuffle
21
22 # The test renders three images using semantically equivalent shaders, and then
23 # checks that the images are similar.
24 # The test passes because the shaders have the same semantics and so the images
25 # should be the same.
26
27 SHADER vertex reference_vertex_shader PASSTHROUGH
28
29 SHADER fragment reference_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
30 ; SPIR-V
31 ; Version: 1.0
32 ; Generator: Khronos Glslang Reference Front End; 7
33 ; Bound: 107
34 ; Schema: 0
35                OpCapability Shader
36           %1 = OpExtInstImport "GLSL.std.450"
37                OpMemoryModel Logical GLSL450
38                OpEntryPoint Fragment %4 "main" %12 %74
39                OpExecutionMode %4 OriginUpperLeft
40                OpSource ESSL 320
41                OpName %4 "main"
42                OpName %12 "gl_FragCoord"
43                OpName %15 "buf0"
44                OpMemberName %15 0 "resolution"
45                OpName %17 ""
46                OpName %74 "_GLF_color"
47                OpName %100 "indexable"
48                OpDecorate %12 BuiltIn FragCoord
49                OpMemberDecorate %15 0 Offset 0
50                OpDecorate %15 Block
51                OpDecorate %17 DescriptorSet 0
52                OpDecorate %17 Binding 0
53                OpDecorate %74 Location 0
54           %2 = OpTypeVoid
55           %3 = OpTypeFunction %2
56           %6 = OpTypeFloat 32
57           %7 = OpTypeVector %6 2
58          %10 = OpTypeVector %6 4
59          %11 = OpTypePointer Input %10
60          %12 = OpVariable %11 Input
61          %15 = OpTypeStruct %7
62          %16 = OpTypePointer Uniform %15
63          %17 = OpVariable %16 Uniform
64          %18 = OpTypeInt 32 1
65          %19 = OpConstant %18 0
66          %20 = OpTypePointer Uniform %7
67          %27 = OpTypeInt 32 0
68          %32 = OpConstant %6 10
69          %47 = OpConstant %18 10
70          %51 = OpConstant %18 100
71          %60 = OpTypeBool
72          %62 = OpConstant %18 4
73          %65 = OpConstant %18 1000
74          %71 = OpConstant %18 1
75          %73 = OpTypePointer Output %10
76          %74 = OpVariable %73 Output
77          %75 = OpConstant %27 16
78          %76 = OpTypeArray %10 %75
79          %77 = OpConstant %6 0
80          %78 = OpConstant %6 1
81          %79 = OpConstantComposite %10 %77 %77 %77 %78
82          %80 = OpConstant %6 0.5
83          %81 = OpConstantComposite %10 %80 %77 %77 %78
84          %82 = OpConstantComposite %10 %77 %80 %77 %78
85          %83 = OpConstantComposite %10 %80 %80 %77 %78
86          %84 = OpConstantComposite %10 %77 %77 %80 %78
87          %85 = OpConstantComposite %10 %80 %77 %80 %78
88          %86 = OpConstantComposite %10 %77 %80 %80 %78
89          %87 = OpConstantComposite %10 %80 %80 %80 %78
90          %88 = OpConstantComposite %10 %78 %77 %77 %78
91          %89 = OpConstantComposite %10 %77 %78 %77 %78
92          %90 = OpConstantComposite %10 %78 %78 %77 %78
93          %91 = OpConstantComposite %10 %77 %77 %78 %78
94          %92 = OpConstantComposite %10 %78 %77 %78 %78
95          %93 = OpConstantComposite %10 %77 %78 %78 %78
96          %94 = OpConstantComposite %10 %78 %78 %78 %78
97          %95 = OpConstantComposite %76 %79 %81 %82 %83 %84 %85 %86 %87 %79 %88 %89 %90 %91 %92 %93 %94
98          %97 = OpConstant %18 16
99          %99 = OpTypePointer Function %76
100         %101 = OpTypePointer Function %10
101           %4 = OpFunction %2 None %3
102           %5 = OpLabel
103         %100 = OpVariable %99 Function
104          %13 = OpLoad %10 %12
105          %14 = OpVectorShuffle %7 %13 %13 0 1
106          %21 = OpAccessChain %20 %17 %19
107          %22 = OpLoad %7 %21
108          %23 = OpFDiv %7 %14 %22
109          %31 = OpCompositeExtract %6 %23 0
110          %33 = OpFMul %6 %31 %32
111          %34 = OpConvertFToS %18 %33
112          %37 = OpCompositeExtract %6 %23 1
113          %38 = OpFMul %6 %37 %32
114          %39 = OpConvertFToS %18 %38
115          %48 = OpIMul %18 %39 %47
116          %49 = OpIAdd %18 %34 %48
117                OpBranch %53
118          %53 = OpLabel
119         %106 = OpPhi %18 %51 %5 %69 %54
120         %104 = OpPhi %18 %19 %5 %72 %54
121          %61 = OpSLessThan %60 %104 %49
122                OpLoopMerge %55 %54 None
123                OpBranchConditional %61 %54 %55
124          %54 = OpLabel
125          %64 = OpIMul %18 %62 %106
126          %67 = OpISub %18 %65 %106
127          %68 = OpIMul %18 %64 %67
128          %69 = OpSDiv %18 %68 %65
129          %72 = OpIAdd %18 %104 %71
130                OpBranch %53
131          %55 = OpLabel
132          %98 = OpSMod %18 %106 %97
133                OpStore %100 %95
134         %102 = OpAccessChain %101 %100 %98
135         %103 = OpLoad %10 %102
136                OpStore %74 %103
137                OpReturn
138                OpFunctionEnd
139 END
140
141 # uniforms for reference
142
143 # resolution
144 BUFFER reference_resolution DATA_TYPE vec2<float> STD140 DATA
145  256.0 256.0
146 END
147
148 BUFFER reference_framebuffer FORMAT B8G8R8A8_UNORM
149
150 PIPELINE graphics reference_pipeline
151   ATTACH reference_vertex_shader
152   ATTACH reference_fragment_shader
153   FRAMEBUFFER_SIZE 256 256
154   BIND BUFFER reference_framebuffer AS color LOCATION 0
155   BIND BUFFER reference_resolution AS uniform DESCRIPTOR_SET 0 BINDING 0
156 END
157 CLEAR_COLOR reference_pipeline 0 0 0 255
158
159 CLEAR reference_pipeline
160 RUN reference_pipeline DRAW_RECT POS 0 0 SIZE 256 256
161
162
163 SHADER vertex variant_vertex_shader PASSTHROUGH
164
165 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
166 ; SPIR-V
167 ; Version: 1.0
168 ; Generator: Khronos Glslang Reference Front End; 7
169 ; Bound: 263
170 ; Schema: 0
171                OpCapability Shader
172           %1 = OpExtInstImport "GLSL.std.450"
173                OpMemoryModel Logical GLSL450
174                OpEntryPoint Fragment %4 "main" %12 %74
175                OpExecutionMode %4 OriginUpperLeft
176                OpSource ESSL 320
177                OpName %4 "main"
178                OpName %12 "gl_FragCoord"
179                OpName %15 "buf0"
180                OpMemberName %15 0 "resolution"
181                OpName %17 ""
182                OpName %74 "_GLF_color"
183                OpName %100 "indexable"
184                OpDecorate %12 BuiltIn FragCoord
185                OpMemberDecorate %15 0 Offset 0
186                OpDecorate %15 Block
187                OpDecorate %17 DescriptorSet 0
188                OpDecorate %17 Binding 0
189                OpDecorate %74 Location 0
190           %2 = OpTypeVoid
191           %3 = OpTypeFunction %2
192           %6 = OpTypeFloat 32
193           %7 = OpTypeVector %6 2
194          %10 = OpTypeVector %6 4
195          %11 = OpTypePointer Input %10
196          %12 = OpVariable %11 Input
197          %15 = OpTypeStruct %7
198          %16 = OpTypePointer Uniform %15
199          %17 = OpVariable %16 Uniform
200          %18 = OpTypeInt 32 1
201          %19 = OpConstant %18 0
202          %20 = OpTypePointer Uniform %7
203          %27 = OpTypeInt 32 0
204          %32 = OpConstant %6 10
205          %47 = OpConstant %18 10
206          %51 = OpConstant %18 100
207          %60 = OpTypeBool
208          %62 = OpConstant %18 4
209          %65 = OpConstant %18 1000
210          %71 = OpConstant %18 1
211          %73 = OpTypePointer Output %10
212          %74 = OpVariable %73 Output
213          %75 = OpConstant %27 16
214          %76 = OpTypeArray %10 %75
215          %77 = OpConstant %6 0
216          %78 = OpConstant %6 1
217          %79 = OpConstantComposite %10 %77 %77 %77 %78
218          %80 = OpConstant %6 0.5
219          %81 = OpConstantComposite %10 %80 %77 %77 %78
220          %82 = OpConstantComposite %10 %77 %80 %77 %78
221          %83 = OpConstantComposite %10 %80 %80 %77 %78
222          %84 = OpConstantComposite %10 %77 %77 %80 %78
223          %85 = OpConstantComposite %10 %80 %77 %80 %78
224          %86 = OpConstantComposite %10 %77 %80 %80 %78
225          %87 = OpConstantComposite %10 %80 %80 %80 %78
226          %88 = OpConstantComposite %10 %78 %77 %77 %78
227          %89 = OpConstantComposite %10 %77 %78 %77 %78
228          %90 = OpConstantComposite %10 %78 %78 %77 %78
229          %91 = OpConstantComposite %10 %77 %77 %78 %78
230          %92 = OpConstantComposite %10 %78 %77 %78 %78
231          %93 = OpConstantComposite %10 %77 %78 %78 %78
232          %94 = OpConstantComposite %10 %78 %78 %78 %78
233          %95 = OpConstantComposite %76 %79 %81 %82 %83 %84 %85 %86 %87 %79 %88 %89 %90 %91 %92 %93 %94
234          %97 = OpConstant %18 16
235          %99 = OpTypePointer Function %76
236         %101 = OpTypePointer Function %10
237         %234 = OpConstant %6 0
238         %235 = OpConstantComposite %10 %234 %234 %234 %234
239         %236 = OpConstantComposite %76 %235 %235 %235 %235 %235 %235 %235 %235 %235 %235 %235 %235 %235 %235 %235 %235
240           %4 = OpFunction %2 None %3
241           %5 = OpLabel
242         %100 = OpVariable %99 Function
243          %13 = OpLoad %10 %12
244          %14 = OpVectorShuffle %7 %13 %13 0 1
245          %21 = OpAccessChain %20 %17 %19
246          %22 = OpLoad %7 %21
247          %23 = OpFDiv %7 %14 %22
248          %31 = OpCompositeExtract %6 %23 0
249          %33 = OpFMul %6 %31 %32
250          %34 = OpConvertFToS %18 %33
251          %37 = OpCompositeExtract %6 %23 1
252          %38 = OpFMul %6 %37 %32
253          %39 = OpConvertFToS %18 %38
254          %48 = OpIMul %18 %39 %47
255          %49 = OpIAdd %18 %34 %48
256                OpBranch %53
257          %53 = OpLabel
258         %106 = OpPhi %18 %51 %5 %69 %54
259         %104 = OpPhi %18 %19 %5 %72 %54
260          %61 = OpSLessThan %60 %104 %49
261                OpLoopMerge %55 %54 None
262                OpBranchConditional %61 %54 %55
263          %54 = OpLabel
264          %64 = OpIMul %18 %62 %106
265          %67 = OpISub %18 %65 %106
266          %68 = OpIMul %18 %64 %67
267          %69 = OpSDiv %18 %68 %65
268          %72 = OpIAdd %18 %104 %71
269                OpBranch %53
270          %55 = OpLabel
271          %98 = OpSMod %18 %106 %97
272                OpStore %100 %95
273         %262 = OpLoad %76 %100
274                OpStore %100 %236
275                OpStore %100 %262
276         %231 = OpVectorShuffle %7 %89 %85 1 4
277         %102 = OpAccessChain %101 %100 %98
278         %103 = OpLoad %10 %102
279                OpStore %74 %103
280                OpReturn
281                OpFunctionEnd
282 END
283
284 # uniforms for variant
285
286 # resolution
287 BUFFER variant_resolution DATA_TYPE vec2<float> STD140 DATA
288  256.0 256.0
289 END
290
291 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
292
293 PIPELINE graphics variant_pipeline
294   ATTACH variant_vertex_shader
295   ATTACH variant_fragment_shader
296   FRAMEBUFFER_SIZE 256 256
297   BIND BUFFER variant_framebuffer AS color LOCATION 0
298   BIND BUFFER variant_resolution AS uniform DESCRIPTOR_SET 0 BINDING 0
299 END
300 CLEAR_COLOR variant_pipeline 0 0 0 255
301
302 CLEAR variant_pipeline
303 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
304
305
306 SHADER vertex variant_2_vertex_shader PASSTHROUGH
307
308 SHADER fragment variant_2_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
309 ; SPIR-V
310 ; Version: 1.0
311 ; Generator: Khronos Glslang Reference Front End; 7
312 ; Bound: 237
313 ; Schema: 0
314                OpCapability Shader
315           %1 = OpExtInstImport "GLSL.std.450"
316                OpMemoryModel Logical GLSL450
317                OpEntryPoint Fragment %4 "main" %12 %74
318                OpExecutionMode %4 OriginUpperLeft
319                OpSource ESSL 320
320                OpName %4 "main"
321                OpName %12 "gl_FragCoord"
322                OpName %15 "buf0"
323                OpMemberName %15 0 "resolution"
324                OpName %17 ""
325                OpName %74 "_GLF_color"
326                OpName %100 "indexable"
327                OpDecorate %12 BuiltIn FragCoord
328                OpMemberDecorate %15 0 Offset 0
329                OpDecorate %15 Block
330                OpDecorate %17 DescriptorSet 0
331                OpDecorate %17 Binding 0
332                OpDecorate %74 Location 0
333           %2 = OpTypeVoid
334           %3 = OpTypeFunction %2
335           %6 = OpTypeFloat 32
336           %7 = OpTypeVector %6 2
337          %10 = OpTypeVector %6 4
338          %11 = OpTypePointer Input %10
339          %12 = OpVariable %11 Input
340          %15 = OpTypeStruct %7
341          %16 = OpTypePointer Uniform %15
342          %17 = OpVariable %16 Uniform
343          %18 = OpTypeInt 32 1
344          %19 = OpConstant %18 0
345          %20 = OpTypePointer Uniform %7
346          %27 = OpTypeInt 32 0
347          %32 = OpConstant %6 10
348          %47 = OpConstant %18 10
349          %51 = OpConstant %18 100
350          %60 = OpTypeBool
351          %62 = OpConstant %18 4
352          %65 = OpConstant %18 1000
353          %71 = OpConstant %18 1
354          %73 = OpTypePointer Output %10
355          %74 = OpVariable %73 Output
356          %75 = OpConstant %27 16
357          %76 = OpTypeArray %10 %75
358          %77 = OpConstant %6 0
359          %78 = OpConstant %6 1
360          %79 = OpConstantComposite %10 %77 %77 %77 %78
361          %80 = OpConstant %6 0.5
362          %81 = OpConstantComposite %10 %80 %77 %77 %78
363          %82 = OpConstantComposite %10 %77 %80 %77 %78
364          %83 = OpConstantComposite %10 %80 %80 %77 %78
365          %84 = OpConstantComposite %10 %77 %77 %80 %78
366          %85 = OpConstantComposite %10 %80 %77 %80 %78
367          %86 = OpConstantComposite %10 %77 %80 %80 %78
368          %87 = OpConstantComposite %10 %80 %80 %80 %78
369          %88 = OpConstantComposite %10 %78 %77 %77 %78
370          %89 = OpConstantComposite %10 %77 %78 %77 %78
371          %90 = OpConstantComposite %10 %78 %78 %77 %78
372          %91 = OpConstantComposite %10 %77 %77 %78 %78
373          %92 = OpConstantComposite %10 %78 %77 %78 %78
374          %93 = OpConstantComposite %10 %77 %78 %78 %78
375          %94 = OpConstantComposite %10 %78 %78 %78 %78
376          %95 = OpConstantComposite %76 %79 %81 %82 %83 %84 %85 %86 %87 %79 %88 %89 %90 %91 %92 %93 %94
377          %97 = OpConstant %18 16
378          %99 = OpTypePointer Function %76
379         %101 = OpTypePointer Function %10
380         %234 = OpConstant %6 0
381         %235 = OpConstantComposite %10 %234 %234 %234 %234
382         %236 = OpConstantComposite %76 %235 %235 %235 %235 %235 %235 %235 %235 %235 %235 %235 %235 %235 %235 %235 %235
383           %4 = OpFunction %2 None %3
384           %5 = OpLabel
385         %100 = OpVariable %99 Function
386          %13 = OpLoad %10 %12
387          %14 = OpVectorShuffle %7 %13 %13 0 1
388          %21 = OpAccessChain %20 %17 %19
389          %22 = OpLoad %7 %21
390          %23 = OpFDiv %7 %14 %22
391          %31 = OpCompositeExtract %6 %23 0
392          %33 = OpFMul %6 %31 %32
393          %34 = OpConvertFToS %18 %33
394          %37 = OpCompositeExtract %6 %23 1
395          %38 = OpFMul %6 %37 %32
396          %39 = OpConvertFToS %18 %38
397          %48 = OpIMul %18 %39 %47
398          %49 = OpIAdd %18 %34 %48
399                OpBranch %53
400          %53 = OpLabel
401         %106 = OpPhi %18 %51 %5 %69 %54
402         %104 = OpPhi %18 %19 %5 %72 %54
403          %61 = OpSLessThan %60 %104 %49
404                OpLoopMerge %55 %54 None
405                OpBranchConditional %61 %54 %55
406          %54 = OpLabel
407          %64 = OpIMul %18 %62 %106
408          %67 = OpISub %18 %65 %106
409          %68 = OpIMul %18 %64 %67
410          %69 = OpSDiv %18 %68 %65
411          %72 = OpIAdd %18 %104 %71
412                OpBranch %53
413          %55 = OpLabel
414          %98 = OpSMod %18 %106 %97
415                OpStore %100 %95
416         %231 = OpVectorShuffle %7 %89 %85 1 4
417         %102 = OpAccessChain %101 %100 %98
418         %103 = OpLoad %10 %102
419                OpStore %74 %103
420                OpReturn
421                OpFunctionEnd
422 END
423
424 # uniforms for variant_2
425
426 # resolution
427 BUFFER variant_2_resolution DATA_TYPE vec2<float> STD140 DATA
428  256.0 256.0
429 END
430
431 BUFFER variant_2_framebuffer FORMAT B8G8R8A8_UNORM
432
433 PIPELINE graphics variant_2_pipeline
434   ATTACH variant_2_vertex_shader
435   ATTACH variant_2_fragment_shader
436   FRAMEBUFFER_SIZE 256 256
437   BIND BUFFER variant_2_framebuffer AS color LOCATION 0
438   BIND BUFFER variant_2_resolution AS uniform DESCRIPTOR_SET 0 BINDING 0
439 END
440 CLEAR_COLOR variant_2_pipeline 0 0 0 255
441
442 CLEAR variant_2_pipeline
443 RUN variant_2_pipeline DRAW_RECT POS 0 0 SIZE 256 256
444
445 EXPECT reference_framebuffer EQ_HISTOGRAM_EMD_BUFFER variant_framebuffer TOLERANCE 0.005
446 EXPECT reference_framebuffer EQ_HISTOGRAM_EMD_BUFFER variant_2_framebuffer TOLERANCE 0.005