Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / cov-if-switch-fallthrough.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 coverage-gap found by the GraphicsFuzz project.
19
20 # Short description: A fragment shader that covers a specific inst combine and or xor code path
21
22 # The test passes because the shader always writes red.
23
24 # Optimized using spirv-opt with the following arguments:
25 # '-O'
26 # spirv-opt commit hash: a187dd58a0485988841d325a85c8e6063f53500a
27
28
29
30 SHADER vertex variant_vertex_shader PASSTHROUGH
31
32 # variant_fragment_shader is derived from the following GLSL:
33 # #version 310 es
34 # #define _int_1 _GLF_uniform_int_values[0]
35 # #define _int_0 _GLF_uniform_int_values[1]
36 # #define _float_0_0 _GLF_uniform_float_values[0]
37 # #define _float_1_0 _GLF_uniform_float_values[1]
38 #
39 # precision highp int;
40 #
41 # precision highp float;
42 #
43 # // Contents of _GLF_uniform_float_values: [0.0, 1.0]
44 # layout(set = 0, binding = 0) uniform buf0
45 # {
46 #     float _GLF_uniform_float_values[2];
47 # };
48 #
49 # // Contents of _GLF_uniform_int_values: [1, 0]
50 # layout(set = 0, binding = 1) uniform buf1
51 # {
52 #     int _GLF_uniform_int_values[2];
53 # };
54 #
55 # layout(location = 0) out vec4 _GLF_color;
56 #
57 # void main()
58 # {
59 #     _GLF_color = vec4(_float_1_0);
60 #
61 #     // Always true.
62 #     if (gl_FragCoord.y >= _float_0_0)
63 #     {
64 #         switch (_int_0)
65 #         {
66 #             case 16:
67 #             case 0:
68 #                 _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
69 #         }
70 #     }
71 #
72 #     // Always false.
73 #     if (_int_0 == _int_1)
74 #     {
75 #         _GLF_color = vec4(_float_0_0);
76 #     }
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; 10
82 ; Bound: 68
83 ; Schema: 0
84                OpCapability Shader
85           %1 = OpExtInstImport "GLSL.std.450"
86                OpMemoryModel Logical GLSL450
87                OpEntryPoint Fragment %4 "main" %9 %24
88                OpExecutionMode %4 OriginUpperLeft
89                OpSource ESSL 310
90                OpName %4 "main"
91                OpName %9 "_GLF_color"
92                OpName %13 "buf0"
93                OpMemberName %13 0 "_GLF_uniform_float_values"
94                OpName %15 ""
95                OpName %24 "gl_FragCoord"
96                OpName %36 "buf1"
97                OpMemberName %36 0 "_GLF_uniform_int_values"
98                OpName %38 ""
99                OpDecorate %9 Location 0
100                OpDecorate %12 ArrayStride 16
101                OpMemberDecorate %13 0 Offset 0
102                OpDecorate %13 Block
103                OpDecorate %15 DescriptorSet 0
104                OpDecorate %15 Binding 0
105                OpDecorate %24 BuiltIn FragCoord
106                OpDecorate %35 ArrayStride 16
107                OpMemberDecorate %36 0 Offset 0
108                OpDecorate %36 Block
109                OpDecorate %38 DescriptorSet 0
110                OpDecorate %38 Binding 1
111           %2 = OpTypeVoid
112           %3 = OpTypeFunction %2
113           %6 = OpTypeFloat 32
114           %7 = OpTypeVector %6 4
115           %8 = OpTypePointer Output %7
116           %9 = OpVariable %8 Output
117          %10 = OpTypeInt 32 0
118          %11 = OpConstant %10 2
119          %12 = OpTypeArray %6 %11
120          %13 = OpTypeStruct %12
121          %14 = OpTypePointer Uniform %13
122          %15 = OpVariable %14 Uniform
123          %16 = OpTypeInt 32 1
124          %17 = OpConstant %16 0
125          %18 = OpConstant %16 1
126          %19 = OpTypePointer Uniform %6
127          %23 = OpTypePointer Input %7
128          %24 = OpVariable %23 Input
129          %25 = OpConstant %10 1
130          %26 = OpTypePointer Input %6
131          %31 = OpTypeBool
132          %35 = OpTypeArray %16 %11
133          %36 = OpTypeStruct %35
134          %37 = OpTypePointer Uniform %36
135          %38 = OpVariable %37 Uniform
136          %39 = OpTypePointer Uniform %16
137           %4 = OpFunction %2 None %3
138           %5 = OpLabel
139          %20 = OpAccessChain %19 %15 %17 %18
140          %21 = OpLoad %6 %20
141          %22 = OpCompositeConstruct %7 %21 %21 %21 %21
142                OpStore %9 %22
143          %27 = OpAccessChain %26 %24 %25
144          %28 = OpLoad %6 %27
145          %29 = OpAccessChain %19 %15 %17 %17
146          %30 = OpLoad %6 %29
147          %32 = OpFOrdGreaterThanEqual %31 %28 %30
148                OpSelectionMerge %34 None
149                OpBranchConditional %32 %33 %34
150          %33 = OpLabel
151          %40 = OpAccessChain %39 %38 %17 %18
152          %41 = OpLoad %16 %40
153                OpSelectionMerge %43 None
154                OpSwitch %41 %43 16 %42 0 %42
155          %42 = OpLabel
156          %44 = OpAccessChain %39 %38 %17 %17
157          %45 = OpLoad %16 %44
158          %46 = OpConvertSToF %6 %45
159          %49 = OpConvertSToF %6 %41
160          %56 = OpCompositeConstruct %7 %46 %49 %49 %46
161                OpStore %9 %56
162                OpBranch %43
163          %43 = OpLabel
164                OpBranch %34
165          %34 = OpLabel
166          %58 = OpAccessChain %39 %38 %17 %18
167          %59 = OpLoad %16 %58
168          %60 = OpAccessChain %39 %38 %17 %17
169          %61 = OpLoad %16 %60
170          %62 = OpIEqual %31 %59 %61
171                OpSelectionMerge %64 None
172                OpBranchConditional %62 %63 %64
173          %63 = OpLabel
174          %67 = OpCompositeConstruct %7 %30 %30 %30 %30
175                OpStore %9 %67
176                OpBranch %64
177          %64 = OpLabel
178                OpReturn
179                OpFunctionEnd
180 END
181
182 # uniforms for variant
183
184 # _GLF_uniform_int_values
185 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
186  1 0
187 END
188 # _GLF_uniform_float_values
189 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
190  0.0 1.0
191 END
192
193 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
194
195 PIPELINE graphics variant_pipeline
196   ATTACH variant_vertex_shader
197   ATTACH variant_fragment_shader
198   FRAMEBUFFER_SIZE 256 256
199   BIND BUFFER variant_framebuffer AS color LOCATION 0
200   BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
201   BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
202 END
203 CLEAR_COLOR variant_pipeline 0 0 0 255
204
205 CLEAR variant_pipeline
206 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
207
208 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255