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