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