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