Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / cov-loop-global-counter-increment-iterator-select-uniform.amber
1 #!amber
2
3 # Copyright 2022 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_0 _GLF_uniform_int_values[0]
30 # #define _int_1 _GLF_uniform_int_values[1]
31 # #define _int_20 _GLF_uniform_int_values[2]
32 # #define _int_4 _GLF_uniform_int_values[3]
33 #
34 # precision highp float;
35 # precision highp int;
36 #
37 # // Contents of _GLF_uniform_int_values: [0, 1, 20, 4]
38 # layout(set = 0, binding = 0) uniform buf0
39 # {
40 #     int _GLF_uniform_int_values[4];
41 # };
42 #
43 # const int _GLF_global_loop_bound = 10;
44 # int _GLF_global_loop_count = 0;
45 #
46 # // Contents of zero: 0
47 # layout(set = 0, binding = 1) uniform buf1
48 # {
49 #     int zero;
50 # };
51 #
52 # // Contents of two: 2
53 # layout(set = 0, binding = 2) uniform buf2
54 # {
55 #     int two;
56 # };
57 #
58 # layout(location = 0) out vec4 _GLF_color;
59 #
60 # void main()
61 # {
62 #     int arr[10] = int[10](_int_0, _int_0, _int_0, _int_0, _int_0, _int_0, _int_0, _int_0, _int_0, _int_0);
63 #
64 #     // Iterates ten times because of the global loop bound.
65 #     for(int i = 0; i < _int_20 && _GLF_global_loop_count < _GLF_global_loop_bound; (zero < _int_1) ? i++ : _int_1)
66 #     {
67 #         _GLF_global_loop_count++;
68 #
69 #         // Always false.
70 #         if(two <= _int_1)
71 #         {
72 #             break;
73 #         }
74 #
75 #         // True when i == 0.
76 #         if((i / 4) == i)
77 #         {
78 #             arr[i / _int_4] = _int_1;
79 #         }
80 #     }
81 #
82 #     arr[_int_1]++;
83 #
84 #     // Always true.
85 #     if(arr[_int_0] == _int_1)
86 #     {
87 #         _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
88 #     }
89 #     else
90 #     {
91 #         _GLF_color = vec4(_int_0);
92 #     }
93 # }
94 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
95 ; SPIR-V
96 ; Version: 1.0
97 ; Generator: Khronos Glslang Reference Front End; 10
98 ; Bound: 140
99 ; Schema: 0
100                OpCapability Shader
101           %1 = OpExtInstImport "GLSL.std.450"
102                OpMemoryModel Logical GLSL450
103                OpEntryPoint Fragment %4 "main" %121
104                OpExecutionMode %4 OriginUpperLeft
105                OpSource ESSL 320
106                OpName %4 "main"
107                OpName %8 "_GLF_global_loop_count"
108                OpName %14 "arr"
109                OpName %17 "buf0"
110                OpMemberName %17 0 "_GLF_uniform_int_values"
111                OpName %19 ""
112                OpName %43 "i"
113                OpName %62 "buf2"
114                OpMemberName %62 0 "two"
115                OpName %64 ""
116                OpName %88 "buf1"
117                OpMemberName %88 0 "zero"
118                OpName %90 ""
119                OpName %121 "_GLF_color"
120                OpDecorate %16 ArrayStride 16
121                OpMemberDecorate %17 0 Offset 0
122                OpDecorate %17 Block
123                OpDecorate %19 DescriptorSet 0
124                OpDecorate %19 Binding 0
125                OpMemberDecorate %62 0 Offset 0
126                OpDecorate %62 Block
127                OpDecorate %64 DescriptorSet 0
128                OpDecorate %64 Binding 2
129                OpMemberDecorate %88 0 Offset 0
130                OpDecorate %88 Block
131                OpDecorate %90 DescriptorSet 0
132                OpDecorate %90 Binding 1
133                OpDecorate %121 Location 0
134           %2 = OpTypeVoid
135           %3 = OpTypeFunction %2
136           %6 = OpTypeInt 32 1
137           %7 = OpTypePointer Private %6
138           %8 = OpVariable %7 Private
139           %9 = OpConstant %6 0
140          %10 = OpTypeInt 32 0
141          %11 = OpConstant %10 10
142          %12 = OpTypeArray %6 %11
143          %13 = OpTypePointer Function %12
144          %15 = OpConstant %10 4
145          %16 = OpTypeArray %6 %15
146          %17 = OpTypeStruct %16
147          %18 = OpTypePointer Uniform %17
148          %19 = OpVariable %18 Uniform
149          %20 = OpTypePointer Uniform %6
150          %42 = OpTypePointer Function %6
151          %50 = OpConstant %6 2
152          %53 = OpTypeBool
153          %56 = OpConstant %6 10
154          %60 = OpConstant %6 1
155          %62 = OpTypeStruct %6
156          %63 = OpTypePointer Uniform %62
157          %64 = OpVariable %63 Uniform
158          %74 = OpConstant %6 4
159          %81 = OpConstant %6 3
160          %88 = OpTypeStruct %6
161          %89 = OpTypePointer Uniform %88
162          %90 = OpVariable %89 Uniform
163         %118 = OpTypeFloat 32
164         %119 = OpTypeVector %118 4
165         %120 = OpTypePointer Output %119
166         %121 = OpVariable %120 Output
167           %4 = OpFunction %2 None %3
168           %5 = OpLabel
169          %14 = OpVariable %13 Function
170          %43 = OpVariable %42 Function
171          %96 = OpVariable %42 Function
172                OpStore %8 %9
173          %21 = OpAccessChain %20 %19 %9 %9
174          %22 = OpLoad %6 %21
175          %23 = OpAccessChain %20 %19 %9 %9
176          %24 = OpLoad %6 %23
177          %25 = OpAccessChain %20 %19 %9 %9
178          %26 = OpLoad %6 %25
179          %27 = OpAccessChain %20 %19 %9 %9
180          %28 = OpLoad %6 %27
181          %29 = OpAccessChain %20 %19 %9 %9
182          %30 = OpLoad %6 %29
183          %31 = OpAccessChain %20 %19 %9 %9
184          %32 = OpLoad %6 %31
185          %33 = OpAccessChain %20 %19 %9 %9
186          %34 = OpLoad %6 %33
187          %35 = OpAccessChain %20 %19 %9 %9
188          %36 = OpLoad %6 %35
189          %37 = OpAccessChain %20 %19 %9 %9
190          %38 = OpLoad %6 %37
191          %39 = OpAccessChain %20 %19 %9 %9
192          %40 = OpLoad %6 %39
193          %41 = OpCompositeConstruct %12 %22 %24 %26 %28 %30 %32 %34 %36 %38 %40
194                OpStore %14 %41
195                OpStore %43 %9
196                OpBranch %44
197          %44 = OpLabel
198                OpLoopMerge %46 %47 None
199                OpBranch %48
200          %48 = OpLabel
201          %49 = OpLoad %6 %43
202          %51 = OpAccessChain %20 %19 %9 %50
203          %52 = OpLoad %6 %51
204          %54 = OpSLessThan %53 %49 %52
205          %55 = OpLoad %6 %8
206          %57 = OpSLessThan %53 %55 %56
207          %58 = OpLogicalAnd %53 %54 %57
208                OpBranchConditional %58 %45 %46
209          %45 = OpLabel
210          %59 = OpLoad %6 %8
211          %61 = OpIAdd %6 %59 %60
212                OpStore %8 %61
213          %65 = OpAccessChain %20 %64 %9
214          %66 = OpLoad %6 %65
215          %67 = OpAccessChain %20 %19 %9 %60
216          %68 = OpLoad %6 %67
217          %69 = OpSLessThanEqual %53 %66 %68
218                OpSelectionMerge %71 None
219                OpBranchConditional %69 %70 %71
220          %70 = OpLabel
221                OpBranch %46
222          %71 = OpLabel
223          %73 = OpLoad %6 %43
224          %75 = OpSDiv %6 %73 %74
225          %76 = OpLoad %6 %43
226          %77 = OpIEqual %53 %75 %76
227                OpSelectionMerge %79 None
228                OpBranchConditional %77 %78 %79
229          %78 = OpLabel
230          %80 = OpLoad %6 %43
231          %82 = OpAccessChain %20 %19 %9 %81
232          %83 = OpLoad %6 %82
233          %84 = OpSDiv %6 %80 %83
234          %85 = OpAccessChain %20 %19 %9 %60
235          %86 = OpLoad %6 %85
236          %87 = OpAccessChain %42 %14 %84
237                OpStore %87 %86
238                OpBranch %79
239          %79 = OpLabel
240                OpBranch %47
241          %47 = OpLabel
242          %91 = OpAccessChain %20 %90 %9
243          %92 = OpLoad %6 %91
244          %93 = OpAccessChain %20 %19 %9 %60
245          %94 = OpLoad %6 %93
246          %95 = OpSLessThan %53 %92 %94
247                OpSelectionMerge %98 None
248                OpBranchConditional %95 %97 %101
249          %97 = OpLabel
250          %99 = OpLoad %6 %43
251         %100 = OpIAdd %6 %99 %60
252                OpStore %43 %100
253                OpStore %96 %99
254                OpBranch %98
255         %101 = OpLabel
256         %102 = OpAccessChain %20 %19 %9 %60
257         %103 = OpLoad %6 %102
258                OpStore %96 %103
259                OpBranch %98
260          %98 = OpLabel
261                OpBranch %44
262          %46 = OpLabel
263         %104 = OpAccessChain %20 %19 %9 %60
264         %105 = OpLoad %6 %104
265         %106 = OpAccessChain %42 %14 %105
266         %107 = OpLoad %6 %106
267         %108 = OpIAdd %6 %107 %60
268                OpStore %106 %108
269         %109 = OpAccessChain %20 %19 %9 %9
270         %110 = OpLoad %6 %109
271         %111 = OpAccessChain %42 %14 %110
272         %112 = OpLoad %6 %111
273         %113 = OpAccessChain %20 %19 %9 %60
274         %114 = OpLoad %6 %113
275         %115 = OpIEqual %53 %112 %114
276                OpSelectionMerge %117 None
277                OpBranchConditional %115 %116 %135
278         %116 = OpLabel
279         %122 = OpAccessChain %20 %19 %9 %60
280         %123 = OpLoad %6 %122
281         %124 = OpConvertSToF %118 %123
282         %125 = OpAccessChain %20 %19 %9 %9
283         %126 = OpLoad %6 %125
284         %127 = OpConvertSToF %118 %126
285         %128 = OpAccessChain %20 %19 %9 %9
286         %129 = OpLoad %6 %128
287         %130 = OpConvertSToF %118 %129
288         %131 = OpAccessChain %20 %19 %9 %60
289         %132 = OpLoad %6 %131
290         %133 = OpConvertSToF %118 %132
291         %134 = OpCompositeConstruct %119 %124 %127 %130 %133
292                OpStore %121 %134
293                OpBranch %117
294         %135 = OpLabel
295         %136 = OpAccessChain %20 %19 %9 %9
296         %137 = OpLoad %6 %136
297         %138 = OpConvertSToF %118 %137
298         %139 = OpCompositeConstruct %119 %138 %138 %138 %138
299                OpStore %121 %139
300                OpBranch %117
301         %117 = OpLabel
302                OpReturn
303                OpFunctionEnd
304 END
305
306 # uniforms for variant
307
308 # zero
309 BUFFER variant_zero DATA_TYPE int32 STD140 DATA
310  0
311 END
312 # two
313 BUFFER variant_two DATA_TYPE int32 STD140 DATA
314  2
315 END
316 # _GLF_uniform_int_values
317 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
318  0 1 20 4
319 END
320
321 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
322
323 PIPELINE graphics variant_pipeline
324   ATTACH variant_vertex_shader
325   ATTACH variant_fragment_shader
326   FRAMEBUFFER_SIZE 32 32
327   BIND BUFFER variant_framebuffer AS color LOCATION 0
328   BIND BUFFER variant_zero AS uniform DESCRIPTOR_SET 0 BINDING 1
329   BIND BUFFER variant_two AS uniform DESCRIPTOR_SET 0 BINDING 2
330   BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
331 END
332 CLEAR_COLOR variant_pipeline 0 0 0 255
333
334 CLEAR variant_pipeline
335 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
336
337 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255