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