Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / cov-nested-loops-temporary-copy-output-color-index-matrix.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 # Optimized using spirv-opt with the following arguments:
25 # '--scalar-replacement=100'
26 # '--copy-propagate-arrays'
27 # '--convert-local-access-chains'
28 # '--eliminate-dead-branches'
29 # '--merge-return'
30 # '--eliminate-local-single-store'
31 # '--eliminate-local-single-store'
32 # '--ccp'
33 # '--eliminate-dead-code-aggressive'
34 # '--copy-propagate-arrays'
35 # '--eliminate-dead-branches'
36 # '--inline-entry-points-exhaustive'
37 # '--copy-propagate-arrays'
38 # '--eliminate-dead-branches'
39 # '--redundancy-elimination'
40 # '--ccp'
41 # '--reduce-load-size'
42 # '--eliminate-local-single-block'
43 # '--copy-propagate-arrays'
44 # '--ccp'
45 # spirv-opt commit hash: a0370efd589be33d5d9a85cfde2f85841b3755af
46
47
48
49 SHADER vertex variant_vertex_shader PASSTHROUGH
50
51 # variant_fragment_shader is derived from the following GLSL:
52 # #version 320 es
53 # #define _int_5 _GLF_uniform_int_values[0]
54 # #define _int_1 _GLF_uniform_int_values[1]
55 # #define _int_0 _GLF_uniform_int_values[2]
56 # #define _float_0_0 _GLF_uniform_float_values[0]
57 # #define _float_3_9 _GLF_uniform_float_values[1]
58 # #define _float_4_1 _GLF_uniform_float_values[2]
59 # #define _float_1_0 _GLF_uniform_float_values[3]
60 #
61 # precision highp float;
62 # precision highp int;
63 #
64 # // Contents of _GLF_uniform_float_values: [0.0, 3.9, 4.1, 1.0]
65 # layout(set = 0, binding = 0) uniform buf0
66 # {
67 #     float _GLF_uniform_float_values[4];
68 # };
69 #
70 # // Contents of _GLF_uniform_int_values: [5, 1, 0]
71 # layout(set = 0, binding = 1) uniform buf1
72 # {
73 #     int _GLF_uniform_int_values[3];
74 # };
75 #
76 # layout(location = 0) out vec4 _GLF_color;
77 #
78 # void main()
79 # {
80 #     _GLF_color = vec4(_int_1);
81 #     float f = _float_0_0;
82 #
83 #     // Iterates four times increasing f by one per each iteration.
84 #     for(int i = _int_1; i < _int_5; i++)
85 #     {
86 #         // Iterates once.
87 #         for(int j = _int_0; j < _int_1; j++)
88 #         {
89 #             for(int k = _int_0; k < i; k++)
90 #             {
91 #                 // Increases f by one when k = 0.
92 #                 f += mat2(_float_1_0)[j][clamp(k, _int_0, _int_1)];
93 #
94 #                 // Copy output color to a temporary vector and back.
95 #                 // This will be overwritten later.
96 #                 vec4 tmp;
97 #                 for(int l = _int_0; l < _int_1; l++)
98 #                 {
99 #                     tmp = _GLF_color;
100 #                 }
101 #                 _GLF_color = tmp;
102 #
103 #                 // Always false.
104 #                 if(gl_FragCoord.y < _float_0_0)
105 #                 {
106 #                     return;
107 #                 }
108 #
109 #                 _GLF_color = vec4(_int_0);
110 #             }
111 #         }
112 #     }
113 #
114 #     // Always true.
115 #     if(f > _float_3_9 && f < _float_4_1)
116 #     {
117 #         _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
118 #     }
119 #     else
120 #     {
121 #         _GLF_color = vec4(_int_0);
122 #     }
123 # }
124 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
125 ; SPIR-V
126 ; Version: 1.0
127 ; Generator: Khronos Glslang Reference Front End; 10
128 ; Bound: 179
129 ; Schema: 0
130                OpCapability Shader
131           %1 = OpExtInstImport "GLSL.std.450"
132                OpMemoryModel Logical GLSL450
133                OpEntryPoint Fragment %4 "main" %9 %114
134                OpExecutionMode %4 OriginUpperLeft
135                OpSource ESSL 320
136                OpName %4 "main"
137                OpName %9 "_GLF_color"
138                OpName %14 "buf1"
139                OpMemberName %14 0 "_GLF_uniform_int_values"
140                OpName %16 ""
141                OpName %25 "f"
142                OpName %28 "buf0"
143                OpMemberName %28 0 "_GLF_uniform_float_values"
144                OpName %30 ""
145                OpName %35 "i"
146                OpName %48 "j"
147                OpName %61 "k"
148                OpName %90 "indexable"
149                OpName %95 "l"
150                OpName %108 "tmp"
151                OpName %114 "gl_FragCoord"
152                OpDecorate %9 Location 0
153                OpDecorate %13 ArrayStride 16
154                OpMemberDecorate %14 0 Offset 0
155                OpDecorate %14 Block
156                OpDecorate %16 DescriptorSet 0
157                OpDecorate %16 Binding 1
158                OpDecorate %27 ArrayStride 16
159                OpMemberDecorate %28 0 Offset 0
160                OpDecorate %28 Block
161                OpDecorate %30 DescriptorSet 0
162                OpDecorate %30 Binding 0
163                OpDecorate %114 BuiltIn FragCoord
164           %2 = OpTypeVoid
165           %3 = OpTypeFunction %2
166           %6 = OpTypeFloat 32
167           %7 = OpTypeVector %6 4
168           %8 = OpTypePointer Output %7
169           %9 = OpVariable %8 Output
170          %10 = OpTypeInt 32 1
171          %11 = OpTypeInt 32 0
172          %12 = OpConstant %11 3
173          %13 = OpTypeArray %10 %12
174          %14 = OpTypeStruct %13
175          %15 = OpTypePointer Uniform %14
176          %16 = OpVariable %15 Uniform
177          %17 = OpConstant %10 0
178          %18 = OpConstant %10 1
179          %19 = OpTypePointer Uniform %10
180          %24 = OpTypePointer Function %6
181          %26 = OpConstant %11 4
182          %27 = OpTypeArray %6 %26
183          %28 = OpTypeStruct %27
184          %29 = OpTypePointer Uniform %28
185          %30 = OpVariable %29 Uniform
186          %31 = OpTypePointer Uniform %6
187          %34 = OpTypePointer Function %10
188          %46 = OpTypeBool
189          %49 = OpConstant %10 2
190          %72 = OpConstant %10 3
191          %75 = OpTypeVector %6 2
192          %76 = OpTypeMatrix %75 2
193          %78 = OpConstant %6 0
194          %89 = OpTypePointer Function %76
195         %107 = OpTypePointer Function %7
196         %113 = OpTypePointer Input %7
197         %114 = OpVariable %113 Input
198         %115 = OpConstant %11 1
199         %116 = OpTypePointer Input %6
200         %168 = OpConstant %11 0
201         %169 = OpConstantFalse %46
202         %170 = OpTypePointer Function %46
203         %172 = OpConstantTrue %46
204           %4 = OpFunction %2 None %3
205           %5 = OpLabel
206         %171 = OpVariable %170 Function %169
207          %25 = OpVariable %24 Function
208          %35 = OpVariable %34 Function
209          %48 = OpVariable %34 Function
210          %61 = OpVariable %34 Function
211          %90 = OpVariable %89 Function
212          %95 = OpVariable %34 Function
213         %108 = OpVariable %107 Function
214                OpSelectionMerge %166 None
215                OpSwitch %168 %167
216         %167 = OpLabel
217          %20 = OpAccessChain %19 %16 %17 %18
218          %21 = OpLoad %10 %20
219          %22 = OpConvertSToF %6 %21
220          %23 = OpCompositeConstruct %7 %22 %22 %22 %22
221                OpStore %9 %23
222          %32 = OpAccessChain %31 %30 %17 %17
223          %33 = OpLoad %6 %32
224                OpStore %25 %33
225                OpStore %35 %21
226                OpBranch %38
227          %38 = OpLabel
228                OpLoopMerge %40 %41 None
229                OpBranch %42
230          %42 = OpLabel
231          %43 = OpLoad %10 %35
232          %44 = OpAccessChain %19 %16 %17 %17
233          %45 = OpLoad %10 %44
234          %47 = OpSLessThan %46 %43 %45
235                OpBranchConditional %47 %39 %40
236          %39 = OpLabel
237          %50 = OpAccessChain %19 %16 %17 %49
238          %51 = OpLoad %10 %50
239                OpStore %48 %51
240                OpBranch %52
241          %52 = OpLabel
242                OpLoopMerge %54 %55 None
243                OpBranch %56
244          %56 = OpLabel
245          %57 = OpLoad %10 %48
246          %60 = OpSLessThan %46 %57 %21
247                OpBranchConditional %60 %53 %54
248          %53 = OpLabel
249                OpStore %61 %51
250                OpBranch %64
251          %64 = OpLabel
252                OpLoopMerge %66 %67 None
253                OpBranch %68
254          %68 = OpLabel
255          %69 = OpLoad %10 %61
256          %70 = OpLoad %10 %35
257          %71 = OpSLessThan %46 %69 %70
258                OpBranchConditional %71 %65 %66
259          %65 = OpLabel
260          %73 = OpAccessChain %31 %30 %17 %72
261          %74 = OpLoad %6 %73
262          %79 = OpCompositeConstruct %75 %74 %78
263          %80 = OpCompositeConstruct %75 %78 %74
264          %81 = OpCompositeConstruct %76 %79 %80
265          %82 = OpLoad %10 %48
266          %83 = OpLoad %10 %61
267          %88 = OpExtInst %10 %1 SClamp %83 %51 %21
268                OpStore %90 %81
269          %91 = OpAccessChain %24 %90 %82 %88
270          %92 = OpLoad %6 %91
271          %93 = OpLoad %6 %25
272          %94 = OpFAdd %6 %93 %92
273                OpStore %25 %94
274                OpStore %95 %51
275                OpBranch %98
276          %98 = OpLabel
277                OpLoopMerge %100 %101 None
278                OpBranch %102
279         %102 = OpLabel
280         %103 = OpLoad %10 %95
281         %106 = OpSLessThan %46 %103 %21
282                OpBranchConditional %106 %99 %100
283          %99 = OpLabel
284         %109 = OpLoad %7 %9
285                OpStore %108 %109
286                OpBranch %101
287         %101 = OpLabel
288         %110 = OpLoad %10 %95
289         %111 = OpIAdd %10 %110 %18
290                OpStore %95 %111
291                OpBranch %98
292         %100 = OpLabel
293         %112 = OpLoad %7 %108
294                OpStore %9 %112
295         %117 = OpAccessChain %116 %114 %115
296         %118 = OpLoad %6 %117
297         %121 = OpFOrdLessThan %46 %118 %33
298                OpSelectionMerge %123 None
299                OpBranchConditional %121 %122 %123
300         %122 = OpLabel
301                OpStore %171 %172
302                OpBranch %66
303         %123 = OpLabel
304         %127 = OpConvertSToF %6 %51
305         %128 = OpCompositeConstruct %7 %127 %127 %127 %127
306                OpStore %9 %128
307                OpBranch %67
308          %67 = OpLabel
309         %129 = OpLoad %10 %61
310         %130 = OpIAdd %10 %129 %18
311                OpStore %61 %130
312                OpBranch %64
313          %66 = OpLabel
314         %174 = OpLoad %46 %171
315                OpSelectionMerge %173 None
316                OpBranchConditional %174 %54 %173
317         %173 = OpLabel
318                OpBranch %55
319          %55 = OpLabel
320         %131 = OpLoad %10 %48
321         %132 = OpIAdd %10 %131 %18
322                OpStore %48 %132
323                OpBranch %52
324          %54 = OpLabel
325         %176 = OpLoad %46 %171
326                OpSelectionMerge %175 None
327                OpBranchConditional %176 %40 %175
328         %175 = OpLabel
329                OpBranch %41
330          %41 = OpLabel
331         %133 = OpLoad %10 %35
332         %134 = OpIAdd %10 %133 %18
333                OpStore %35 %134
334                OpBranch %38
335          %40 = OpLabel
336         %178 = OpLoad %46 %171
337                OpSelectionMerge %177 None
338                OpBranchConditional %178 %166 %177
339         %177 = OpLabel
340         %135 = OpLoad %6 %25
341         %136 = OpAccessChain %31 %30 %17 %18
342         %137 = OpLoad %6 %136
343         %138 = OpFOrdGreaterThan %46 %135 %137
344                OpSelectionMerge %140 None
345                OpBranchConditional %138 %139 %140
346         %139 = OpLabel
347         %141 = OpLoad %6 %25
348         %142 = OpAccessChain %31 %30 %17 %49
349         %143 = OpLoad %6 %142
350         %144 = OpFOrdLessThan %46 %141 %143
351                OpBranch %140
352         %140 = OpLabel
353         %145 = OpPhi %46 %138 %177 %144 %139
354                OpSelectionMerge %147 None
355                OpBranchConditional %145 %146 %161
356         %146 = OpLabel
357         %151 = OpAccessChain %19 %16 %17 %49
358         %152 = OpLoad %10 %151
359         %153 = OpConvertSToF %6 %152
360         %160 = OpCompositeConstruct %7 %22 %153 %153 %22
361                OpStore %9 %160
362                OpBranch %147
363         %161 = OpLabel
364         %162 = OpAccessChain %19 %16 %17 %49
365         %163 = OpLoad %10 %162
366         %164 = OpConvertSToF %6 %163
367         %165 = OpCompositeConstruct %7 %164 %164 %164 %164
368                OpStore %9 %165
369                OpBranch %147
370         %147 = OpLabel
371                OpStore %171 %172
372                OpBranch %166
373         %166 = OpLabel
374                OpReturn
375                OpFunctionEnd
376 END
377
378 # uniforms for variant
379
380 # _GLF_uniform_int_values
381 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
382  5 1 0
383 END
384 # _GLF_uniform_float_values
385 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
386  0.0 3.9 4.1 1.0
387 END
388
389 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
390
391 PIPELINE graphics variant_pipeline
392   ATTACH variant_vertex_shader
393   ATTACH variant_fragment_shader
394   FRAMEBUFFER_SIZE 32 32
395   BIND BUFFER variant_framebuffer AS color LOCATION 0
396   BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
397   BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
398 END
399 CLEAR_COLOR variant_pipeline 0 0 0 255
400
401 CLEAR variant_pipeline
402 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
403
404 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255