Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / cov-unused-access-past-matrix-elements.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 NIR code paths
21
22 # The test passes because the shader always writes red.
23
24 # Optimized using spirv-opt with the following arguments:
25 # '--vector-dce'
26 # '--scalar-replacement=100'
27 # '--eliminate-local-multi-store'
28 # '--copy-propagate-arrays'
29 # '--convert-local-access-chains'
30 # '--reduce-load-size'
31 # '--eliminate-dead-inserts'
32 # '--eliminate-dead-inserts'
33 # '--ccp'
34 # spirv-opt commit hash: a0370efd589be33d5d9a85cfde2f85841b3755af
35
36
37
38 SHADER vertex variant_vertex_shader PASSTHROUGH
39
40 # variant_fragment_shader is derived from the following GLSL:
41 # #version 320 es
42 # #define _int_1 _GLF_uniform_int_values[0]
43 # #define _int_0 _GLF_uniform_int_values[1]
44 # #define _int_2 _GLF_uniform_int_values[2]
45 # #define _int_4 _GLF_uniform_int_values[3]
46 # #define _float_1_0 _GLF_uniform_float_values[0]
47 # #define _float_0_0 _GLF_uniform_float_values[1]
48 # #define _float_3_0 _GLF_uniform_float_values[2]
49 #
50 # precision highp int;
51 # precision highp float;
52 #
53 # // Contents of _GLF_uniform_int_values: [1, 0, 2, 4]
54 # layout(set = 0, binding = 0) uniform buf0
55 # {
56 #     int _GLF_uniform_int_values[4];
57 # };
58 # // Contents of _GLF_uniform_float_values: [1.0, 0.0, 3.0]
59 # layout(set = 0, binding = 1) uniform buf1
60 # {
61 #     float _GLF_uniform_float_values[3];
62 # };
63 # layout(location = 0) out vec4 _GLF_color;
64 #
65 # void main()
66 # {
67 #     mat4x3 m43 = mat4x3(_float_0_0);
68 #     m43[_int_1][_int_1] = _float_1_0;
69 #     float sums[3] = float[3](_float_1_0, _float_1_0, _float_1_0);
70 #
71 #     // Increases sums[1] by one, picking it from m43[1][1].
72 #     for(int i = _int_1; i < _int_4; i++)
73 #     {
74 #         sums[_int_1] += m43[i][_int_1];
75 #     }
76 #
77 #     // Always false.
78 #     if (_int_0 == 1)
79 #     {
80 #         // Static out of bound access is required
81 #         // to hit the coverage point. Still, this
82 #         // is never executed.
83 #         int a = 4;
84 #         sums[_int_2] += m43[a][_int_1];
85 #     }
86 #
87 #     if(sums[_int_0] + sums[_int_1] == _float_3_0)
88 #     {
89 #         _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
90 #     }
91 #     else
92 #     {
93 #         _GLF_color = vec4(_int_0);
94 #     }
95 # }
96 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
97 ; SPIR-V
98 ; Version: 1.0
99 ; Generator: Khronos Glslang Reference Front End; 10
100 ; Bound: 137
101 ; Schema: 0
102                OpCapability Shader
103           %1 = OpExtInstImport "GLSL.std.450"
104                OpMemoryModel Logical GLSL450
105                OpEntryPoint Fragment %4 "main" %116
106                OpExecutionMode %4 OriginUpperLeft
107                OpSource ESSL 320
108                OpName %4 "main"
109                OpName %10 "m43"
110                OpName %14 "buf1"
111                OpMemberName %14 0 "_GLF_uniform_float_values"
112                OpName %16 ""
113                OpName %32 "buf0"
114                OpMemberName %32 0 "_GLF_uniform_int_values"
115                OpName %34 ""
116                OpName %45 "sums"
117                OpName %54 "i"
118                OpName %86 "a"
119                OpName %116 "_GLF_color"
120                OpDecorate %13 ArrayStride 16
121                OpMemberDecorate %14 0 Offset 0
122                OpDecorate %14 Block
123                OpDecorate %16 DescriptorSet 0
124                OpDecorate %16 Binding 1
125                OpDecorate %31 ArrayStride 16
126                OpMemberDecorate %32 0 Offset 0
127                OpDecorate %32 Block
128                OpDecorate %34 DescriptorSet 0
129                OpDecorate %34 Binding 0
130                OpDecorate %116 Location 0
131           %2 = OpTypeVoid
132           %3 = OpTypeFunction %2
133           %6 = OpTypeFloat 32
134           %7 = OpTypeVector %6 3
135           %8 = OpTypeMatrix %7 4
136           %9 = OpTypePointer Function %8
137          %11 = OpTypeInt 32 0
138          %12 = OpConstant %11 3
139          %13 = OpTypeArray %6 %12
140          %14 = OpTypeStruct %13
141          %15 = OpTypePointer Uniform %14
142          %16 = OpVariable %15 Uniform
143          %17 = OpTypeInt 32 1
144          %18 = OpConstant %17 0
145          %19 = OpConstant %17 1
146          %20 = OpTypePointer Uniform %6
147          %23 = OpConstant %6 1
148          %24 = OpConstant %6 0
149          %30 = OpConstant %11 4
150          %31 = OpTypeArray %17 %30
151          %32 = OpTypeStruct %31
152          %33 = OpTypePointer Uniform %32
153          %34 = OpVariable %33 Uniform
154          %35 = OpTypePointer Uniform %17
155          %42 = OpTypePointer Function %6
156          %44 = OpTypePointer Function %13
157          %53 = OpTypePointer Function %17
158          %63 = OpConstant %17 3
159          %66 = OpTypeBool
160          %87 = OpConstant %17 4
161          %88 = OpConstant %17 2
162         %114 = OpTypeVector %6 4
163         %115 = OpTypePointer Output %114
164         %116 = OpVariable %115 Output
165         %136 = OpConstantComposite %7 %24 %24 %24
166           %4 = OpFunction %2 None %3
167           %5 = OpLabel
168          %10 = OpVariable %9 Function
169          %45 = OpVariable %44 Function
170          %54 = OpVariable %53 Function
171          %86 = OpVariable %53 Function
172          %21 = OpAccessChain %20 %16 %18 %19
173          %22 = OpLoad %6 %21
174          %25 = OpCompositeConstruct %7 %22 %24 %24
175          %26 = OpCompositeConstruct %7 %24 %22 %24
176          %27 = OpCompositeConstruct %7 %24 %24 %22
177          %28 = OpCompositeConstruct %7 %24 %24 %24
178          %29 = OpCompositeConstruct %8 %25 %26 %27 %136
179                OpStore %10 %29
180          %36 = OpAccessChain %35 %34 %18 %18
181          %37 = OpLoad %17 %36
182          %38 = OpAccessChain %35 %34 %18 %18
183          %39 = OpLoad %17 %38
184          %40 = OpAccessChain %20 %16 %18 %18
185          %41 = OpLoad %6 %40
186          %43 = OpAccessChain %42 %10 %37 %39
187                OpStore %43 %41
188          %46 = OpAccessChain %20 %16 %18 %18
189          %47 = OpLoad %6 %46
190          %48 = OpAccessChain %20 %16 %18 %18
191          %49 = OpLoad %6 %48
192          %50 = OpAccessChain %20 %16 %18 %18
193          %51 = OpLoad %6 %50
194          %52 = OpCompositeConstruct %13 %47 %49 %51
195                OpStore %45 %52
196          %55 = OpAccessChain %35 %34 %18 %18
197          %56 = OpLoad %17 %55
198                OpStore %54 %56
199                OpBranch %57
200          %57 = OpLabel
201         %135 = OpPhi %17 %56 %5 %80 %60
202                OpLoopMerge %59 %60 None
203                OpBranch %61
204          %61 = OpLabel
205          %64 = OpAccessChain %35 %34 %18 %63
206          %65 = OpLoad %17 %64
207          %67 = OpSLessThan %66 %135 %65
208                OpBranchConditional %67 %58 %59
209          %58 = OpLabel
210          %68 = OpAccessChain %35 %34 %18 %18
211          %69 = OpLoad %17 %68
212          %71 = OpAccessChain %35 %34 %18 %18
213          %72 = OpLoad %17 %71
214          %73 = OpAccessChain %42 %10 %135 %72
215          %74 = OpLoad %6 %73
216          %75 = OpAccessChain %42 %45 %69
217          %76 = OpLoad %6 %75
218          %77 = OpFAdd %6 %76 %74
219          %78 = OpAccessChain %42 %45 %69
220                OpStore %78 %77
221                OpBranch %60
222          %60 = OpLabel
223          %80 = OpIAdd %17 %135 %19
224                OpStore %54 %80
225                OpBranch %57
226          %59 = OpLabel
227          %81 = OpAccessChain %35 %34 %18 %19
228          %82 = OpLoad %17 %81
229          %83 = OpIEqual %66 %82 %19
230                OpSelectionMerge %85 None
231                OpBranchConditional %83 %84 %85
232          %84 = OpLabel
233                OpStore %86 %87
234          %89 = OpAccessChain %35 %34 %18 %88
235          %90 = OpLoad %17 %89
236          %92 = OpAccessChain %35 %34 %18 %18
237          %93 = OpLoad %17 %92
238          %94 = OpAccessChain %42 %10 %87 %93
239          %95 = OpLoad %6 %94
240          %96 = OpAccessChain %42 %45 %90
241          %97 = OpLoad %6 %96
242          %98 = OpFAdd %6 %97 %95
243          %99 = OpAccessChain %42 %45 %90
244                OpStore %99 %98
245                OpBranch %85
246          %85 = OpLabel
247         %100 = OpAccessChain %35 %34 %18 %19
248         %101 = OpLoad %17 %100
249         %102 = OpAccessChain %42 %45 %101
250         %103 = OpLoad %6 %102
251         %104 = OpAccessChain %35 %34 %18 %18
252         %105 = OpLoad %17 %104
253         %106 = OpAccessChain %42 %45 %105
254         %107 = OpLoad %6 %106
255         %108 = OpFAdd %6 %103 %107
256         %109 = OpAccessChain %20 %16 %18 %88
257         %110 = OpLoad %6 %109
258         %111 = OpFOrdEqual %66 %108 %110
259                OpSelectionMerge %113 None
260                OpBranchConditional %111 %112 %130
261         %112 = OpLabel
262         %117 = OpAccessChain %35 %34 %18 %18
263         %118 = OpLoad %17 %117
264         %119 = OpConvertSToF %6 %118
265         %120 = OpAccessChain %35 %34 %18 %19
266         %121 = OpLoad %17 %120
267         %122 = OpConvertSToF %6 %121
268         %123 = OpAccessChain %35 %34 %18 %19
269         %124 = OpLoad %17 %123
270         %125 = OpConvertSToF %6 %124
271         %126 = OpAccessChain %35 %34 %18 %18
272         %127 = OpLoad %17 %126
273         %128 = OpConvertSToF %6 %127
274         %129 = OpCompositeConstruct %114 %119 %122 %125 %128
275                OpStore %116 %129
276                OpBranch %113
277         %130 = OpLabel
278         %131 = OpAccessChain %35 %34 %18 %19
279         %132 = OpLoad %17 %131
280         %133 = OpConvertSToF %6 %132
281         %134 = OpCompositeConstruct %114 %133 %133 %133 %133
282                OpStore %116 %134
283                OpBranch %113
284         %113 = OpLabel
285                OpReturn
286                OpFunctionEnd
287 END
288
289 # uniforms for variant
290
291 # _GLF_uniform_float_values
292 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
293  1.0 0.0 3.0
294 END
295 # _GLF_uniform_int_values
296 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
297  1 0 2 4
298 END
299
300 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
301
302 PIPELINE graphics variant_pipeline
303   ATTACH variant_vertex_shader
304   ATTACH variant_fragment_shader
305   FRAMEBUFFER_SIZE 256 256
306   BIND BUFFER variant_framebuffer AS color LOCATION 0
307   BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1
308   BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
309 END
310 CLEAR_COLOR variant_pipeline 0 0 0 255
311
312 CLEAR variant_pipeline
313 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
314
315 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255