Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / returned-boolean-in-vector.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 returned boolean in vector
21
22 # The test passes because the shader always writes the color red.
23
24 # Optimized using spirv-opt with the following arguments:
25 # '--eliminate-dead-branches'
26 # '--merge-return'
27 # '--inline-entry-points-exhaustive'
28 # '--vector-dce'
29 # '--simplify-instructions'
30 # '--eliminate-dead-branches'
31 # '--vector-dce'
32 # '--eliminate-dead-code-aggressive'
33 # '--scalar-replacement=100'
34 # '--eliminate-dead-branches'
35 # '--reduce-load-size'
36 # '--eliminate-local-multi-store'
37 # '--ccp'
38 # spirv-opt commit hash: ad7f2c5c4c7f51360e9e079109a9217aa5ba5cc0
39
40
41
42 SHADER vertex variant_vertex_shader PASSTHROUGH
43
44 # variant_fragment_shader is derived from the following GLSL:
45 # #version 310 es
46 # precision highp float;
47 #
48 # layout(location = 0) out vec4 _GLF_color;
49 #
50 # layout(set = 0, binding = 0) uniform buf0
51 # {
52 #   vec2 injectionSwitch;
53 # };
54 #
55 # bool puzzlelize()
56 # {
57 #   for (int i = 0; i < 1; i++)
58 #   {
59 #     return true;
60 #   }
61 # }
62 # void main()
63 # {
64 #   vec2 uv;
65 #   vec3 color;
66 #
67 #   do
68 #   {
69 #     if (injectionSwitch.y < 0.0)
70 #     {
71 #       color = vec3(1.0);
72 #     }
73 #   } while (false);
74 #   _GLF_color = vec4(color, 1.0) + vec4(puzzlelize());
75 #
76 #   _GLF_color = vec4(1.0, 0.0, 0.0, 1.0);
77 # }
78 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
79 ; SPIR-V
80 ; Version: 1.0
81 ; Generator: Khronos Glslang Reference Front End; 7
82 ; Bound: 108
83 ; Schema: 0
84                OpCapability Shader
85           %1 = OpExtInstImport "GLSL.std.450"
86                OpMemoryModel Logical GLSL450
87                OpEntryPoint Fragment %4 "main" %53
88                OpExecutionMode %4 OriginUpperLeft
89                OpSource ESSL 310
90                OpName %4 "main"
91                OpName %33 "buf0"
92                OpMemberName %33 0 "injectionSwitch"
93                OpName %35 ""
94                OpName %47 "color"
95                OpName %53 "_GLF_color"
96                OpMemberDecorate %33 0 Offset 0
97                OpDecorate %33 Block
98                OpDecorate %35 DescriptorSet 0
99                OpDecorate %35 Binding 0
100                OpDecorate %53 Location 0
101                OpDecorate %76 RelaxedPrecision
102           %2 = OpTypeVoid
103           %3 = OpTypeFunction %2
104           %6 = OpTypeBool
105          %10 = OpTypeInt 32 1
106          %11 = OpTypePointer Function %10
107          %13 = OpConstant %10 0
108          %20 = OpConstant %10 1
109          %22 = OpConstantTrue %6
110          %31 = OpTypeFloat 32
111          %32 = OpTypeVector %31 2
112          %33 = OpTypeStruct %32
113          %34 = OpTypePointer Uniform %33
114          %35 = OpVariable %34 Uniform
115          %36 = OpTypeInt 32 0
116          %37 = OpConstant %36 1
117          %38 = OpTypePointer Uniform %31
118          %41 = OpConstant %31 0
119          %45 = OpTypeVector %31 3
120          %46 = OpTypePointer Function %45
121          %48 = OpConstant %31 1
122          %49 = OpConstantComposite %45 %48 %48 %48
123          %50 = OpConstantFalse %6
124          %51 = OpTypeVector %31 4
125          %52 = OpTypePointer Output %51
126          %53 = OpVariable %52 Output
127          %63 = OpConstantComposite %51 %48 %41 %41 %48
128          %65 = OpTypePointer Function %6
129          %95 = OpUndef %45
130         %106 = OpUndef %6
131         %107 = OpUndef %10
132           %4 = OpFunction %2 None %3
133           %5 = OpLabel
134          %74 = OpVariable %65 Function %50
135          %75 = OpVariable %65 Function
136          %76 = OpVariable %11 Function
137          %77 = OpVariable %65 Function
138          %47 = OpVariable %46 Function
139                OpBranch %27
140          %27 = OpLabel
141         %105 = OpPhi %6 %106 %5 %105 %30
142          %94 = OpPhi %45 %95 %5 %93 %30
143                OpLoopMerge %29 %30 None
144                OpBranch %28
145          %28 = OpLabel
146          %39 = OpAccessChain %38 %35 %13 %37
147          %40 = OpLoad %31 %39
148          %42 = OpFOrdLessThan %6 %40 %41
149                OpSelectionMerge %44 None
150                OpBranchConditional %42 %43 %44
151          %43 = OpLabel
152                OpStore %47 %49
153                OpBranch %44
154          %44 = OpLabel
155          %93 = OpPhi %45 %94 %28 %49 %43
156                OpBranch %30
157          %30 = OpLabel
158                OpBranchConditional %50 %27 %29
159          %29 = OpLabel
160          %55 = OpCompositeExtract %31 %93 0
161          %56 = OpCompositeExtract %31 %93 1
162          %57 = OpCompositeExtract %31 %93 2
163          %58 = OpCompositeConstruct %51 %55 %56 %57 %48
164                OpStore %74 %50
165                OpBranch %78
166          %78 = OpLabel
167         %103 = OpPhi %6 %105 %29 %106 %80
168          %99 = OpPhi %6 %50 %29 %106 %80
169                OpLoopMerge %79 %80 None
170                OpBranch %81
171          %81 = OpLabel
172                OpStore %76 %13
173                OpBranch %82
174          %82 = OpLabel
175         %102 = OpPhi %6 %103 %81 %106 %84
176          %98 = OpPhi %6 %50 %81 %106 %84
177          %96 = OpPhi %10 %13 %81 %107 %84
178                OpLoopMerge %83 %84 None
179                OpBranch %85
180          %85 = OpLabel
181          %87 = OpSLessThan %6 %13 %20
182                OpBranchConditional %22 %88 %83
183          %88 = OpLabel
184                OpStore %74 %22
185                OpStore %75 %22
186                OpBranch %83
187          %84 = OpLabel
188                OpBranch %82
189          %83 = OpLabel
190         %101 = OpPhi %6 %102 %85 %22 %88
191          %97 = OpPhi %6 %50 %85 %22 %88
192                OpSelectionMerge %90 None
193                OpBranchConditional %22 %79 %90
194          %90 = OpLabel
195                OpStore %74 %22
196                OpBranch %79
197          %80 = OpLabel
198                OpBranch %78
199          %79 = OpLabel
200                OpStore %77 %22
201          %60 = OpSelect %31 %22 %48 %41
202          %61 = OpCompositeConstruct %51 %60 %60 %60 %60
203          %62 = OpFAdd %51 %58 %61
204                OpStore %53 %62
205                OpStore %53 %63
206                OpReturn
207                OpFunctionEnd
208 END
209
210 # uniforms for variant
211
212 # injectionSwitch
213 BUFFER variant_injectionSwitch DATA_TYPE vec2<float> 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