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