Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / cov-and-even-numbers-from-fragcoord.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 NIR 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_0 _GLF_uniform_int_values[0]
29 # #define _int_1 _GLF_uniform_int_values[1]
30 # #define _float_0_4 _GLF_uniform_float_values[0]
31 # #define _float_1_0 _GLF_uniform_float_values[1]
32 # #define _float_256_0 _GLF_uniform_float_values[2]
33 #
34 # precision highp int;
35 # precision highp float;
36 #
37 # // Contents of _GLF_uniform_int_values: [0, 1]
38 # layout(set = 0, binding = 0) uniform buf0
39 # {
40 #     int _GLF_uniform_int_values[2];
41 # };
42 # // Contents of _GLF_uniform_float_values: [0.4, 1.0, 256.0]
43 # layout(set = 0, binding = 1) uniform buf1
44 # {
45 #     float _GLF_uniform_float_values[3];
46 # };
47 # layout(location = 0) out vec4 _GLF_color;
48 #
49 # void main()
50 # {
51 #     // Always false.
52 #     if(gl_FragCoord.y < _float_0_4)
53 #     {
54 #         _GLF_color = vec4(_int_0);
55 #     }
56 #     else
57 #     {
58 #         // gl_FragCoord has the decimal part of 0.5. If we name the integer part
59 #         // of gl_FragCoord (X, Y) it can be expressed as (X + 0.5, Y + 0.5).
60 #         //
61 #         // The value of v is calculated as follows:
62 #         // v = ((X + 0.5, Y + 0.5) - (1.0, 0.4)) * 256
63 #         //   = (X - 1 + 0.5, Y + 0.5 - 0.4) * 256
64 #         //   = (X - 0.5, Y + 0.1) * 256
65 #         //   = (X * 256 - 128, Y * 256 + 25.6)
66 #         //
67 #         // X * 256 is always an even number, and substracting 128 still keeps it even.
68 #         // Y * 256 is always and even number, but adding 25.6 (and converting to an integer)
69 #         // makes it always odd.
70 #         ivec2 v = ivec2((gl_FragCoord.xy - vec2(_float_1_0, _float_0_4)) * _float_256_0);
71 #
72 #         // v.x is even and v.y is odd. We substract one from v.y making it even too.
73 #         // Doing a bitwise AND with an even number always resuls in zero.
74 #         _GLF_color = vec4(_float_1_0, (v.y - _int_1) & _int_1, v.x & _int_1, _float_1_0);
75 #     }
76 # }
77 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
78 ; SPIR-V
79 ; Version: 1.0
80 ; Generator: Khronos Glslang Reference Front End; 10
81 ; Bound: 82
82 ; Schema: 0
83                OpCapability Shader
84           %1 = OpExtInstImport "GLSL.std.450"
85                OpMemoryModel Logical GLSL450
86                OpEntryPoint Fragment %4 "main" %9 %30
87                OpExecutionMode %4 OriginUpperLeft
88                OpSource ESSL 320
89                OpName %4 "main"
90                OpName %9 "gl_FragCoord"
91                OpName %17 "buf1"
92                OpMemberName %17 0 "_GLF_uniform_float_values"
93                OpName %19 ""
94                OpName %30 "_GLF_color"
95                OpName %33 "buf0"
96                OpMemberName %33 0 "_GLF_uniform_int_values"
97                OpName %35 ""
98                OpName %44 "v"
99                OpDecorate %9 BuiltIn FragCoord
100                OpDecorate %16 ArrayStride 16
101                OpMemberDecorate %17 0 Offset 0
102                OpDecorate %17 Block
103                OpDecorate %19 DescriptorSet 0
104                OpDecorate %19 Binding 1
105                OpDecorate %30 Location 0
106                OpDecorate %32 ArrayStride 16
107                OpMemberDecorate %33 0 Offset 0
108                OpDecorate %33 Block
109                OpDecorate %35 DescriptorSet 0
110                OpDecorate %35 Binding 0
111           %2 = OpTypeVoid
112           %3 = OpTypeFunction %2
113           %6 = OpTypeFloat 32
114           %7 = OpTypeVector %6 4
115           %8 = OpTypePointer Input %7
116           %9 = OpVariable %8 Input
117          %10 = OpTypeInt 32 0
118          %11 = OpConstant %10 1
119          %12 = OpTypePointer Input %6
120          %15 = OpConstant %10 3
121          %16 = OpTypeArray %6 %15
122          %17 = OpTypeStruct %16
123          %18 = OpTypePointer Uniform %17
124          %19 = OpVariable %18 Uniform
125          %20 = OpTypeInt 32 1
126          %21 = OpConstant %20 0
127          %22 = OpTypePointer Uniform %6
128          %25 = OpTypeBool
129          %29 = OpTypePointer Output %7
130          %30 = OpVariable %29 Output
131          %31 = OpConstant %10 2
132          %32 = OpTypeArray %20 %31
133          %33 = OpTypeStruct %32
134          %34 = OpTypePointer Uniform %33
135          %35 = OpVariable %34 Uniform
136          %36 = OpTypePointer Uniform %20
137          %42 = OpTypeVector %20 2
138          %43 = OpTypePointer Function %42
139          %45 = OpTypeVector %6 2
140          %48 = OpConstant %20 1
141          %55 = OpConstant %20 2
142          %62 = OpTypePointer Function %20
143          %72 = OpConstant %10 0
144           %4 = OpFunction %2 None %3
145           %5 = OpLabel
146          %44 = OpVariable %43 Function
147          %13 = OpAccessChain %12 %9 %11
148          %14 = OpLoad %6 %13
149          %23 = OpAccessChain %22 %19 %21 %21
150          %24 = OpLoad %6 %23
151          %26 = OpFOrdLessThan %25 %14 %24
152                OpSelectionMerge %28 None
153                OpBranchConditional %26 %27 %41
154          %27 = OpLabel
155          %37 = OpAccessChain %36 %35 %21 %21
156          %38 = OpLoad %20 %37
157          %39 = OpConvertSToF %6 %38
158          %40 = OpCompositeConstruct %7 %39 %39 %39 %39
159                OpStore %30 %40
160                OpBranch %28
161          %41 = OpLabel
162          %46 = OpLoad %7 %9
163          %47 = OpVectorShuffle %45 %46 %46 0 1
164          %49 = OpAccessChain %22 %19 %21 %48
165          %50 = OpLoad %6 %49
166          %51 = OpAccessChain %22 %19 %21 %21
167          %52 = OpLoad %6 %51
168          %53 = OpCompositeConstruct %45 %50 %52
169          %54 = OpFSub %45 %47 %53
170          %56 = OpAccessChain %22 %19 %21 %55
171          %57 = OpLoad %6 %56
172          %58 = OpVectorTimesScalar %45 %54 %57
173          %59 = OpConvertFToS %42 %58
174                OpStore %44 %59
175          %60 = OpAccessChain %22 %19 %21 %48
176          %61 = OpLoad %6 %60
177          %63 = OpAccessChain %62 %44 %11
178          %64 = OpLoad %20 %63
179          %65 = OpAccessChain %36 %35 %21 %48
180          %66 = OpLoad %20 %65
181          %67 = OpISub %20 %64 %66
182          %68 = OpAccessChain %36 %35 %21 %48
183          %69 = OpLoad %20 %68
184          %70 = OpBitwiseAnd %20 %67 %69
185          %71 = OpConvertSToF %6 %70
186          %73 = OpAccessChain %62 %44 %72
187          %74 = OpLoad %20 %73
188          %75 = OpAccessChain %36 %35 %21 %48
189          %76 = OpLoad %20 %75
190          %77 = OpBitwiseAnd %20 %74 %76
191          %78 = OpConvertSToF %6 %77
192          %79 = OpAccessChain %22 %19 %21 %48
193          %80 = OpLoad %6 %79
194          %81 = OpCompositeConstruct %7 %61 %71 %78 %80
195                OpStore %30 %81
196                OpBranch %28
197          %28 = OpLabel
198                OpReturn
199                OpFunctionEnd
200 END
201
202 # uniforms for variant
203
204 # _GLF_uniform_float_values
205 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
206  0.4 1.0 256.0
207 END
208 # _GLF_uniform_int_values
209 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
210  0 1
211 END
212
213 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
214
215 PIPELINE graphics variant_pipeline
216   ATTACH variant_vertex_shader
217   ATTACH variant_fragment_shader
218   FRAMEBUFFER_SIZE 256 256
219   BIND BUFFER variant_framebuffer AS color LOCATION 0
220   BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1
221   BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
222 END
223 CLEAR_COLOR variant_pipeline 0 0 0 255
224
225 CLEAR variant_pipeline
226 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
227
228 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255