Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / cov-apfloat-undefined-matrix-mul.amber
1 #!amber
2
3 # Copyright 2020 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 a specific floating point code path
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 310 es
28 # #define _int_50 _GLF_uniform_int_values[0]
29 # #define _int_10 _GLF_uniform_int_values[1]
30 # #define _int_11 _GLF_uniform_int_values[2]
31 # #define _int_12 _GLF_uniform_int_values[3]
32 # #define _int_1 _GLF_uniform_int_values[4]
33 # #define _int_2 _GLF_uniform_int_values[5]
34 # #define _int_3 _GLF_uniform_int_values[6]
35 # #define _int_6 _GLF_uniform_int_values[7]
36 # #define _int_7 _GLF_uniform_int_values[8]
37 # #define _int_0 _GLF_uniform_int_values[9]
38 # #define _int_5 _GLF_uniform_int_values[10]
39 # #define _int_9 _GLF_uniform_int_values[11]
40 # #define _float_0_0 _GLF_uniform_float_values[0]
41 #
42 # precision highp float;
43 #
44 # // Contents of _GLF_uniform_float_values: 0.0
45 # layout(set = 0, binding = 0) uniform buf0
46 # {
47 #     float _GLF_uniform_float_values[1];
48 # };
49 #
50 # // Contents of _GLF_uniform_int_values: [50, 10, 11, 12, 1, 2, 3, 6, 7, 0, 5, 9]
51 # layout(set = 0, binding = 1) uniform buf1
52 # {
53 #     int _GLF_uniform_int_values[12];
54 # };
55 #
56 # layout(location = 0) out vec4 _GLF_color;
57 #
58 # void main()
59 # {
60 #     mat3x4 m0 = mat3x4(_int_1, _int_2, _int_3, 4, _int_5, _int_6, _int_7, 8,
61 #                        _int_9, _int_10, _int_11, _int_12);
62 #     mat3x4 m1 = mat3x4(_int_1);
63 #
64 #     // Results are too large to fit into a floating point type, thus the results are undefined.
65 #     vec3 undefined = ldexp(vec3(1), ivec3(500));
66 #     // These still fit into floating point type.
67 #     vec3 defined = ldexp(vec3(_int_1), ivec3(_int_50));
68 #
69 #     // Vectors v0 and v1 are undefined.
70 #     vec4 v0 = m0 * undefined;
71 #     vec4 v1 = m1 * undefined;
72 #
73 #     // Vectors v2 and v3 are defined.
74 #     vec4 v2 = m0 * defined;
75 #     vec4 v3 = m1 * defined;
76 #
77 #     // Always true.
78 #     if (v2.x > v3.x)
79 #     {
80 #         _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
81 #     }
82 #     else
83 #     {
84 #         _GLF_color = vec4(_int_0);
85 #     }
86 #
87 #     // The result doesn't matter as the green channel is already zero.
88 #     if (v0.x < v1.x)
89 #     {
90 #         _GLF_color.g = _float_0_0;
91 #     }
92 # }
93 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
94 ; SPIR-V
95 ; Version: 1.0
96 ; Generator: Khronos Glslang Reference Front End; 8
97 ; Bound: 158
98 ; Schema: 0
99                OpCapability Shader
100           %1 = OpExtInstImport "GLSL.std.450"
101                OpMemoryModel Logical GLSL450
102                OpEntryPoint Fragment %4 "main" %121
103                OpExecutionMode %4 OriginUpperLeft
104                OpSource ESSL 310
105                OpName %4 "main"
106                OpName %10 "m0"
107                OpName %15 "buf1"
108                OpMemberName %15 0 "_GLF_uniform_int_values"
109                OpName %17 ""
110                OpName %68 "m1"
111                OpName %78 "undefined"
112                OpName %84 "defined"
113                OpName %94 "v0"
114                OpName %98 "v1"
115                OpName %102 "v2"
116                OpName %106 "v3"
117                OpName %121 "_GLF_color"
118                OpName %150 "buf0"
119                OpMemberName %150 0 "_GLF_uniform_float_values"
120                OpName %152 ""
121                OpDecorate %14 ArrayStride 16
122                OpMemberDecorate %15 0 RelaxedPrecision
123                OpMemberDecorate %15 0 Offset 0
124                OpDecorate %15 Block
125                OpDecorate %17 DescriptorSet 0
126                OpDecorate %17 Binding 1
127                OpDecorate %22 RelaxedPrecision
128                OpDecorate %26 RelaxedPrecision
129                OpDecorate %30 RelaxedPrecision
130                OpDecorate %35 RelaxedPrecision
131                OpDecorate %39 RelaxedPrecision
132                OpDecorate %43 RelaxedPrecision
133                OpDecorate %48 RelaxedPrecision
134                OpDecorate %52 RelaxedPrecision
135                OpDecorate %56 RelaxedPrecision
136                OpDecorate %60 RelaxedPrecision
137                OpDecorate %70 RelaxedPrecision
138                OpDecorate %86 RelaxedPrecision
139                OpDecorate %90 RelaxedPrecision
140                OpDecorate %121 Location 0
141                OpDecorate %123 RelaxedPrecision
142                OpDecorate %127 RelaxedPrecision
143                OpDecorate %130 RelaxedPrecision
144                OpDecorate %133 RelaxedPrecision
145                OpDecorate %138 RelaxedPrecision
146                OpDecorate %149 ArrayStride 16
147                OpMemberDecorate %150 0 Offset 0
148                OpDecorate %150 Block
149                OpDecorate %152 DescriptorSet 0
150                OpDecorate %152 Binding 0
151           %2 = OpTypeVoid
152           %3 = OpTypeFunction %2
153           %6 = OpTypeFloat 32
154           %7 = OpTypeVector %6 4
155           %8 = OpTypeMatrix %7 3
156           %9 = OpTypePointer Function %8
157          %11 = OpTypeInt 32 1
158          %12 = OpTypeInt 32 0
159          %13 = OpConstant %12 12
160          %14 = OpTypeArray %11 %13
161          %15 = OpTypeStruct %14
162          %16 = OpTypePointer Uniform %15
163          %17 = OpVariable %16 Uniform
164          %18 = OpConstant %11 0
165          %19 = OpConstant %11 4
166          %20 = OpTypePointer Uniform %11
167          %24 = OpConstant %11 5
168          %28 = OpConstant %11 6
169          %32 = OpConstant %6 4
170          %33 = OpConstant %11 10
171          %37 = OpConstant %11 7
172          %41 = OpConstant %11 8
173          %45 = OpConstant %6 8
174          %46 = OpConstant %11 11
175          %50 = OpConstant %11 1
176          %54 = OpConstant %11 2
177          %58 = OpConstant %11 3
178          %62 = OpConstant %6 1
179          %63 = OpConstant %6 0
180          %76 = OpTypeVector %6 3
181          %77 = OpTypePointer Function %76
182          %79 = OpConstantComposite %76 %62 %62 %62
183          %80 = OpTypeVector %11 3
184          %81 = OpConstant %11 500
185          %82 = OpConstantComposite %80 %81 %81 %81
186          %93 = OpTypePointer Function %7
187         %110 = OpConstant %12 0
188         %111 = OpTypePointer Function %6
189         %116 = OpTypeBool
190         %120 = OpTypePointer Output %7
191         %121 = OpVariable %120 Output
192         %125 = OpConstant %11 9
193         %148 = OpConstant %12 1
194         %149 = OpTypeArray %6 %148
195         %150 = OpTypeStruct %149
196         %151 = OpTypePointer Uniform %150
197         %152 = OpVariable %151 Uniform
198         %153 = OpTypePointer Uniform %6
199         %156 = OpTypePointer Output %6
200           %4 = OpFunction %2 None %3
201           %5 = OpLabel
202          %10 = OpVariable %9 Function
203          %68 = OpVariable %9 Function
204          %78 = OpVariable %77 Function
205          %84 = OpVariable %77 Function
206          %94 = OpVariable %93 Function
207          %98 = OpVariable %93 Function
208         %102 = OpVariable %93 Function
209         %106 = OpVariable %93 Function
210          %21 = OpAccessChain %20 %17 %18 %19
211          %22 = OpLoad %11 %21
212          %23 = OpConvertSToF %6 %22
213          %25 = OpAccessChain %20 %17 %18 %24
214          %26 = OpLoad %11 %25
215          %27 = OpConvertSToF %6 %26
216          %29 = OpAccessChain %20 %17 %18 %28
217          %30 = OpLoad %11 %29
218          %31 = OpConvertSToF %6 %30
219          %34 = OpAccessChain %20 %17 %18 %33
220          %35 = OpLoad %11 %34
221          %36 = OpConvertSToF %6 %35
222          %38 = OpAccessChain %20 %17 %18 %37
223          %39 = OpLoad %11 %38
224          %40 = OpConvertSToF %6 %39
225          %42 = OpAccessChain %20 %17 %18 %41
226          %43 = OpLoad %11 %42
227          %44 = OpConvertSToF %6 %43
228          %47 = OpAccessChain %20 %17 %18 %46
229          %48 = OpLoad %11 %47
230          %49 = OpConvertSToF %6 %48
231          %51 = OpAccessChain %20 %17 %18 %50
232          %52 = OpLoad %11 %51
233          %53 = OpConvertSToF %6 %52
234          %55 = OpAccessChain %20 %17 %18 %54
235          %56 = OpLoad %11 %55
236          %57 = OpConvertSToF %6 %56
237          %59 = OpAccessChain %20 %17 %18 %58
238          %60 = OpLoad %11 %59
239          %61 = OpConvertSToF %6 %60
240          %64 = OpCompositeConstruct %7 %23 %27 %31 %32
241          %65 = OpCompositeConstruct %7 %36 %40 %44 %45
242          %66 = OpCompositeConstruct %7 %49 %53 %57 %61
243          %67 = OpCompositeConstruct %8 %64 %65 %66
244                OpStore %10 %67
245          %69 = OpAccessChain %20 %17 %18 %19
246          %70 = OpLoad %11 %69
247          %71 = OpConvertSToF %6 %70
248          %72 = OpCompositeConstruct %7 %71 %63 %63 %63
249          %73 = OpCompositeConstruct %7 %63 %71 %63 %63
250          %74 = OpCompositeConstruct %7 %63 %63 %71 %63
251          %75 = OpCompositeConstruct %8 %72 %73 %74
252                OpStore %68 %75
253          %83 = OpExtInst %76 %1 Ldexp %79 %82
254                OpStore %78 %83
255          %85 = OpAccessChain %20 %17 %18 %19
256          %86 = OpLoad %11 %85
257          %87 = OpConvertSToF %6 %86
258          %88 = OpCompositeConstruct %76 %87 %87 %87
259          %89 = OpAccessChain %20 %17 %18 %18
260          %90 = OpLoad %11 %89
261          %91 = OpCompositeConstruct %80 %90 %90 %90
262          %92 = OpExtInst %76 %1 Ldexp %88 %91
263                OpStore %84 %92
264          %95 = OpLoad %8 %10
265          %96 = OpLoad %76 %78
266          %97 = OpMatrixTimesVector %7 %95 %96
267                OpStore %94 %97
268          %99 = OpLoad %8 %68
269         %100 = OpLoad %76 %78
270         %101 = OpMatrixTimesVector %7 %99 %100
271                OpStore %98 %101
272         %103 = OpLoad %8 %10
273         %104 = OpLoad %76 %84
274         %105 = OpMatrixTimesVector %7 %103 %104
275                OpStore %102 %105
276         %107 = OpLoad %8 %68
277         %108 = OpLoad %76 %84
278         %109 = OpMatrixTimesVector %7 %107 %108
279                OpStore %106 %109
280         %112 = OpAccessChain %111 %102 %110
281         %113 = OpLoad %6 %112
282         %114 = OpAccessChain %111 %106 %110
283         %115 = OpLoad %6 %114
284         %117 = OpFOrdGreaterThan %116 %113 %115
285                OpSelectionMerge %119 None
286                OpBranchConditional %117 %118 %136
287         %118 = OpLabel
288         %122 = OpAccessChain %20 %17 %18 %19
289         %123 = OpLoad %11 %122
290         %124 = OpConvertSToF %6 %123
291         %126 = OpAccessChain %20 %17 %18 %125
292         %127 = OpLoad %11 %126
293         %128 = OpConvertSToF %6 %127
294         %129 = OpAccessChain %20 %17 %18 %125
295         %130 = OpLoad %11 %129
296         %131 = OpConvertSToF %6 %130
297         %132 = OpAccessChain %20 %17 %18 %19
298         %133 = OpLoad %11 %132
299         %134 = OpConvertSToF %6 %133
300         %135 = OpCompositeConstruct %7 %124 %128 %131 %134
301                OpStore %121 %135
302                OpBranch %119
303         %136 = OpLabel
304         %137 = OpAccessChain %20 %17 %18 %125
305         %138 = OpLoad %11 %137
306         %139 = OpConvertSToF %6 %138
307         %140 = OpCompositeConstruct %7 %139 %139 %139 %139
308                OpStore %121 %140
309                OpBranch %119
310         %119 = OpLabel
311         %141 = OpAccessChain %111 %94 %110
312         %142 = OpLoad %6 %141
313         %143 = OpAccessChain %111 %98 %110
314         %144 = OpLoad %6 %143
315         %145 = OpFOrdLessThan %116 %142 %144
316                OpSelectionMerge %147 None
317                OpBranchConditional %145 %146 %147
318         %146 = OpLabel
319         %154 = OpAccessChain %153 %152 %18 %18
320         %155 = OpLoad %6 %154
321         %157 = OpAccessChain %156 %121 %148
322                OpStore %157 %155
323                OpBranch %147
324         %147 = OpLabel
325                OpReturn
326                OpFunctionEnd
327 END
328
329 # uniforms for variant
330
331 # _GLF_uniform_int_values
332 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
333  50 10 11 12 1 2 3 6 7 0 5 9
334 END
335 # _GLF_uniform_float_values
336 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
337  0.0
338 END
339
340 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
341
342 PIPELINE graphics variant_pipeline
343   ATTACH variant_vertex_shader
344   ATTACH variant_fragment_shader
345   FRAMEBUFFER_SIZE 256 256
346   BIND BUFFER variant_framebuffer AS color LOCATION 0
347   BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
348   BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
349 END
350 CLEAR_COLOR variant_pipeline 0 0 0 255
351
352 CLEAR variant_pipeline
353 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
354
355 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255