Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / two-loops-mat-add.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 bug found by GraphicsFuzz.
19
20 # Short description: A fragment shader with two for loops over a global matrix
21
22 # The test passes because the shader always writes red.
23
24 # Optimized using spirv-opt with the following arguments:
25 # '--eliminate-dead-code-aggressive'
26 # '--vector-dce'
27 # '--ccp'
28 # '--ccp'
29 # '--eliminate-dead-code-aggressive'
30 # '--eliminate-local-multi-store'
31 # '--eliminate-dead-branches'
32 # '--inline-entry-points-exhaustive'
33 # '--copy-propagate-arrays'
34 # '--eliminate-local-single-store'
35 # '--eliminate-local-multi-store'
36 # '--convert-local-access-chains'
37 # '--inline-entry-points-exhaustive'
38 # '--convert-local-access-chains'
39 # '--ccp'
40 # '--redundancy-elimination'
41 # spirv-opt commit hash: 18b3b94567a9251a6f8491a6d07c4422abadd22c
42
43
44
45 SHADER vertex variant_vertex_shader PASSTHROUGH
46
47 # variant_fragment_shader is derived from the following GLSL:
48 # #version 310 es
49 # precision highp float;
50 #
51 # layout(set = 0, binding = 0) uniform buf0 {
52 #   vec2 injectionSwitch;
53 # };
54 #
55 # layout(location = 0) out vec4 _GLF_color;
56 #
57 # mat4 m44;
58 #
59 # void main()
60 # {
61 #     // Always true.
62 #     if (injectionSwitch.x < 1.0) {
63 #         m44 = mat4(
64 #             1.0,  2.0,  3.0,  4.0,
65 #             5.0,  6.0,  7.0,  8.0,
66 #             9.0,  10.0, 11.0, 12.0,
67 #             13.0, 14.0, 15.0, 16.0
68 #         );
69 #     }
70 #
71 #     float s = 0.0;
72 #     int c = 0;
73 #     for (
74 #         int i = 0;
75 #         i < 4;
76 #         i++)
77 #     {
78 #         s += m44[c][i];
79 #     }
80 #
81 #     // 0 iteration loop.
82 #     for (
83 #         int i = 4;
84 #         i < 4;
85 #         i++)
86 #     {
87 #         s += m44[c][i];
88 #     }
89 #
90 #     // Always true (1+2+3+4==10).
91 #     if (s == 10.0)
92 #         _GLF_color = vec4(1.0, 0.0, 0.0, 1.0);
93 #     else
94 #         _GLF_color = vec4(0.0, 0.0, 0.0, 1.0);
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; 8
100 ; Bound: 104
101 ; Schema: 0
102                OpCapability Shader
103           %1 = OpExtInstImport "GLSL.std.450"
104                OpMemoryModel Logical GLSL450
105                OpEntryPoint Fragment %4 "main" %92
106                OpExecutionMode %4 OriginUpperLeft
107                OpSource ESSL 310
108                OpName %4 "main"
109                OpName %8 "buf0"
110                OpMemberName %8 0 "injectionSwitch"
111                OpName %10 ""
112                OpName %26 "m44"
113                OpName %48 "s"
114                OpName %51 "c"
115                OpName %52 "i"
116                OpName %71 "i"
117                OpName %92 "_GLF_color"
118                OpMemberDecorate %8 0 Offset 0
119                OpDecorate %8 Block
120                OpDecorate %10 DescriptorSet 0
121                OpDecorate %10 Binding 0
122                OpDecorate %51 RelaxedPrecision
123                OpDecorate %52 RelaxedPrecision
124                OpDecorate %70 RelaxedPrecision
125                OpDecorate %71 RelaxedPrecision
126                OpDecorate %86 RelaxedPrecision
127                OpDecorate %92 Location 0
128                OpDecorate %96 RelaxedPrecision
129           %2 = OpTypeVoid
130           %3 = OpTypeFunction %2
131           %6 = OpTypeFloat 32
132           %7 = OpTypeVector %6 2
133           %8 = OpTypeStruct %7
134           %9 = OpTypePointer Uniform %8
135          %10 = OpVariable %9 Uniform
136          %11 = OpTypeInt 32 1
137          %12 = OpConstant %11 0
138          %13 = OpTypeInt 32 0
139          %14 = OpConstant %13 0
140          %15 = OpTypePointer Uniform %6
141          %18 = OpConstant %6 1
142          %19 = OpTypeBool
143          %23 = OpTypeVector %6 4
144          %24 = OpTypeMatrix %23 4
145          %25 = OpTypePointer Private %24
146          %26 = OpVariable %25 Private
147          %27 = OpConstant %6 2
148          %28 = OpConstant %6 3
149          %29 = OpConstant %6 4
150          %30 = OpConstantComposite %23 %18 %27 %28 %29
151          %31 = OpConstant %6 5
152          %32 = OpConstant %6 6
153          %33 = OpConstant %6 7
154          %34 = OpConstant %6 8
155          %35 = OpConstantComposite %23 %31 %32 %33 %34
156          %36 = OpConstant %6 9
157          %37 = OpConstant %6 10
158          %38 = OpConstant %6 11
159          %39 = OpConstant %6 12
160          %40 = OpConstantComposite %23 %36 %37 %38 %39
161          %41 = OpConstant %6 13
162          %42 = OpConstant %6 14
163          %43 = OpConstant %6 15
164          %44 = OpConstant %6 16
165          %45 = OpConstantComposite %23 %41 %42 %43 %44
166          %46 = OpConstantComposite %24 %30 %35 %40 %45
167          %47 = OpTypePointer Function %6
168          %49 = OpConstant %6 0
169          %50 = OpTypePointer Function %11
170          %59 = OpConstant %11 4
171          %63 = OpTypePointer Private %6
172          %69 = OpConstant %11 1
173          %91 = OpTypePointer Output %23
174          %92 = OpVariable %91 Output
175          %93 = OpConstantComposite %23 %18 %49 %49 %18
176          %95 = OpConstantComposite %23 %49 %49 %49 %18
177         %102 = OpConstantTrue %19
178         %103 = OpConstantFalse %19
179           %4 = OpFunction %2 None %3
180           %5 = OpLabel
181          %48 = OpVariable %47 Function
182          %51 = OpVariable %50 Function
183          %52 = OpVariable %50 Function
184          %71 = OpVariable %50 Function
185          %16 = OpAccessChain %15 %10 %12 %14
186          %17 = OpLoad %6 %16
187          %20 = OpFOrdLessThan %19 %17 %18
188                OpSelectionMerge %22 None
189                OpBranchConditional %20 %21 %22
190          %21 = OpLabel
191                OpStore %26 %46
192                OpBranch %22
193          %22 = OpLabel
194                OpStore %48 %49
195                OpStore %51 %12
196                OpStore %52 %12
197                OpBranch %53
198          %53 = OpLabel
199          %99 = OpPhi %6 %49 %22 %67 %56
200          %96 = OpPhi %11 %12 %22 %70 %56
201                OpLoopMerge %55 %56 None
202                OpBranch %57
203          %57 = OpLabel
204          %60 = OpSLessThan %19 %96 %59
205                OpBranchConditional %60 %54 %55
206          %54 = OpLabel
207          %64 = OpAccessChain %63 %26 %12 %96
208          %65 = OpLoad %6 %64
209          %67 = OpFAdd %6 %99 %65
210                OpStore %48 %67
211                OpBranch %56
212          %56 = OpLabel
213          %70 = OpIAdd %11 %96 %69
214                OpStore %52 %70
215                OpBranch %53
216          %55 = OpLabel
217                OpStore %71 %59
218                OpBranch %72
219          %72 = OpLabel
220          %98 = OpPhi %6 %99 %55 %84 %75
221          %97 = OpPhi %11 %59 %55 %86 %75
222                OpLoopMerge %74 %75 None
223                OpBranch %76
224          %76 = OpLabel
225          %78 = OpSLessThan %19 %59 %59
226                OpBranchConditional %103 %73 %74
227          %73 = OpLabel
228          %81 = OpAccessChain %63 %26 %12 %59
229          %82 = OpLoad %6 %81
230          %84 = OpFAdd %6 %98 %82
231                OpStore %48 %84
232                OpBranch %75
233          %75 = OpLabel
234          %86 = OpIAdd %11 %59 %69
235                OpStore %71 %86
236                OpBranch %72
237          %74 = OpLabel
238          %88 = OpFOrdEqual %19 %98 %37
239                OpSelectionMerge %90 None
240                OpBranchConditional %88 %89 %94
241          %89 = OpLabel
242                OpStore %92 %93
243                OpBranch %90
244          %94 = OpLabel
245                OpStore %92 %95
246                OpBranch %90
247          %90 = OpLabel
248                OpReturn
249                OpFunctionEnd
250 END
251
252 # uniforms for variant
253
254 # injectionSwitch
255 BUFFER variant_injectionSwitch DATA_TYPE vec2<float> DATA
256  0.0 1.0
257 END
258
259 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
260
261 PIPELINE graphics variant_pipeline
262   ATTACH variant_vertex_shader
263   ATTACH variant_fragment_shader
264   FRAMEBUFFER_SIZE 256 256
265   BIND BUFFER variant_framebuffer AS color LOCATION 0
266   BIND BUFFER variant_injectionSwitch AS uniform DESCRIPTOR_SET 0 BINDING 0
267 END
268 CLEAR_COLOR variant_pipeline 0 0 0 255
269
270 CLEAR variant_pipeline
271 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
272
273 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255