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