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