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