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