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