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