Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / switch-inside-while-always-return.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 a switch inside while always return
21
22 # The test passes because main always writes the color red.
23
24 SHADER vertex variant_vertex_shader PASSTHROUGH
25
26 # variant_fragment_shader is derived from the following GLSL:
27 # #version 310 es
28 # precision highp float;
29 #
30 # layout(location = 0) out vec4 _GLF_color;
31 #
32 # layout(set = 0, binding = 0) uniform buf0
33 # {
34 #   float zero;
35 # };
36 #
37 # int merge()
38 # {
39 #   if (zero < 0.0)
40 #   {
41 #     return 0;
42 #   }
43 # }
44 #
45 # void main()
46 # {
47 #   _GLF_color = vec4(1, 0, 0, 1);
48 #   do
49 #   {
50 #     switch (int(zero))
51 #     {
52 #     case 0:
53 #       return; // We always end up here
54 #     }
55 #   } while (false);
56 #
57 #   int res = merge();
58 #   _GLF_color = vec4(int(res));
59 # }
60 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
61 ; SPIR-V
62 ; Version: 1.0
63 ; Generator: Khronos Glslang Reference Front End; 8
64 ; Bound: 48
65 ; Schema: 0
66                OpCapability Shader
67           %1 = OpExtInstImport "GLSL.std.450"
68                OpMemoryModel Logical GLSL450
69                OpEntryPoint Fragment %4 "main" %27
70                OpExecutionMode %4 OriginUpperLeft
71                OpSource ESSL 310
72                OpName %4 "main"
73                OpName %8 "merge("
74                OpName %11 "buf0"
75                OpMemberName %11 0 "zero"
76                OpName %13 ""
77                OpName %27 "_GLF_color"
78                OpName %43 "res"
79                OpDecorate %8 RelaxedPrecision
80                OpMemberDecorate %11 0 Offset 0
81                OpDecorate %11 Block
82                OpDecorate %13 DescriptorSet 0
83                OpDecorate %13 Binding 0
84                OpDecorate %27 Location 0
85                OpDecorate %43 RelaxedPrecision
86                OpDecorate %44 RelaxedPrecision
87                OpDecorate %45 RelaxedPrecision
88           %2 = OpTypeVoid
89           %3 = OpTypeFunction %2
90           %6 = OpTypeInt 32 1
91           %7 = OpTypeFunction %6
92          %10 = OpTypeFloat 32
93          %11 = OpTypeStruct %10
94          %12 = OpTypePointer Uniform %11
95          %13 = OpVariable %12 Uniform
96          %14 = OpConstant %6 0
97          %15 = OpTypePointer Uniform %10
98          %18 = OpConstant %10 0
99          %19 = OpTypeBool
100          %25 = OpTypeVector %10 4
101          %26 = OpTypePointer Output %25
102          %27 = OpVariable %26 Output
103          %28 = OpConstant %10 1
104          %29 = OpConstantComposite %25 %28 %18 %18 %28
105          %41 = OpConstantFalse %19
106          %42 = OpTypePointer Function %6
107           %4 = OpFunction %2 None %3
108           %5 = OpLabel
109          %43 = OpVariable %42 Function
110                OpStore %27 %29
111                OpBranch %30
112          %30 = OpLabel
113                OpLoopMerge %32 %33 None
114                OpBranch %31
115          %31 = OpLabel
116          %34 = OpAccessChain %15 %13 %14
117          %35 = OpLoad %10 %34
118          %36 = OpConvertFToS %6 %35
119                OpSelectionMerge %38 None
120                OpSwitch %36 %38 0 %37
121          %37 = OpLabel
122                OpReturn
123          %38 = OpLabel
124                OpBranch %33
125          %33 = OpLabel
126                OpBranchConditional %41 %30 %32
127          %32 = OpLabel
128          %44 = OpFunctionCall %6 %8
129                OpStore %43 %44
130          %45 = OpLoad %6 %43
131          %46 = OpConvertSToF %10 %45
132          %47 = OpCompositeConstruct %25 %46 %46 %46 %46
133                OpStore %27 %47
134                OpReturn
135                OpFunctionEnd
136           %8 = OpFunction %6 None %7
137           %9 = OpLabel
138          %16 = OpAccessChain %15 %13 %14
139          %17 = OpLoad %10 %16
140          %20 = OpFOrdLessThan %19 %17 %18
141                OpSelectionMerge %22 None
142                OpBranchConditional %20 %21 %22
143          %21 = OpLabel
144                OpReturnValue %14
145          %22 = OpLabel
146          %24 = OpUndef %6
147                OpReturnValue %24
148                OpFunctionEnd
149 END
150
151 # uniforms for variant
152
153 # zero
154 BUFFER variant_zero DATA_TYPE float DATA
155  0.0
156 END
157
158 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
159
160 PIPELINE graphics variant_pipeline
161   ATTACH variant_vertex_shader
162   ATTACH variant_fragment_shader
163   FRAMEBUFFER_SIZE 256 256
164   BIND BUFFER variant_framebuffer AS color LOCATION 0
165   BIND BUFFER variant_zero AS uniform DESCRIPTOR_SET 0 BINDING 0
166 END
167 CLEAR_COLOR variant_pipeline 0 0 0 255
168
169 CLEAR variant_pipeline
170 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
171
172 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255