Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / cov-function-struct-int-array-loop-check-element.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 # '--ccp'
26 # '--eliminate-local-single-store'
27 # '--eliminate-dead-branches'
28 # '--merge-return'
29 # '--eliminate-dead-branches'
30 # '--eliminate-dead-branches'
31 # '--merge-return'
32 # '--eliminate-dead-code-aggressive'
33 # '--private-to-local'
34 # '--private-to-local'
35 # '--eliminate-dead-inserts'
36 # '--copy-propagate-arrays'
37 # '--eliminate-local-multi-store'
38 # '--eliminate-dead-inserts'
39 # spirv-opt commit hash: a0370efd589be33d5d9a85cfde2f85841b3755af
40
41
42
43 SHADER vertex variant_vertex_shader PASSTHROUGH
44
45 # variant_fragment_shader is derived from the following GLSL:
46 # #version 320 es
47 #
48 # #define _int_1 _GLF_uniform_int_values[0]
49 # #define _int_0 _GLF_uniform_int_values[1]
50 # #define _int_2 _GLF_uniform_int_values[2]
51 # #define _int_9 _GLF_uniform_int_values[3]
52 #
53 # precision highp float;
54 # precision highp int;
55 #
56 # // Contents of _GLF_uniform_int_values: [1, 0, 2, 9]
57 # layout(set = 0, binding = 0) uniform buf0
58 # {
59 #     int _GLF_uniform_int_values[4];
60 # };
61 #
62 # layout(location = 0) out vec4 _GLF_color;
63 #
64 # struct S
65 # {
66 #     int arr[10];
67 # };
68 #
69 # int func(S s)
70 # {
71 #     int a = _int_0;
72 #
73 #     // Iterates twice.
74 #     for(int i = _int_0; i < _int_2; i++)
75 #     {
76 #         // True during the second iteration when a = 1.
77 #         if(s.arr[(a + _int_9) / _int_2] == 1)
78 #         {
79 #             return i;
80 #         }
81 #
82 #         a = _int_1;
83 #     }
84 #
85 #     // Never executed.
86 #     return _int_0;
87 # }
88 #
89 # void main()
90 # {
91 #     S s = S(int[10](1, 1, 1, 1, -1, 1, 1, 1, 1, 1));
92 #
93 #     // Always true.
94 #     if(func(s) == _int_1)
95 #     {
96 #         _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
97 #     }
98 #     else
99 #     {
100 #         _GLF_color = vec4(_int_0);
101 #     }
102 # }
103 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
104 ; SPIR-V
105 ; Version: 1.0
106 ; Generator: Khronos Glslang Reference Front End; 10
107 ; Bound: 118
108 ; Schema: 0
109                OpCapability Shader
110           %1 = OpExtInstImport "GLSL.std.450"
111                OpMemoryModel Logical GLSL450
112                OpEntryPoint Fragment %4 "main" %80
113                OpExecutionMode %4 OriginUpperLeft
114                OpSource ESSL 320
115                OpName %4 "main"
116                OpName %10 "S"
117                OpMemberName %10 0 "arr"
118                OpName %14 "func(struct-S-i1[10]1;"
119                OpName %13 "s"
120                OpName %17 "a"
121                OpName %20 "buf0"
122                OpMemberName %20 0 "_GLF_uniform_int_values"
123                OpName %22 ""
124                OpName %28 "i"
125                OpName %69 "param"
126                OpName %80 "_GLF_color"
127                OpDecorate %19 ArrayStride 16
128                OpMemberDecorate %20 0 Offset 0
129                OpDecorate %20 Block
130                OpDecorate %22 DescriptorSet 0
131                OpDecorate %22 Binding 0
132                OpDecorate %80 Location 0
133           %2 = OpTypeVoid
134           %3 = OpTypeFunction %2
135           %6 = OpTypeInt 32 1
136           %7 = OpTypeInt 32 0
137           %8 = OpConstant %7 10
138           %9 = OpTypeArray %6 %8
139          %10 = OpTypeStruct %9
140          %11 = OpTypePointer Function %10
141          %12 = OpTypeFunction %6 %11
142          %16 = OpTypePointer Function %6
143          %18 = OpConstant %7 4
144          %19 = OpTypeArray %6 %18
145          %20 = OpTypeStruct %19
146          %21 = OpTypePointer Uniform %20
147          %22 = OpVariable %21 Uniform
148          %23 = OpConstant %6 0
149          %24 = OpConstant %6 1
150          %25 = OpTypePointer Uniform %6
151          %37 = OpConstant %6 2
152          %40 = OpTypeBool
153          %43 = OpConstant %6 3
154          %66 = OpConstant %6 -1
155          %67 = OpConstantComposite %9 %24 %24 %24 %24 %66 %24 %24 %24 %24 %24
156          %68 = OpConstantComposite %10 %67
157          %77 = OpTypeFloat 32
158          %78 = OpTypeVector %77 4
159          %79 = OpTypePointer Output %78
160          %80 = OpVariable %79 Output
161         %103 = OpConstant %7 0
162         %104 = OpConstantFalse %40
163         %105 = OpTypePointer Function %40
164         %107 = OpConstantTrue %40
165         %117 = OpUndef %6
166           %4 = OpFunction %2 None %3
167           %5 = OpLabel
168          %69 = OpVariable %11 Function
169                OpStore %69 %68
170          %71 = OpFunctionCall %6 %14 %69
171          %72 = OpAccessChain %25 %22 %23 %23
172          %73 = OpLoad %6 %72
173          %74 = OpIEqual %40 %71 %73
174                OpSelectionMerge %76 None
175                OpBranchConditional %74 %75 %94
176          %75 = OpLabel
177          %81 = OpAccessChain %25 %22 %23 %23
178          %82 = OpLoad %6 %81
179          %83 = OpConvertSToF %77 %82
180          %84 = OpAccessChain %25 %22 %23 %24
181          %85 = OpLoad %6 %84
182          %86 = OpConvertSToF %77 %85
183          %87 = OpAccessChain %25 %22 %23 %24
184          %88 = OpLoad %6 %87
185          %89 = OpConvertSToF %77 %88
186          %90 = OpAccessChain %25 %22 %23 %23
187          %91 = OpLoad %6 %90
188          %92 = OpConvertSToF %77 %91
189          %93 = OpCompositeConstruct %78 %83 %86 %89 %92
190                OpStore %80 %93
191                OpBranch %76
192          %94 = OpLabel
193          %95 = OpAccessChain %25 %22 %23 %24
194          %96 = OpLoad %6 %95
195          %97 = OpConvertSToF %77 %96
196          %98 = OpCompositeConstruct %78 %97 %97 %97 %97
197                OpStore %80 %98
198                OpBranch %76
199          %76 = OpLabel
200                OpReturn
201                OpFunctionEnd
202          %14 = OpFunction %6 None %12
203          %13 = OpFunctionParameter %11
204          %15 = OpLabel
205         %106 = OpVariable %105 Function %104
206         %100 = OpVariable %16 Function
207          %17 = OpVariable %16 Function
208          %28 = OpVariable %16 Function
209                OpSelectionMerge %99 None
210                OpSwitch %103 %102
211         %102 = OpLabel
212          %26 = OpAccessChain %25 %22 %23 %24
213          %27 = OpLoad %6 %26
214                OpStore %17 %27
215          %29 = OpAccessChain %25 %22 %23 %24
216          %30 = OpLoad %6 %29
217                OpStore %28 %30
218                OpBranch %31
219          %31 = OpLabel
220         %111 = OpPhi %6 %27 %102 %58 %34
221         %110 = OpPhi %6 %30 %102 %60 %34
222                OpLoopMerge %33 %34 None
223                OpBranch %35
224          %35 = OpLabel
225          %38 = OpAccessChain %25 %22 %23 %37
226          %39 = OpLoad %6 %38
227          %41 = OpSLessThan %40 %110 %39
228                OpBranchConditional %41 %32 %33
229          %32 = OpLabel
230          %44 = OpAccessChain %25 %22 %23 %43
231          %45 = OpLoad %6 %44
232          %46 = OpIAdd %6 %111 %45
233          %47 = OpAccessChain %25 %22 %23 %37
234          %48 = OpLoad %6 %47
235          %49 = OpSDiv %6 %46 %48
236          %50 = OpAccessChain %16 %13 %23 %49
237          %51 = OpLoad %6 %50
238          %52 = OpIEqual %40 %51 %24
239                OpSelectionMerge %54 None
240                OpBranchConditional %52 %53 %54
241          %53 = OpLabel
242                OpStore %106 %107
243                OpStore %100 %110
244                OpBranch %33
245          %54 = OpLabel
246          %57 = OpAccessChain %25 %22 %23 %23
247          %58 = OpLoad %6 %57
248                OpStore %17 %58
249                OpBranch %34
250          %34 = OpLabel
251          %60 = OpIAdd %6 %110 %24
252                OpStore %28 %60
253                OpBranch %31
254          %33 = OpLabel
255         %115 = OpPhi %6 %117 %35 %110 %53
256         %112 = OpPhi %40 %104 %35 %107 %53
257                OpSelectionMerge %108 None
258                OpBranchConditional %112 %99 %108
259         %108 = OpLabel
260          %61 = OpAccessChain %25 %22 %23 %24
261          %62 = OpLoad %6 %61
262                OpStore %106 %107
263                OpStore %100 %62
264                OpBranch %99
265          %99 = OpLabel
266         %114 = OpPhi %6 %115 %33 %62 %108
267                OpReturnValue %114
268                OpFunctionEnd
269 END
270
271 # uniforms for variant
272
273 # _GLF_uniform_int_values
274 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
275  1 0 2 9
276 END
277
278 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
279
280 PIPELINE graphics variant_pipeline
281   ATTACH variant_vertex_shader
282   ATTACH variant_fragment_shader
283   FRAMEBUFFER_SIZE 32 32
284   BIND BUFFER variant_framebuffer AS color LOCATION 0
285   BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
286 END
287 CLEAR_COLOR variant_pipeline 0 0 0 255
288
289 CLEAR variant_pipeline
290 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
291
292 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255