Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / cov-missing-return-value-function-never-called.amber
1 #!amber
2
3 # Copyright 2021 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 specific BRW code paths
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 320 es
28 #
29 # #define _int_0 _GLF_uniform_int_values[0]
30 #
31 # precision highp int;
32 # precision highp float;
33 #
34 # // Contents of _GLF_uniform_int_values: 0
35 # layout(set = 0, binding = 0) uniform buf0
36 # {
37 #     int _GLF_uniform_int_values[1];
38 # };
39 #
40 # // Contents of one: 1
41 # layout(set = 0, binding = 1) uniform buf1
42 # {
43 #     uint one;
44 # };
45 #
46 # layout(location = 0) out vec4 _GLF_color;
47 #
48 # // Function is missing return value at the end,
49 # // but this function is never called.
50 # float func()
51 # {
52 #     switch(1)
53 #     {
54 #         case 0:
55 #             return 1.0;
56 #     }
57 # }
58 #
59 # void main()
60 # {
61 #     vec4 v = vec4(1.0);
62 #
63 #     // Always false.
64 #     if (gl_FragCoord.y < 0.0)
65 #     {
66 #         v = vec4(func());
67 #     }
68 #
69 #     // Always false.
70 #     if (packUnorm4x8(v) == 1u)
71 #     {
72 #         return;
73 #     }
74 #
75 #     // Always true.
76 #     if ((1u << one) == 2u)
77 #     {
78 #         _GLF_color = vec4(1, 0, 0, 1);
79 #     }
80 #     else
81 #     {
82 #         _GLF_color = vec4(_int_0);
83 #     }
84 # }
85 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
86 ; SPIR-V
87 ; Version: 1.0
88 ; Generator: Khronos Glslang Reference Front End; 10
89 ; Bound: 67
90 ; Schema: 0
91                OpCapability Shader
92           %1 = OpExtInstImport "GLSL.std.450"
93                OpMemoryModel Logical GLSL450
94                OpEntryPoint Fragment %4 "main" %23 %55
95                OpExecutionMode %4 OriginUpperLeft
96                OpSource ESSL 320
97                OpName %4 "main"
98                OpName %8 "func("
99                OpName %20 "v"
100                OpName %23 "gl_FragCoord"
101                OpName %42 "buf1"
102                OpMemberName %42 0 "one"
103                OpName %44 ""
104                OpName %55 "_GLF_color"
105                OpName %59 "buf0"
106                OpMemberName %59 0 "_GLF_uniform_int_values"
107                OpName %61 ""
108                OpDecorate %23 BuiltIn FragCoord
109                OpMemberDecorate %42 0 Offset 0
110                OpDecorate %42 Block
111                OpDecorate %44 DescriptorSet 0
112                OpDecorate %44 Binding 1
113                OpDecorate %55 Location 0
114                OpDecorate %58 ArrayStride 16
115                OpMemberDecorate %59 0 Offset 0
116                OpDecorate %59 Block
117                OpDecorate %61 DescriptorSet 0
118                OpDecorate %61 Binding 0
119           %2 = OpTypeVoid
120           %3 = OpTypeFunction %2
121           %6 = OpTypeFloat 32
122           %7 = OpTypeFunction %6
123          %10 = OpTypeInt 32 1
124          %11 = OpConstant %10 1
125          %14 = OpConstant %6 1
126          %18 = OpTypeVector %6 4
127          %19 = OpTypePointer Function %18
128          %21 = OpConstantComposite %18 %14 %14 %14 %14
129          %22 = OpTypePointer Input %18
130          %23 = OpVariable %22 Input
131          %24 = OpTypeInt 32 0
132          %25 = OpConstant %24 1
133          %26 = OpTypePointer Input %6
134          %29 = OpConstant %6 0
135          %30 = OpTypeBool
136          %42 = OpTypeStruct %24
137          %43 = OpTypePointer Uniform %42
138          %44 = OpVariable %43 Uniform
139          %45 = OpConstant %10 0
140          %46 = OpTypePointer Uniform %24
141          %50 = OpConstant %24 2
142          %54 = OpTypePointer Output %18
143          %55 = OpVariable %54 Output
144          %56 = OpConstantComposite %18 %14 %29 %29 %14
145          %58 = OpTypeArray %10 %25
146          %59 = OpTypeStruct %58
147          %60 = OpTypePointer Uniform %59
148          %61 = OpVariable %60 Uniform
149          %62 = OpTypePointer Uniform %10
150           %4 = OpFunction %2 None %3
151           %5 = OpLabel
152          %20 = OpVariable %19 Function
153                OpStore %20 %21
154          %27 = OpAccessChain %26 %23 %25
155          %28 = OpLoad %6 %27
156          %31 = OpFOrdLessThan %30 %28 %29
157                OpSelectionMerge %33 None
158                OpBranchConditional %31 %32 %33
159          %32 = OpLabel
160          %34 = OpFunctionCall %6 %8
161          %35 = OpCompositeConstruct %18 %34 %34 %34 %34
162                OpStore %20 %35
163                OpBranch %33
164          %33 = OpLabel
165          %36 = OpLoad %18 %20
166          %37 = OpExtInst %24 %1 PackUnorm4x8 %36
167          %38 = OpIEqual %30 %37 %25
168                OpSelectionMerge %40 None
169                OpBranchConditional %38 %39 %40
170          %39 = OpLabel
171                OpReturn
172          %40 = OpLabel
173          %47 = OpAccessChain %46 %44 %45
174          %48 = OpLoad %24 %47
175          %49 = OpShiftLeftLogical %24 %25 %48
176          %51 = OpIEqual %30 %49 %50
177                OpSelectionMerge %53 None
178                OpBranchConditional %51 %52 %57
179          %52 = OpLabel
180                OpStore %55 %56
181                OpBranch %53
182          %57 = OpLabel
183          %63 = OpAccessChain %62 %61 %45 %45
184          %64 = OpLoad %10 %63
185          %65 = OpConvertSToF %6 %64
186          %66 = OpCompositeConstruct %18 %65 %65 %65 %65
187                OpStore %55 %66
188                OpBranch %53
189          %53 = OpLabel
190                OpReturn
191                OpFunctionEnd
192           %8 = OpFunction %6 None %7
193           %9 = OpLabel
194                OpSelectionMerge %13 None
195                OpSwitch %11 %13 0 %12
196          %12 = OpLabel
197                OpReturnValue %14
198          %13 = OpLabel
199          %17 = OpUndef %6
200                OpReturnValue %17
201                OpFunctionEnd
202 END
203
204 # uniforms for variant
205
206 # one
207 BUFFER variant_one DATA_TYPE uint32 STD140 DATA
208  1
209 END
210 # _GLF_uniform_int_values
211 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
212  0
213 END
214
215 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
216
217 PIPELINE graphics variant_pipeline
218   ATTACH variant_vertex_shader
219   ATTACH variant_fragment_shader
220   FRAMEBUFFER_SIZE 256 256
221   BIND BUFFER variant_framebuffer AS color LOCATION 0
222   BIND BUFFER variant_one AS uniform DESCRIPTOR_SET 0 BINDING 1
223   BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
224 END
225 CLEAR_COLOR variant_pipeline 0 0 0 255
226
227 CLEAR variant_pipeline
228 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
229
230 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255