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