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