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