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