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