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