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