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