Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / cov-nested-loop-continue-inner-copy-array-element.amber
1 #!amber
2
3 # Copyright 2021 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 coverage-gap found by the GraphicsFuzz project.
19
20 # Short description: A fragment shader that covers specific LLVM code paths
21
22 # The test passes because the shader always writes red.
23
24 SHADER vertex variant_vertex_shader PASSTHROUGH
25
26 # variant_fragment_shader is derived from the following GLSL:
27 # #version 320 es
28 #
29 # #define _int_1 _GLF_uniform_int_values[0]
30 # #define _int_0 _GLF_uniform_int_values[1]
31 # #define _int_10 _GLF_uniform_int_values[2]
32 # #define _float_1_0 _GLF_uniform_float_values[0]
33 # #define _float_2_0 _GLF_uniform_float_values[1]
34 # #define _float_3_0 _GLF_uniform_float_values[2]
35 # #define _float_4_0 _GLF_uniform_float_values[3]
36 # #define _float_5_0 _GLF_uniform_float_values[4]
37 # #define _float_6_0 _GLF_uniform_float_values[5]
38 # #define _float_7_0 _GLF_uniform_float_values[6]
39 # #define _float_8_0 _GLF_uniform_float_values[7]
40 # #define _float_9_0 _GLF_uniform_float_values[8]
41 # #define _float_10_0 _GLF_uniform_float_values[9]
42 # #define _float_0_0 _GLF_uniform_float_values[10]
43 #
44 # precision highp float;
45 # precision highp int;
46 #
47 # // Contents of _GLF_uniform_float_values: [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 0.0]
48 # layout(set = 0, binding = 0) uniform buf0
49 # {
50 #     float _GLF_uniform_float_values[11];
51 # };
52 # // Contents of _GLF_uniform_int_values: [1, 0, 10]
53 # layout(set = 0, binding = 1) uniform buf1
54 # {
55 #     int _GLF_uniform_int_values[3];
56 # };
57 # // Contents of injectionSwitch: [0.0, 1.0]
58 # layout(set = 0, binding = 2) uniform buf2
59 # {
60 #     vec2 injectionSwitch;
61 # };
62 # layout(location = 0) out vec4 _GLF_color;
63 #
64 # void main()
65 # {
66 #     float data[10] = float[10](_float_1_0, _float_2_0, _float_3_0, _float_4_0, _float_5_0, _float_6_0, _float_7_0, _float_8_0, _float_9_0, _float_10_0);
67 #
68 #     // This loop copies data[1] to indices two and up.
69 #     for(int i = 0; i < 10; i ++)
70 #     {
71 #         for(int j = 0; j < 10; j ++)
72 #         {
73 #             // Skips all other iterations except j >= i. The inner loop has no dependency of j,
74 #             // thus it just does data[i] = data[1] multiple times when i > 1.
75 #             if(j < i)
76 #             {
77 #                 continue;
78 #             }
79 #
80 #             float f0 = data[i];
81 #             float f1 = data[_int_1];
82 #
83 #             // Always selects f0 > f1 which is true when i > 1.
84 #             bool b = injectionSwitch.x > _float_0_0 ? injectionSwitch.x < injectionSwitch.y : f0 > f1;
85 #
86 #             if(b)
87 #             {
88 #                 data[i] = data[_int_1];
89 #             }
90 #         }
91 #     }
92 #
93 #     // Compare against expected results.
94 #     float ref[10] = float[10](_float_1_0, _float_2_0, _float_2_0, _float_2_0, _float_2_0, _float_2_0, _float_2_0, _float_2_0, _float_2_0, _float_2_0);
95 #     _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
96 #
97 #     for(int i = _int_0; i < _int_10; i ++)
98 #     {
99 #         if(data[i] != ref[i])
100 #         {
101 #             _GLF_color = vec4(_int_0);
102 #         }
103 #     }
104 # }
105 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
106 ; SPIR-V
107 ; Version: 1.0
108 ; Generator: Khronos Glslang Reference Front End; 10
109 ; Bound: 195
110 ; Schema: 0
111                OpCapability Shader
112           %1 = OpExtInstImport "GLSL.std.450"
113                OpMemoryModel Logical GLSL450
114                OpEntryPoint Fragment %4 "main" %154
115                OpExecutionMode %4 OriginUpperLeft
116                OpSource ESSL 320
117                OpName %4 "main"
118                OpName %11 "data"
119                OpName %14 "buf0"
120                OpMemberName %14 0 "_GLF_uniform_float_values"
121                OpName %16 ""
122                OpName %51 "i"
123                OpName %61 "j"
124                OpName %76 "f0"
125                OpName %80 "f1"
126                OpName %83 "buf1"
127                OpMemberName %83 0 "_GLF_uniform_int_values"
128                OpName %85 ""
129                OpName %92 "b"
130                OpName %94 "buf2"
131                OpMemberName %94 0 "injectionSwitch"
132                OpName %96 ""
133                OpName %130 "ref"
134                OpName %154 "_GLF_color"
135                OpName %168 "i"
136                OpDecorate %13 ArrayStride 16
137                OpMemberDecorate %14 0 Offset 0
138                OpDecorate %14 Block
139                OpDecorate %16 DescriptorSet 0
140                OpDecorate %16 Binding 0
141                OpDecorate %82 ArrayStride 16
142                OpMemberDecorate %83 0 Offset 0
143                OpDecorate %83 Block
144                OpDecorate %85 DescriptorSet 0
145                OpDecorate %85 Binding 1
146                OpMemberDecorate %94 0 Offset 0
147                OpDecorate %94 Block
148                OpDecorate %96 DescriptorSet 0
149                OpDecorate %96 Binding 2
150                OpDecorate %154 Location 0
151           %2 = OpTypeVoid
152           %3 = OpTypeFunction %2
153           %6 = OpTypeFloat 32
154           %7 = OpTypeInt 32 0
155           %8 = OpConstant %7 10
156           %9 = OpTypeArray %6 %8
157          %10 = OpTypePointer Function %9
158          %12 = OpConstant %7 11
159          %13 = OpTypeArray %6 %12
160          %14 = OpTypeStruct %13
161          %15 = OpTypePointer Uniform %14
162          %16 = OpVariable %15 Uniform
163          %17 = OpTypeInt 32 1
164          %18 = OpConstant %17 0
165          %19 = OpTypePointer Uniform %6
166          %22 = OpConstant %17 1
167          %25 = OpConstant %17 2
168          %28 = OpConstant %17 3
169          %31 = OpConstant %17 4
170          %34 = OpConstant %17 5
171          %37 = OpConstant %17 6
172          %40 = OpConstant %17 7
173          %43 = OpConstant %17 8
174          %46 = OpConstant %17 9
175          %50 = OpTypePointer Function %17
176          %58 = OpConstant %17 10
177          %59 = OpTypeBool
178          %75 = OpTypePointer Function %6
179          %81 = OpConstant %7 3
180          %82 = OpTypeArray %17 %81
181          %83 = OpTypeStruct %82
182          %84 = OpTypePointer Uniform %83
183          %85 = OpVariable %84 Uniform
184          %86 = OpTypePointer Uniform %17
185          %91 = OpTypePointer Function %59
186          %93 = OpTypeVector %6 2
187          %94 = OpTypeStruct %93
188          %95 = OpTypePointer Uniform %94
189          %96 = OpVariable %95 Uniform
190          %97 = OpConstant %7 0
191         %108 = OpConstant %7 1
192         %152 = OpTypeVector %6 4
193         %153 = OpTypePointer Output %152
194         %154 = OpVariable %153 Output
195           %4 = OpFunction %2 None %3
196           %5 = OpLabel
197          %11 = OpVariable %10 Function
198          %51 = OpVariable %50 Function
199          %61 = OpVariable %50 Function
200          %76 = OpVariable %75 Function
201          %80 = OpVariable %75 Function
202          %92 = OpVariable %91 Function
203         %103 = OpVariable %91 Function
204         %130 = OpVariable %10 Function
205         %168 = OpVariable %50 Function
206          %20 = OpAccessChain %19 %16 %18 %18
207          %21 = OpLoad %6 %20
208          %23 = OpAccessChain %19 %16 %18 %22
209          %24 = OpLoad %6 %23
210          %26 = OpAccessChain %19 %16 %18 %25
211          %27 = OpLoad %6 %26
212          %29 = OpAccessChain %19 %16 %18 %28
213          %30 = OpLoad %6 %29
214          %32 = OpAccessChain %19 %16 %18 %31
215          %33 = OpLoad %6 %32
216          %35 = OpAccessChain %19 %16 %18 %34
217          %36 = OpLoad %6 %35
218          %38 = OpAccessChain %19 %16 %18 %37
219          %39 = OpLoad %6 %38
220          %41 = OpAccessChain %19 %16 %18 %40
221          %42 = OpLoad %6 %41
222          %44 = OpAccessChain %19 %16 %18 %43
223          %45 = OpLoad %6 %44
224          %47 = OpAccessChain %19 %16 %18 %46
225          %48 = OpLoad %6 %47
226          %49 = OpCompositeConstruct %9 %21 %24 %27 %30 %33 %36 %39 %42 %45 %48
227                OpStore %11 %49
228                OpStore %51 %18
229                OpBranch %52
230          %52 = OpLabel
231                OpLoopMerge %54 %55 None
232                OpBranch %56
233          %56 = OpLabel
234          %57 = OpLoad %17 %51
235          %60 = OpSLessThan %59 %57 %58
236                OpBranchConditional %60 %53 %54
237          %53 = OpLabel
238                OpStore %61 %18
239                OpBranch %62
240          %62 = OpLabel
241                OpLoopMerge %64 %65 None
242                OpBranch %66
243          %66 = OpLabel
244          %67 = OpLoad %17 %61
245          %68 = OpSLessThan %59 %67 %58
246                OpBranchConditional %68 %63 %64
247          %63 = OpLabel
248          %69 = OpLoad %17 %61
249          %70 = OpLoad %17 %51
250          %71 = OpSLessThan %59 %69 %70
251                OpSelectionMerge %73 None
252                OpBranchConditional %71 %72 %73
253          %72 = OpLabel
254                OpBranch %65
255          %73 = OpLabel
256          %77 = OpLoad %17 %51
257          %78 = OpAccessChain %75 %11 %77
258          %79 = OpLoad %6 %78
259                OpStore %76 %79
260          %87 = OpAccessChain %86 %85 %18 %18
261          %88 = OpLoad %17 %87
262          %89 = OpAccessChain %75 %11 %88
263          %90 = OpLoad %6 %89
264                OpStore %80 %90
265          %98 = OpAccessChain %19 %96 %18 %97
266          %99 = OpLoad %6 %98
267         %100 = OpAccessChain %19 %16 %18 %58
268         %101 = OpLoad %6 %100
269         %102 = OpFOrdGreaterThan %59 %99 %101
270                OpSelectionMerge %105 None
271                OpBranchConditional %102 %104 %112
272         %104 = OpLabel
273         %106 = OpAccessChain %19 %96 %18 %97
274         %107 = OpLoad %6 %106
275         %109 = OpAccessChain %19 %96 %18 %108
276         %110 = OpLoad %6 %109
277         %111 = OpFOrdLessThan %59 %107 %110
278                OpStore %103 %111
279                OpBranch %105
280         %112 = OpLabel
281         %113 = OpLoad %6 %76
282         %114 = OpLoad %6 %80
283         %115 = OpFOrdGreaterThan %59 %113 %114
284                OpStore %103 %115
285                OpBranch %105
286         %105 = OpLabel
287         %116 = OpLoad %59 %103
288                OpStore %92 %116
289         %117 = OpLoad %59 %92
290                OpSelectionMerge %119 None
291                OpBranchConditional %117 %118 %119
292         %118 = OpLabel
293         %120 = OpLoad %17 %51
294         %121 = OpAccessChain %86 %85 %18 %18
295         %122 = OpLoad %17 %121
296         %123 = OpAccessChain %75 %11 %122
297         %124 = OpLoad %6 %123
298         %125 = OpAccessChain %75 %11 %120
299                OpStore %125 %124
300                OpBranch %119
301         %119 = OpLabel
302                OpBranch %65
303          %65 = OpLabel
304         %126 = OpLoad %17 %61
305         %127 = OpIAdd %17 %126 %22
306                OpStore %61 %127
307                OpBranch %62
308          %64 = OpLabel
309                OpBranch %55
310          %55 = OpLabel
311         %128 = OpLoad %17 %51
312         %129 = OpIAdd %17 %128 %22
313                OpStore %51 %129
314                OpBranch %52
315          %54 = OpLabel
316         %131 = OpAccessChain %19 %16 %18 %18
317         %132 = OpLoad %6 %131
318         %133 = OpAccessChain %19 %16 %18 %22
319         %134 = OpLoad %6 %133
320         %135 = OpAccessChain %19 %16 %18 %22
321         %136 = OpLoad %6 %135
322         %137 = OpAccessChain %19 %16 %18 %22
323         %138 = OpLoad %6 %137
324         %139 = OpAccessChain %19 %16 %18 %22
325         %140 = OpLoad %6 %139
326         %141 = OpAccessChain %19 %16 %18 %22
327         %142 = OpLoad %6 %141
328         %143 = OpAccessChain %19 %16 %18 %22
329         %144 = OpLoad %6 %143
330         %145 = OpAccessChain %19 %16 %18 %22
331         %146 = OpLoad %6 %145
332         %147 = OpAccessChain %19 %16 %18 %22
333         %148 = OpLoad %6 %147
334         %149 = OpAccessChain %19 %16 %18 %22
335         %150 = OpLoad %6 %149
336         %151 = OpCompositeConstruct %9 %132 %134 %136 %138 %140 %142 %144 %146 %148 %150
337                OpStore %130 %151
338         %155 = OpAccessChain %86 %85 %18 %18
339         %156 = OpLoad %17 %155
340         %157 = OpConvertSToF %6 %156
341         %158 = OpAccessChain %86 %85 %18 %22
342         %159 = OpLoad %17 %158
343         %160 = OpConvertSToF %6 %159
344         %161 = OpAccessChain %86 %85 %18 %22
345         %162 = OpLoad %17 %161
346         %163 = OpConvertSToF %6 %162
347         %164 = OpAccessChain %86 %85 %18 %18
348         %165 = OpLoad %17 %164
349         %166 = OpConvertSToF %6 %165
350         %167 = OpCompositeConstruct %152 %157 %160 %163 %166
351                OpStore %154 %167
352         %169 = OpAccessChain %86 %85 %18 %22
353         %170 = OpLoad %17 %169
354                OpStore %168 %170
355                OpBranch %171
356         %171 = OpLabel
357                OpLoopMerge %173 %174 None
358                OpBranch %175
359         %175 = OpLabel
360         %176 = OpLoad %17 %168
361         %177 = OpAccessChain %86 %85 %18 %25
362         %178 = OpLoad %17 %177
363         %179 = OpSLessThan %59 %176 %178
364                OpBranchConditional %179 %172 %173
365         %172 = OpLabel
366         %180 = OpLoad %17 %168
367         %181 = OpAccessChain %75 %11 %180
368         %182 = OpLoad %6 %181
369         %183 = OpLoad %17 %168
370         %184 = OpAccessChain %75 %130 %183
371         %185 = OpLoad %6 %184
372         %186 = OpFUnordNotEqual %59 %182 %185
373                OpSelectionMerge %188 None
374                OpBranchConditional %186 %187 %188
375         %187 = OpLabel
376         %189 = OpAccessChain %86 %85 %18 %22
377         %190 = OpLoad %17 %189
378         %191 = OpConvertSToF %6 %190
379         %192 = OpCompositeConstruct %152 %191 %191 %191 %191
380                OpStore %154 %192
381                OpBranch %188
382         %188 = OpLabel
383                OpBranch %174
384         %174 = OpLabel
385         %193 = OpLoad %17 %168
386         %194 = OpIAdd %17 %193 %22
387                OpStore %168 %194
388                OpBranch %171
389         %173 = OpLabel
390                OpReturn
391                OpFunctionEnd
392 END
393
394 # uniforms for variant
395
396 # injectionSwitch
397 BUFFER variant_injectionSwitch DATA_TYPE vec2<float> STD140 DATA
398  0.0 1.0
399 END
400 # _GLF_uniform_int_values
401 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
402  1 0 10
403 END
404 # _GLF_uniform_float_values
405 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
406  1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 0.0
407 END
408
409 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
410
411 PIPELINE graphics variant_pipeline
412   ATTACH variant_vertex_shader
413   ATTACH variant_fragment_shader
414   FRAMEBUFFER_SIZE 256 256
415   BIND BUFFER variant_framebuffer AS color LOCATION 0
416   BIND BUFFER variant_injectionSwitch AS uniform DESCRIPTOR_SET 0 BINDING 2
417   BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
418   BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
419 END
420 CLEAR_COLOR variant_pipeline 0 0 0 255
421
422 CLEAR variant_pipeline
423 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
424
425 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255