Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / nested-for-break-mat-color.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: Two nested for loops modify a mat4 then writes red
21
22 # The test passes because the shader always writes red.
23
24 # Optimized using spirv-opt with the following arguments:
25 # '-O'
26 # spirv-opt commit hash: 18b3b94567a9251a6f8491a6d07c4422abadd22c
27
28
29
30 SHADER vertex variant_vertex_shader PASSTHROUGH
31
32 # variant_fragment_shader is derived from the following GLSL:
33 # #version 310 es
34 # precision highp float;
35 #
36 # layout(location = 0) out vec4 _GLF_color;
37 #
38 # layout(set = 0, binding = 0) uniform buf0
39 # {
40 #     float one;
41 # };
42 #
43 # mat4 m44;
44 #
45 # void main()
46 # {
47 #     m44 = mat4(
48 #          1.0,  2.0,  3.0,  4.0,
49 #          5.0,  6.0,  7.0,  8.0,
50 #          9.0, 10.0, 11.0, 12.0,
51 #         13.0, 14.0, 15.0, 16.0
52 #     );
53 #
54 #     for (
55 #         int c = 0;
56 #         c < 4;
57 #         c++)
58 #     {
59 #         // Always false.
60 #         if (gl_FragCoord.y < 0.0)
61 #         {
62 #             break;
63 #         }
64 #
65 #         for (
66 #             int r = 0;
67 #             r < 4;
68 #             r++)
69 #         {
70 #             m44[c][r] += one;
71 #         }
72 #     }
73 #
74 #     // Red:
75 #     // vec4(1.0, 0.0, 0.0, 1.0)
76 #     vec4 c = vec4(0.0);
77 #     c.x += m44[1][1] -  6.0;  // += 1.0
78 #     c.w += m44[2][2] - 11.0;  // += 1.0
79 #     _GLF_color = c;
80 # }
81 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
82 ; SPIR-V
83 ; Version: 1.0
84 ; Generator: Khronos Glslang Reference Front End; 8
85 ; Bound: 117
86 ; Schema: 0
87                OpCapability Shader
88           %1 = OpExtInstImport "GLSL.std.450"
89                OpMemoryModel Logical GLSL450
90                OpEntryPoint Fragment %4 "main" %46 %106
91                OpExecutionMode %4 OriginUpperLeft
92                OpSource ESSL 310
93                OpName %4 "main"
94                OpName %10 "m44"
95                OpName %46 "gl_FragCoord"
96                OpName %67 "buf0"
97                OpMemberName %67 0 "one"
98                OpName %69 ""
99                OpName %106 "_GLF_color"
100                OpDecorate %46 BuiltIn FragCoord
101                OpMemberDecorate %67 0 Offset 0
102                OpDecorate %67 Block
103                OpDecorate %69 DescriptorSet 0
104                OpDecorate %69 Binding 0
105                OpDecorate %80 RelaxedPrecision
106                OpDecorate %82 RelaxedPrecision
107                OpDecorate %106 Location 0
108                OpDecorate %115 RelaxedPrecision
109                OpDecorate %116 RelaxedPrecision
110           %2 = OpTypeVoid
111           %3 = OpTypeFunction %2
112           %6 = OpTypeFloat 32
113           %7 = OpTypeVector %6 4
114           %8 = OpTypeMatrix %7 4
115          %11 = OpConstant %6 1
116          %12 = OpConstant %6 2
117          %13 = OpConstant %6 3
118          %14 = OpConstant %6 4
119          %15 = OpConstantComposite %7 %11 %12 %13 %14
120          %16 = OpConstant %6 5
121          %17 = OpConstant %6 6
122          %18 = OpConstant %6 7
123          %19 = OpConstant %6 8
124          %20 = OpConstantComposite %7 %16 %17 %18 %19
125          %21 = OpConstant %6 9
126          %22 = OpConstant %6 10
127          %23 = OpConstant %6 11
128          %24 = OpConstant %6 12
129          %25 = OpConstantComposite %7 %21 %22 %23 %24
130          %26 = OpConstant %6 13
131          %27 = OpConstant %6 14
132          %28 = OpConstant %6 15
133          %29 = OpConstant %6 16
134          %30 = OpConstantComposite %7 %26 %27 %28 %29
135          %31 = OpConstantComposite %8 %15 %20 %25 %30
136          %32 = OpTypeInt 32 1
137          %35 = OpConstant %32 0
138          %42 = OpConstant %32 4
139          %43 = OpTypeBool
140          %45 = OpTypePointer Input %7
141          %46 = OpVariable %45 Input
142          %47 = OpTypeInt 32 0
143          %48 = OpConstant %47 1
144          %49 = OpTypePointer Input %6
145          %52 = OpConstant %6 0
146          %67 = OpTypeStruct %6
147          %68 = OpTypePointer Uniform %67
148          %69 = OpVariable %68 Uniform
149          %70 = OpTypePointer Uniform %6
150          %79 = OpConstant %32 1
151          %85 = OpConstantComposite %7 %52 %52 %52 %52
152          %90 = OpTypePointer Function %6
153          %95 = OpConstant %32 2
154          %96 = OpConstant %47 2
155         %105 = OpTypePointer Output %7
156         %106 = OpVariable %105 Output
157         %108 = OpTypePointer Function %8
158           %4 = OpFunction %2 None %3
159           %5 = OpLabel
160          %10 = OpVariable %108 Function
161                OpStore %10 %31
162                OpBranch %36
163          %36 = OpLabel
164         %115 = OpPhi %32 %35 %5 %82 %39
165          %44 = OpSLessThan %43 %115 %42
166                OpLoopMerge %38 %39 None
167                OpBranchConditional %44 %37 %38
168          %37 = OpLabel
169          %50 = OpAccessChain %49 %46 %48
170          %51 = OpLoad %6 %50
171          %53 = OpFOrdLessThan %43 %51 %52
172                OpSelectionMerge %55 None
173                OpBranchConditional %53 %54 %55
174          %54 = OpLabel
175                OpBranch %38
176          %55 = OpLabel
177                OpBranch %58
178          %58 = OpLabel
179         %116 = OpPhi %32 %35 %55 %80 %59
180          %64 = OpSLessThan %43 %116 %42
181                OpLoopMerge %60 %59 None
182                OpBranchConditional %64 %59 %60
183          %59 = OpLabel
184          %71 = OpAccessChain %70 %69 %35
185          %72 = OpLoad %6 %71
186          %74 = OpAccessChain %90 %10 %115 %116
187          %75 = OpLoad %6 %74
188          %76 = OpFAdd %6 %75 %72
189                OpStore %74 %76
190          %80 = OpIAdd %32 %116 %79
191                OpBranch %58
192          %60 = OpLabel
193                OpBranch %39
194          %39 = OpLabel
195          %82 = OpIAdd %32 %115 %79
196                OpBranch %36
197          %38 = OpLabel
198          %86 = OpAccessChain %90 %10 %79 %48
199          %87 = OpLoad %6 %86
200          %88 = OpFSub %6 %87 %17
201         %111 = OpCompositeInsert %7 %88 %85 0
202          %97 = OpAccessChain %90 %10 %95 %96
203          %98 = OpLoad %6 %97
204          %99 = OpFSub %6 %98 %23
205         %114 = OpCompositeInsert %7 %99 %111 3
206                OpStore %106 %114
207                OpReturn
208                OpFunctionEnd
209 END
210
211 # uniforms for variant
212
213 # one
214 BUFFER variant_one DATA_TYPE float DATA
215  1.0
216 END
217
218 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
219
220 PIPELINE graphics variant_pipeline
221   ATTACH variant_vertex_shader
222   ATTACH variant_fragment_shader
223   FRAMEBUFFER_SIZE 16 16
224   BIND BUFFER variant_framebuffer AS color LOCATION 0
225   BIND BUFFER variant_one AS uniform DESCRIPTOR_SET 0 BINDING 0
226 END
227 CLEAR_COLOR variant_pipeline 0 0 0 255
228
229 CLEAR variant_pipeline
230 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 16 16
231
232 EXPECT variant_framebuffer IDX 0 0 SIZE 16 16 EQ_RGBA 255 0 0 255