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