Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / cov-function-loop-copy-array-elements-based-on-arguments.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_0 _GLF_uniform_int_values[0]
30 # #define _int_7 _GLF_uniform_int_values[1]
31 # #define _int_9 _GLF_uniform_int_values[2]
32 # #define _int_1 _GLF_uniform_int_values[3]
33 # #define _int_10 _GLF_uniform_int_values[4]
34 #
35 # precision highp float;
36 # precision highp int;
37 #
38 # // Contents of _GLF_uniform_int_values: [0, 7, 9, 1, 10]
39 # layout(set = 0, binding = 0) uniform buf0
40 # {
41 #     int _GLF_uniform_int_values[5];
42 # };
43 #
44 # layout(location = 0) out vec4 _GLF_color;
45 #
46 # int arr0[10] = int[10](0, 0, 0, 0, 0, 0, 0, 0, 0, 0), arr1[10] = int[10](1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
47 #
48 # void func(int x, int y)
49 # {
50 #     int a = _int_1;
51 #     int b = _int_1;
52 #
53 #     // Sets arr1[1..5] to zero.
54 #     while(x <= y)
55 #     {
56 #         if(b >= 6)
57 #         {
58 #             break;
59 #         }
60 #
61 #         b++;
62 #
63 #         arr1[a++] = arr0[_int_1];
64 #     }
65 #
66 #     // Same as arr0[x] = arr1[x].
67 #     for(int i = x; i <= x; i ++)
68 #     {
69 #         arr0[i] = arr1[i];
70 #     }
71 # }
72 #
73 # void main()
74 # {
75 #     // Iterates only i = 1.
76 #     for(int i = 1; i <= 1; i = 2 * i)
77 #     {
78 #         // Iterates j = 0, 2, 4, 6, and 8.
79 #         for(int j = 0; j < 10; j += 2 * i)
80 #         {
81 #             func(j, j + i);
82 #         }
83 #     }
84 #
85 #     _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
86 #
87 #     // Check the results and output black if unexpected values are seen.
88 #     int ref[10] = int[10](_int_1, _int_0, _int_0, _int_0, _int_0, _int_0, _int_7, _int_0, _int_9, _int_0);
89 #     for(int i = _int_0; i < _int_10; i++)
90 #     {
91 #         if(arr0[i] != ref[i])
92 #         {
93 #             _GLF_color = vec4(_int_0);
94 #         }
95 #     }
96 # }
97 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
98 ; SPIR-V
99 ; Version: 1.0
100 ; Generator: Khronos Glslang Reference Front End; 10
101 ; Bound: 181
102 ; Schema: 0
103                OpCapability Shader
104           %1 = OpExtInstImport "GLSL.std.450"
105                OpMemoryModel Logical GLSL450
106                OpEntryPoint Fragment %4 "main" %117
107                OpExecutionMode %4 OriginUpperLeft
108                OpSource ESSL 320
109                OpName %4 "main"
110                OpName %11 "func(i1;i1;"
111                OpName %9 "x"
112                OpName %10 "y"
113                OpName %17 "arr0"
114                OpName %20 "arr1"
115                OpName %32 "a"
116                OpName %35 "buf0"
117                OpMemberName %35 0 "_GLF_uniform_int_values"
118                OpName %37 ""
119                OpName %41 "b"
120                OpName %68 "i"
121                OpName %85 "i"
122                OpName %93 "j"
123                OpName %104 "param"
124                OpName %106 "param"
125                OpName %117 "_GLF_color"
126                OpName %132 "ref"
127                OpName %154 "i"
128                OpDecorate %34 ArrayStride 16
129                OpMemberDecorate %35 0 Offset 0
130                OpDecorate %35 Block
131                OpDecorate %37 DescriptorSet 0
132                OpDecorate %37 Binding 0
133                OpDecorate %117 Location 0
134           %2 = OpTypeVoid
135           %3 = OpTypeFunction %2
136           %6 = OpTypeInt 32 1
137           %7 = OpTypePointer Function %6
138           %8 = OpTypeFunction %2 %7 %7
139          %13 = OpTypeInt 32 0
140          %14 = OpConstant %13 10
141          %15 = OpTypeArray %6 %14
142          %16 = OpTypePointer Private %15
143          %17 = OpVariable %16 Private
144          %18 = OpConstant %6 0
145          %19 = OpConstantComposite %15 %18 %18 %18 %18 %18 %18 %18 %18 %18 %18
146          %20 = OpVariable %16 Private
147          %21 = OpConstant %6 1
148          %22 = OpConstant %6 2
149          %23 = OpConstant %6 3
150          %24 = OpConstant %6 4
151          %25 = OpConstant %6 5
152          %26 = OpConstant %6 6
153          %27 = OpConstant %6 7
154          %28 = OpConstant %6 8
155          %29 = OpConstant %6 9
156          %30 = OpConstant %6 10
157          %31 = OpConstantComposite %15 %21 %22 %23 %24 %25 %26 %27 %28 %29 %30
158          %33 = OpConstant %13 5
159          %34 = OpTypeArray %6 %33
160          %35 = OpTypeStruct %34
161          %36 = OpTypePointer Uniform %35
162          %37 = OpVariable %36 Uniform
163          %38 = OpTypePointer Uniform %6
164          %51 = OpTypeBool
165          %64 = OpTypePointer Private %6
166         %114 = OpTypeFloat 32
167         %115 = OpTypeVector %114 4
168         %116 = OpTypePointer Output %115
169         %117 = OpVariable %116 Output
170         %131 = OpTypePointer Function %15
171           %4 = OpFunction %2 None %3
172           %5 = OpLabel
173          %85 = OpVariable %7 Function
174          %93 = OpVariable %7 Function
175         %104 = OpVariable %7 Function
176         %106 = OpVariable %7 Function
177         %132 = OpVariable %131 Function
178         %154 = OpVariable %7 Function
179                OpStore %17 %19
180                OpStore %20 %31
181                OpStore %85 %21
182                OpBranch %86
183          %86 = OpLabel
184                OpLoopMerge %88 %89 None
185                OpBranch %90
186          %90 = OpLabel
187          %91 = OpLoad %6 %85
188          %92 = OpSLessThanEqual %51 %91 %21
189                OpBranchConditional %92 %87 %88
190          %87 = OpLabel
191                OpStore %93 %18
192                OpBranch %94
193          %94 = OpLabel
194                OpLoopMerge %96 %97 None
195                OpBranch %98
196          %98 = OpLabel
197          %99 = OpLoad %6 %93
198         %100 = OpSLessThan %51 %99 %30
199                OpBranchConditional %100 %95 %96
200          %95 = OpLabel
201         %101 = OpLoad %6 %93
202         %102 = OpLoad %6 %85
203         %103 = OpIAdd %6 %101 %102
204         %105 = OpLoad %6 %93
205                OpStore %104 %105
206                OpStore %106 %103
207         %107 = OpFunctionCall %2 %11 %104 %106
208                OpBranch %97
209          %97 = OpLabel
210         %108 = OpLoad %6 %85
211         %109 = OpIMul %6 %22 %108
212         %110 = OpLoad %6 %93
213         %111 = OpIAdd %6 %110 %109
214                OpStore %93 %111
215                OpBranch %94
216          %96 = OpLabel
217                OpBranch %89
218          %89 = OpLabel
219         %112 = OpLoad %6 %85
220         %113 = OpIMul %6 %22 %112
221                OpStore %85 %113
222                OpBranch %86
223          %88 = OpLabel
224         %118 = OpAccessChain %38 %37 %18 %23
225         %119 = OpLoad %6 %118
226         %120 = OpConvertSToF %114 %119
227         %121 = OpAccessChain %38 %37 %18 %18
228         %122 = OpLoad %6 %121
229         %123 = OpConvertSToF %114 %122
230         %124 = OpAccessChain %38 %37 %18 %18
231         %125 = OpLoad %6 %124
232         %126 = OpConvertSToF %114 %125
233         %127 = OpAccessChain %38 %37 %18 %23
234         %128 = OpLoad %6 %127
235         %129 = OpConvertSToF %114 %128
236         %130 = OpCompositeConstruct %115 %120 %123 %126 %129
237                OpStore %117 %130
238         %133 = OpAccessChain %38 %37 %18 %23
239         %134 = OpLoad %6 %133
240         %135 = OpAccessChain %38 %37 %18 %18
241         %136 = OpLoad %6 %135
242         %137 = OpAccessChain %38 %37 %18 %18
243         %138 = OpLoad %6 %137
244         %139 = OpAccessChain %38 %37 %18 %18
245         %140 = OpLoad %6 %139
246         %141 = OpAccessChain %38 %37 %18 %18
247         %142 = OpLoad %6 %141
248         %143 = OpAccessChain %38 %37 %18 %18
249         %144 = OpLoad %6 %143
250         %145 = OpAccessChain %38 %37 %18 %21
251         %146 = OpLoad %6 %145
252         %147 = OpAccessChain %38 %37 %18 %18
253         %148 = OpLoad %6 %147
254         %149 = OpAccessChain %38 %37 %18 %22
255         %150 = OpLoad %6 %149
256         %151 = OpAccessChain %38 %37 %18 %18
257         %152 = OpLoad %6 %151
258         %153 = OpCompositeConstruct %15 %134 %136 %138 %140 %142 %144 %146 %148 %150 %152
259                OpStore %132 %153
260         %155 = OpAccessChain %38 %37 %18 %18
261         %156 = OpLoad %6 %155
262                OpStore %154 %156
263                OpBranch %157
264         %157 = OpLabel
265                OpLoopMerge %159 %160 None
266                OpBranch %161
267         %161 = OpLabel
268         %162 = OpLoad %6 %154
269         %163 = OpAccessChain %38 %37 %18 %24
270         %164 = OpLoad %6 %163
271         %165 = OpSLessThan %51 %162 %164
272                OpBranchConditional %165 %158 %159
273         %158 = OpLabel
274         %166 = OpLoad %6 %154
275         %167 = OpAccessChain %64 %17 %166
276         %168 = OpLoad %6 %167
277         %169 = OpLoad %6 %154
278         %170 = OpAccessChain %7 %132 %169
279         %171 = OpLoad %6 %170
280         %172 = OpINotEqual %51 %168 %171
281                OpSelectionMerge %174 None
282                OpBranchConditional %172 %173 %174
283         %173 = OpLabel
284         %175 = OpAccessChain %38 %37 %18 %18
285         %176 = OpLoad %6 %175
286         %177 = OpConvertSToF %114 %176
287         %178 = OpCompositeConstruct %115 %177 %177 %177 %177
288                OpStore %117 %178
289                OpBranch %174
290         %174 = OpLabel
291                OpBranch %160
292         %160 = OpLabel
293         %179 = OpLoad %6 %154
294         %180 = OpIAdd %6 %179 %21
295                OpStore %154 %180
296                OpBranch %157
297         %159 = OpLabel
298                OpReturn
299                OpFunctionEnd
300          %11 = OpFunction %2 None %8
301           %9 = OpFunctionParameter %7
302          %10 = OpFunctionParameter %7
303          %12 = OpLabel
304          %32 = OpVariable %7 Function
305          %41 = OpVariable %7 Function
306          %68 = OpVariable %7 Function
307          %39 = OpAccessChain %38 %37 %18 %23
308          %40 = OpLoad %6 %39
309                OpStore %32 %40
310          %42 = OpAccessChain %38 %37 %18 %23
311          %43 = OpLoad %6 %42
312                OpStore %41 %43
313                OpBranch %44
314          %44 = OpLabel
315                OpLoopMerge %46 %47 None
316                OpBranch %48
317          %48 = OpLabel
318          %49 = OpLoad %6 %9
319          %50 = OpLoad %6 %10
320          %52 = OpSLessThanEqual %51 %49 %50
321                OpBranchConditional %52 %45 %46
322          %45 = OpLabel
323          %53 = OpLoad %6 %41
324          %54 = OpSGreaterThanEqual %51 %53 %26
325                OpSelectionMerge %56 None
326                OpBranchConditional %54 %55 %56
327          %55 = OpLabel
328                OpBranch %46
329          %56 = OpLabel
330          %58 = OpLoad %6 %41
331          %59 = OpIAdd %6 %58 %21
332                OpStore %41 %59
333          %60 = OpLoad %6 %32
334          %61 = OpIAdd %6 %60 %21
335                OpStore %32 %61
336          %62 = OpAccessChain %38 %37 %18 %23
337          %63 = OpLoad %6 %62
338          %65 = OpAccessChain %64 %17 %63
339          %66 = OpLoad %6 %65
340          %67 = OpAccessChain %64 %20 %60
341                OpStore %67 %66
342                OpBranch %47
343          %47 = OpLabel
344                OpBranch %44
345          %46 = OpLabel
346          %69 = OpLoad %6 %9
347                OpStore %68 %69
348                OpBranch %70
349          %70 = OpLabel
350                OpLoopMerge %72 %73 None
351                OpBranch %74
352          %74 = OpLabel
353          %75 = OpLoad %6 %68
354          %76 = OpLoad %6 %9
355          %77 = OpSLessThanEqual %51 %75 %76
356                OpBranchConditional %77 %71 %72
357          %71 = OpLabel
358          %78 = OpLoad %6 %68
359          %79 = OpLoad %6 %68
360          %80 = OpAccessChain %64 %20 %79
361          %81 = OpLoad %6 %80
362          %82 = OpAccessChain %64 %17 %78
363                OpStore %82 %81
364                OpBranch %73
365          %73 = OpLabel
366          %83 = OpLoad %6 %68
367          %84 = OpIAdd %6 %83 %21
368                OpStore %68 %84
369                OpBranch %70
370          %72 = OpLabel
371                OpReturn
372                OpFunctionEnd
373 END
374
375 # uniforms for variant
376
377 # _GLF_uniform_int_values
378 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
379  0 7 9 1 10
380 END
381
382 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
383
384 PIPELINE graphics variant_pipeline
385   ATTACH variant_vertex_shader
386   ATTACH variant_fragment_shader
387   FRAMEBUFFER_SIZE 16 16
388   BIND BUFFER variant_framebuffer AS color LOCATION 0
389   BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
390 END
391 CLEAR_COLOR variant_pipeline 0 0 0 255
392
393 CLEAR variant_pipeline
394 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 16 16
395
396 EXPECT variant_framebuffer IDX 0 0 SIZE 16 16 EQ_RGBA 255 0 0 255