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