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