Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / spv-stable-sampler-loop-extra-instructions.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: Equivalent shaders, one with irrelevant extra instructions
21
22 # The test passes because both shaders render the same image.
23
24 SHADER vertex texgen_vert PASSTHROUGH
25
26 SHADER fragment texgen_frag GLSL
27 #version 430
28 precision highp float;
29
30 layout(location = 0) out vec4 _GLF_color;
31
32 void main()
33 {
34  _GLF_color = vec4(
35  floor(gl_FragCoord.x) * (1.0 / 255.0),
36  (int(gl_FragCoord.x) ^ int(gl_FragCoord.y)) * (1.0 / 255.0),
37  floor(gl_FragCoord.y) * (1.0 / 255.0),
38  1.0);
39 }
40 END
41 BUFFER default_texture FORMAT B8G8R8A8_UNORM
42
43 PIPELINE graphics texgen_pipeline
44   ATTACH texgen_vert
45   ATTACH texgen_frag
46   FRAMEBUFFER_SIZE 256 256
47   BIND BUFFER default_texture AS color LOCATION 0
48 END
49
50 CLEAR_COLOR texgen_pipeline 0 0 0 255
51 CLEAR texgen_pipeline
52 RUN texgen_pipeline DRAW_RECT POS 0 0  SIZE 256 256
53
54 SHADER vertex reference_vertex_shader PASSTHROUGH
55
56 SHADER fragment reference_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
57 ; SPIR-V
58 ; Version: 1.0
59 ; Generator: Khronos Glslang Reference Front End; 10
60 ; Bound: 75
61 ; Schema: 0
62                OpCapability Shader
63           %1 = OpExtInstImport "GLSL.std.450"
64                OpMemoryModel Logical GLSL450
65                OpEntryPoint Fragment %4 "main" %16 %73
66                OpExecutionMode %4 OriginUpperLeft
67                OpSource ESSL 320
68                OpName %4 "main"
69                OpName %8 "i"
70                OpName %13 "coord"
71                OpName %16 "gl_FragCoord"
72                OpName %22 "texel"
73                OpName %26 "tex"
74                OpName %73 "_GLF_color"
75                OpDecorate %8 RelaxedPrecision
76                OpDecorate %16 BuiltIn FragCoord
77                OpDecorate %26 RelaxedPrecision
78                OpDecorate %26 DescriptorSet 0
79                OpDecorate %26 Binding 0
80                OpDecorate %27 RelaxedPrecision
81                OpDecorate %29 RelaxedPrecision
82                OpDecorate %51 RelaxedPrecision
83                OpDecorate %66 RelaxedPrecision
84                OpDecorate %68 RelaxedPrecision
85                OpDecorate %69 RelaxedPrecision
86                OpDecorate %71 RelaxedPrecision
87                OpDecorate %73 Location 0
88           %2 = OpTypeVoid
89           %3 = OpTypeFunction %2
90           %6 = OpTypeInt 32 1
91           %7 = OpTypePointer Function %6
92           %9 = OpConstant %6 0
93          %10 = OpTypeFloat 32
94          %11 = OpTypeVector %10 2
95          %12 = OpTypePointer Function %11
96          %14 = OpTypeVector %10 4
97          %15 = OpTypePointer Input %14
98          %16 = OpVariable %15 Input
99          %19 = OpConstant %10 0.00390625
100          %21 = OpTypePointer Function %14
101          %23 = OpTypeImage %10 2D 0 0 0 1 Unknown
102          %24 = OpTypeSampledImage %23
103          %25 = OpTypePointer UniformConstant %24
104          %26 = OpVariable %25 UniformConstant
105          %35 = OpTypeInt 32 0
106          %36 = OpConstant %35 0
107          %37 = OpTypePointer Function %10
108          %40 = OpConstant %35 1
109          %44 = OpConstant %35 2
110          %48 = OpConstant %10 1
111          %49 = OpTypeBool
112          %52 = OpConstant %6 16
113          %61 = OpConstant %10 256
114          %70 = OpConstant %6 1
115          %72 = OpTypePointer Output %14
116          %73 = OpVariable %72 Output
117           %4 = OpFunction %2 None %3
118           %5 = OpLabel
119           %8 = OpVariable %7 Function
120          %13 = OpVariable %12 Function
121          %22 = OpVariable %21 Function
122                OpStore %8 %9
123          %17 = OpLoad %14 %16
124          %18 = OpVectorShuffle %11 %17 %17 0 1
125          %20 = OpVectorTimesScalar %11 %18 %19
126                OpStore %13 %20
127          %27 = OpLoad %24 %26
128          %28 = OpLoad %11 %13
129          %29 = OpImageSampleImplicitLod %14 %27 %28
130                OpStore %22 %29
131                OpBranch %30
132          %30 = OpLabel
133                OpLoopMerge %32 %33 None
134                OpBranch %34
135          %34 = OpLabel
136          %38 = OpAccessChain %37 %22 %36
137          %39 = OpLoad %10 %38
138          %41 = OpAccessChain %37 %22 %40
139          %42 = OpLoad %10 %41
140          %43 = OpFAdd %10 %39 %42
141          %45 = OpAccessChain %37 %22 %44
142          %46 = OpLoad %10 %45
143          %47 = OpFAdd %10 %43 %46
144          %50 = OpFOrdGreaterThan %49 %47 %48
145          %51 = OpLoad %6 %8
146          %53 = OpSLessThan %49 %51 %52
147          %54 = OpLogicalAnd %49 %50 %53
148                OpBranchConditional %54 %31 %32
149          %31 = OpLabel
150          %55 = OpLoad %14 %22
151          %56 = OpVectorShuffle %11 %55 %55 0 2
152          %57 = OpLoad %14 %22
153          %58 = OpVectorShuffle %11 %57 %57 1 1
154          %59 = OpFAdd %11 %56 %58
155                OpStore %13 %59
156          %60 = OpLoad %11 %13
157          %62 = OpVectorTimesScalar %11 %60 %61
158          %63 = OpExtInst %11 %1 Floor %62
159          %64 = OpCompositeConstruct %11 %61 %61
160          %65 = OpFDiv %11 %63 %64
161                OpStore %13 %65
162          %66 = OpLoad %24 %26
163          %67 = OpLoad %11 %13
164          %68 = OpImageSampleImplicitLod %14 %66 %67
165                OpStore %22 %68
166          %69 = OpLoad %6 %8
167          %71 = OpIAdd %6 %69 %70
168                OpStore %8 %71
169                OpBranch %33
170          %33 = OpLabel
171                OpBranch %30
172          %32 = OpLabel
173          %74 = OpLoad %14 %22
174                OpStore %73 %74
175                OpReturn
176                OpFunctionEnd
177 END
178
179 # uniforms for reference
180
181 # tex
182 SAMPLER reference_tex
183
184
185 BUFFER reference_framebuffer FORMAT B8G8R8A8_UNORM
186
187 PIPELINE graphics reference_pipeline
188   ATTACH reference_vertex_shader
189   ATTACH reference_fragment_shader
190   FRAMEBUFFER_SIZE 256 256
191   BIND BUFFER reference_framebuffer AS color LOCATION 0
192   BIND BUFFER default_texture AS combined_image_sampler SAMPLER reference_tex DESCRIPTOR_SET 0 BINDING 0
193 END
194 CLEAR_COLOR reference_pipeline 0 0 0 255
195
196 CLEAR reference_pipeline
197 RUN reference_pipeline DRAW_RECT POS 0 0 SIZE 256 256
198
199
200 SHADER vertex variant_vertex_shader PASSTHROUGH
201
202 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
203 ; SPIR-V
204 ; Version: 1.0
205 ; Generator: Khronos Glslang Reference Front End; 10
206 ; Bound: 377
207 ; Schema: 0
208                OpCapability Shader
209           %1 = OpExtInstImport "GLSL.std.450"
210                OpMemoryModel Logical GLSL450
211                OpEntryPoint Fragment %4 "main" %16 %73
212                OpExecutionMode %4 OriginUpperLeft
213                OpSource ESSL 320
214                OpName %4 "main"
215                OpName %8 "i"
216                OpName %13 "coord"
217                OpName %16 "gl_FragCoord"
218                OpName %22 "texel"
219                OpName %26 "tex"
220                OpName %73 "_GLF_color"
221                OpDecorate %8 RelaxedPrecision
222                OpDecorate %16 BuiltIn FragCoord
223                OpDecorate %26 RelaxedPrecision
224                OpDecorate %26 DescriptorSet 0
225                OpDecorate %26 Binding 0
226                OpDecorate %27 RelaxedPrecision
227                OpDecorate %29 RelaxedPrecision
228                OpDecorate %51 RelaxedPrecision
229                OpDecorate %66 RelaxedPrecision
230                OpDecorate %68 RelaxedPrecision
231                OpDecorate %69 RelaxedPrecision
232                OpDecorate %71 RelaxedPrecision
233                OpDecorate %73 Location 0
234           %2 = OpTypeVoid
235           %3 = OpTypeFunction %2
236           %6 = OpTypeInt 32 1
237           %7 = OpTypePointer Function %6
238           %9 = OpConstant %6 0
239          %10 = OpTypeFloat 32
240          %11 = OpTypeVector %10 2
241          %12 = OpTypePointer Function %11
242          %14 = OpTypeVector %10 4
243          %15 = OpTypePointer Input %14
244          %16 = OpVariable %15 Input
245          %19 = OpConstant %10 0.00390625
246          %21 = OpTypePointer Function %14
247          %23 = OpTypeImage %10 2D 0 0 0 1 Unknown
248          %24 = OpTypeSampledImage %23
249          %25 = OpTypePointer UniformConstant %24
250          %26 = OpVariable %25 UniformConstant
251          %35 = OpTypeInt 32 0
252          %36 = OpConstant %35 0
253          %37 = OpTypePointer Function %10
254          %40 = OpConstant %35 1
255          %44 = OpConstant %35 2
256          %48 = OpConstant %10 1
257          %49 = OpTypeBool
258          %52 = OpConstant %6 16
259          %61 = OpConstant %10 256
260          %70 = OpConstant %6 1
261          %72 = OpTypePointer Output %14
262          %73 = OpVariable %72 Output
263         %178 = OpTypeVector %6 3
264         %179 = OpTypeVector %6 4
265         %180 = OpTypeVector %35 2
266         %181 = OpTypeVector %35 3
267         %182 = OpTypeVector %10 3
268         %183 = OpTypeMatrix %182 2
269         %187 = OpTypeMatrix %14 4
270         %222 = OpConstantComposite %180 %36 %36
271         %225 = OpConstant %10 0
272         %226 = OpConstantComposite %11 %225 %225
273         %231 = OpConstantComposite %14 %225 %225 %225 %225
274         %265 = OpTypeStruct %180 %180
275         %267 = OpTypeStruct %35 %35
276         %279 = OpTypePointer Function %265
277         %280 = OpConstantComposite %265 %222 %222
278         %294 = OpConstant %35 3
279         %323 = OpTypePointer Function %35
280           %4 = OpFunction %2 None %3
281           %5 = OpLabel
282         %293 = OpVariable %12 Function %226
283         %288 = OpVariable %21 Function %231
284         %281 = OpVariable %279 Function %280
285           %8 = OpVariable %7 Function
286          %13 = OpVariable %12 Function
287          %22 = OpVariable %21 Function
288         %188 = OpCompositeConstruct %180 %44 %40
289                OpStore %8 %9
290         %266 = OpIAddCarry %265 %188 %222
291         %299 = OpULessThanEqual %49 %9 %70
292         %344 = OpULessThanEqual %49 %294 %294
293         %345 = OpSelect %35 %344 %294 %294
294                OpStore %281 %266
295         %346 = OpAccessChain %37 %288 %345
296         %300 = OpSelect %6 %299 %9 %70
297         %301 = OpAccessChain %37 %293 %300
298          %17 = OpLoad %14 %16
299         %360 = OpULessThanEqual %49 %36 %294
300         %361 = OpSelect %35 %360 %36 %294
301         %362 = OpAccessChain %37 %22 %361
302         %223 = OpCompositeExtract %180 %266 0
303         %189 = OpCompositeConstruct %14 %19 %19 %61 %61
304          %18 = OpVectorShuffle %11 %17 %17 0 1
305          %20 = OpVectorTimesScalar %11 %18 %19
306         %227 = OpFSub %11 %20 %226
307         %190 = OpCompositeConstruct %182 %61 %48 %48
308         %228 = OpFSub %10 %48 %225
309                OpStore %13 %20
310         %191 = OpCompositeConstruct %180 %36 %40
311          %27 = OpLoad %24 %26
312          %28 = OpLoad %11 %13
313          %29 = OpImageSampleImplicitLod %14 %27 %28
314                OpStore %22 %29
315                OpBranch %30
316          %30 = OpLabel
317                OpLoopMerge %32 %33 None
318                OpBranch %34
319          %34 = OpLabel
320          %38 = OpAccessChain %37 %22 %36
321          %39 = OpLoad %10 %38
322          %41 = OpAccessChain %37 %22 %40
323          %42 = OpLoad %10 %41
324         %232 = OpFSub %14 %189 %231
325          %43 = OpFAdd %10 %39 %42
326          %45 = OpAccessChain %37 %22 %44
327          %46 = OpLoad %10 %45
328          %47 = OpFAdd %10 %43 %46
329         %234 = OpCopyObject %10 %61
330          %50 = OpFOrdGreaterThan %49 %47 %48
331         %235 = OpISub %35 %40 %36
332          %51 = OpLoad %6 %8
333          %53 = OpSLessThan %49 %51 %52
334          %54 = OpLogicalAnd %49 %50 %53
335                OpBranchConditional %54 %31 %32
336          %31 = OpLabel
337          %55 = OpLoad %14 %22
338          %56 = OpVectorShuffle %11 %55 %55 0 2
339          %57 = OpLoad %14 %22
340          %58 = OpVectorShuffle %11 %57 %57 1 1
341          %59 = OpFAdd %11 %56 %58
342                OpStore %13 %59
343          %60 = OpLoad %11 %13
344         %268 = OpUMulExtended %267 %36 %40
345         %321 = OpULessThanEqual %49 %9 %70
346         %322 = OpSelect %6 %321 %9 %70
347         %324 = OpAccessChain %323 %281 %40 %322
348         %243 = OpCompositeExtract %35 %268 0
349          %62 = OpVectorTimesScalar %11 %60 %61
350          %63 = OpExtInst %11 %1 Floor %62
351          %64 = OpCompositeConstruct %11 %61 %61
352          %65 = OpFDiv %11 %63 %64
353         %205 = OpCompositeConstruct %181 %188 %40
354                OpStore %13 %65
355          %66 = OpLoad %24 %26
356          %67 = OpLoad %11 %13
357          %68 = OpImageSampleImplicitLod %14 %66 %67
358                OpStore %22 %68
359          %69 = OpLoad %6 %8
360          %71 = OpIAdd %6 %69 %70
361         %376 = OpAccessChain %323 %324
362         %207 = OpCompositeConstruct %183 %190 %190
363                OpStore %376 %361
364         %244 = OpFMul %10 %234 %48
365                OpStore %8 %71
366                OpBranch %33
367          %33 = OpLabel
368         %208 = OpCompositeConstruct %14 %39 %42 %58
369                OpBranch %30
370          %32 = OpLabel
371         %209 = OpCompositeConstruct %183 %190 %190
372          %74 = OpLoad %14 %22
373                OpStore %73 %74
374                OpReturn
375                OpFunctionEnd
376 END
377
378 # uniforms for variant
379
380 # tex
381 SAMPLER variant_tex
382
383
384 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
385
386 PIPELINE graphics variant_pipeline
387   ATTACH variant_vertex_shader
388   ATTACH variant_fragment_shader
389   FRAMEBUFFER_SIZE 256 256
390   BIND BUFFER variant_framebuffer AS color LOCATION 0
391   BIND BUFFER default_texture AS combined_image_sampler SAMPLER variant_tex DESCRIPTOR_SET 0 BINDING 0
392 END
393 CLEAR_COLOR variant_pipeline 0 0 0 255
394
395 CLEAR variant_pipeline
396 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
397
398 EXPECT reference_framebuffer EQ_HISTOGRAM_EMD_BUFFER variant_framebuffer TOLERANCE 0.005