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