Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / nested-loops-switch.amber
1 #!amber
2
3 # Copyright 2019 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 nested loops and a switch
21
22 # The test passes because the fragment shader enters the outer loop, immediately breaks, and
23 # writes the color red.
24
25 SHADER vertex variant_vertex_shader PASSTHROUGH
26
27 # variant_fragment_shader is derived from the following GLSL:
28 # #version 310 es
29 # precision highp float;
30 # precision highp int;
31 #
32 # layout(location = 0) out vec4 _GLF_color;
33 #
34 # layout(set = 0, binding = 0) uniform buf0
35 # {
36 #   vec2 injectionSwitch;
37 # };
38 # void main()
39 # {
40 #   int msb10;
41 #   int i = 0;
42 #   do
43 #   {
44 #     if (i >= int(injectionSwitch.x)) // always true
45 #     {
46 #       break;
47 #     }
48 #     if (0.0 > injectionSwitch.y)
49 #     {
50 #       float donor_replacementGLF_dead5sums[9];
51 #       for (
52 #           int GLF_dead5cols = 2;
53 #           GLF_dead5cols <= 4;
54 #           GLF_dead5cols++)
55 #       {
56 #         for (
57 #             int GLF_dead5rows = 2;
58 #             GLF_dead5rows <= 4;
59 #             GLF_dead5rows++)
60 #         {
61 #           for (
62 #               int GLF_dead5c = 0;
63 #               GLF_dead5c < GLF_dead5cols;
64 #               GLF_dead5c++)
65 #           {
66 #             for (
67 #                 int GLF_dead5r = 0;
68 #                 GLF_dead5r < GLF_dead5rows;
69 #                 GLF_dead5r++)
70 #             {
71 #               switch (msb10)
72 #               {
73 #               case 1:
74 #               case 8:
75 #                 donor_replacementGLF_dead5sums[msb10 >= 0 && msb10 < 9 ? msb10 : 0] += 1.0;
76 #               }
77 #             }
78 #           }
79 #           msb10++;
80 #         }
81 #       }
82 #     }
83 #     i++;
84 #   } while (i < 200);
85 #   _GLF_color = vec4(1.0, 0.0, 0.0, 1.0);
86 # }
87 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
88 ; SPIR-V
89 ; Version: 1.0
90 ; Generator: Khronos Glslang Reference Front End; 7
91 ; Bound: 117
92 ; Schema: 0
93                OpCapability Shader
94           %1 = OpExtInstImport "GLSL.std.450"
95                OpMemoryModel Logical GLSL450
96                OpEntryPoint Fragment %4 "main" %115
97                OpExecutionMode %4 OriginUpperLeft
98                OpSource ESSL 310
99                OpName %4 "main"
100                OpName %8 "i"
101                OpName %17 "buf0"
102                OpMemberName %17 0 "injectionSwitch"
103                OpName %19 ""
104                OpName %38 "GLF_dead5cols"
105                OpName %48 "GLF_dead5rows"
106                OpName %56 "GLF_dead5c"
107                OpName %65 "GLF_dead5r"
108                OpName %74 "msb10"
109                OpName %81 "donor_replacementGLF_dead5sums"
110                OpName %115 "_GLF_color"
111                OpMemberDecorate %17 0 Offset 0
112                OpDecorate %17 Block
113                OpDecorate %19 DescriptorSet 0
114                OpDecorate %19 Binding 0
115                OpDecorate %115 Location 0
116           %2 = OpTypeVoid
117           %3 = OpTypeFunction %2
118           %6 = OpTypeInt 32 1
119           %7 = OpTypePointer Function %6
120           %9 = OpConstant %6 0
121          %15 = OpTypeFloat 32
122          %16 = OpTypeVector %15 2
123          %17 = OpTypeStruct %16
124          %18 = OpTypePointer Uniform %17
125          %19 = OpVariable %18 Uniform
126          %20 = OpTypeInt 32 0
127          %21 = OpConstant %20 0
128          %22 = OpTypePointer Uniform %15
129          %26 = OpTypeBool
130          %31 = OpConstant %15 0
131          %32 = OpConstant %20 1
132          %39 = OpConstant %6 2
133          %46 = OpConstant %6 4
134          %78 = OpConstant %20 9
135          %79 = OpTypeArray %15 %78
136          %80 = OpTypePointer Function %79
137          %85 = OpConstant %6 9
138          %90 = OpConstant %15 1
139          %91 = OpTypePointer Function %15
140          %98 = OpConstant %6 1
141         %111 = OpConstant %6 200
142         %113 = OpTypeVector %15 4
143         %114 = OpTypePointer Output %113
144         %115 = OpVariable %114 Output
145         %116 = OpConstantComposite %113 %90 %31 %31 %90
146           %4 = OpFunction %2 None %3
147           %5 = OpLabel
148           %8 = OpVariable %7 Function
149          %38 = OpVariable %7 Function
150          %48 = OpVariable %7 Function
151          %56 = OpVariable %7 Function
152          %65 = OpVariable %7 Function
153          %74 = OpVariable %7 Function
154          %81 = OpVariable %80 Function
155                OpStore %8 %9
156                OpBranch %10
157          %10 = OpLabel
158                OpLoopMerge %12 %13 None
159                OpBranch %11
160          %11 = OpLabel
161          %14 = OpLoad %6 %8
162          %23 = OpAccessChain %22 %19 %9 %21
163          %24 = OpLoad %15 %23
164          %25 = OpConvertFToS %6 %24
165          %27 = OpSGreaterThanEqual %26 %14 %25
166                OpSelectionMerge %29 None
167                OpBranchConditional %27 %28 %29
168          %28 = OpLabel
169                OpBranch %12
170          %29 = OpLabel
171          %33 = OpAccessChain %22 %19 %9 %32
172          %34 = OpLoad %15 %33
173          %35 = OpFOrdGreaterThan %26 %31 %34
174                OpSelectionMerge %37 None
175                OpBranchConditional %35 %36 %37
176          %36 = OpLabel
177                OpStore %38 %39
178                OpBranch %40
179          %40 = OpLabel
180                OpLoopMerge %42 %43 None
181                OpBranch %44
182          %44 = OpLabel
183          %45 = OpLoad %6 %38
184          %47 = OpSLessThanEqual %26 %45 %46
185                OpBranchConditional %47 %41 %42
186          %41 = OpLabel
187                OpStore %48 %39
188                OpBranch %49
189          %49 = OpLabel
190                OpLoopMerge %51 %52 None
191                OpBranch %53
192          %53 = OpLabel
193          %54 = OpLoad %6 %48
194          %55 = OpSLessThanEqual %26 %54 %46
195                OpBranchConditional %55 %50 %51
196          %50 = OpLabel
197                OpStore %56 %9
198                OpBranch %57
199          %57 = OpLabel
200                OpLoopMerge %59 %60 None
201                OpBranch %61
202          %61 = OpLabel
203          %62 = OpLoad %6 %56
204          %63 = OpLoad %6 %38
205          %64 = OpSLessThan %26 %62 %63
206                OpBranchConditional %64 %58 %59
207          %58 = OpLabel
208                OpStore %65 %9
209                OpBranch %66
210          %66 = OpLabel
211                OpLoopMerge %68 %69 None
212                OpBranch %70
213          %70 = OpLabel
214          %71 = OpLoad %6 %65
215          %72 = OpLoad %6 %48
216          %73 = OpSLessThan %26 %71 %72
217                OpBranchConditional %73 %67 %68
218          %67 = OpLabel
219          %75 = OpLoad %6 %74
220                OpSelectionMerge %77 None
221                OpSwitch %75 %77 1 %76 8 %76
222          %76 = OpLabel
223          %82 = OpLoad %6 %74
224          %83 = OpSGreaterThanEqual %26 %82 %9
225          %84 = OpLoad %6 %74
226          %86 = OpSLessThan %26 %84 %85
227          %87 = OpLogicalAnd %26 %83 %86
228          %88 = OpLoad %6 %74
229          %89 = OpSelect %6 %87 %88 %9
230          %92 = OpAccessChain %91 %81 %89
231          %93 = OpLoad %15 %92
232          %94 = OpFAdd %15 %93 %90
233          %95 = OpAccessChain %91 %81 %89
234                OpStore %95 %94
235                OpBranch %77
236          %77 = OpLabel
237                OpBranch %69
238          %69 = OpLabel
239          %97 = OpLoad %6 %65
240          %99 = OpIAdd %6 %97 %98
241                OpStore %65 %99
242                OpBranch %66
243          %68 = OpLabel
244                OpBranch %60
245          %60 = OpLabel
246         %100 = OpLoad %6 %56
247         %101 = OpIAdd %6 %100 %98
248                OpStore %56 %101
249                OpBranch %57
250          %59 = OpLabel
251         %102 = OpLoad %6 %74
252         %103 = OpIAdd %6 %102 %98
253                OpStore %74 %103
254                OpBranch %52
255          %52 = OpLabel
256         %104 = OpLoad %6 %48
257         %105 = OpIAdd %6 %104 %98
258                OpStore %48 %105
259                OpBranch %49
260          %51 = OpLabel
261                OpBranch %43
262          %43 = OpLabel
263         %106 = OpLoad %6 %38
264         %107 = OpIAdd %6 %106 %98
265                OpStore %38 %107
266                OpBranch %40
267          %42 = OpLabel
268                OpBranch %37
269          %37 = OpLabel
270         %108 = OpLoad %6 %8
271         %109 = OpIAdd %6 %108 %98
272                OpStore %8 %109
273                OpBranch %13
274          %13 = OpLabel
275         %110 = OpLoad %6 %8
276         %112 = OpSLessThan %26 %110 %111
277                OpBranchConditional %112 %10 %12
278          %12 = OpLabel
279                OpStore %115 %116
280                OpReturn
281                OpFunctionEnd
282 END
283
284 # uniforms for variant
285
286 # injectionSwitch
287 BUFFER variant_injectionSwitch DATA_TYPE vec2<float> DATA
288  0.0 1.0
289 END
290
291 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
292
293 PIPELINE graphics variant_pipeline
294   ATTACH variant_vertex_shader
295   ATTACH variant_fragment_shader
296   FRAMEBUFFER_SIZE 256 256
297   BIND BUFFER variant_framebuffer AS color LOCATION 0
298   BIND BUFFER variant_injectionSwitch AS uniform DESCRIPTOR_SET 0 BINDING 0
299 END
300 CLEAR_COLOR variant_pipeline 0 0 0 255
301
302 CLEAR variant_pipeline
303 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
304
305 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255