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