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