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