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