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