Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / cov-apfloat-reflect-denorm.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 floating point code path
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 # #define _int_1 _GLF_uniform_int_values[0]
29 # #define _int_0 _GLF_uniform_int_values[1]
30 # #define _int_768 _GLF_uniform_int_values[2]
31 # #define _int_1792 _GLF_uniform_int_values[3]
32 # #define _int_45056 _GLF_uniform_int_values[4]
33 # #define _float_0_1 _GLF_uniform_float_values[0]
34 # #define _float_0_5 _GLF_uniform_float_values[1]
35 # #define _float_2_0 _GLF_uniform_float_values[2]
36 #
37 # precision highp float;
38 # precision highp int;
39 #
40 # // Contents of _GLF_uniform_int_values: [1, 0, 768, 1792, 45056]
41 # layout(set = 0, binding = 0) uniform buf0
42 # {
43 #     int _GLF_uniform_int_values[5];
44 # };
45 #
46 # // Contents of _GLF_uniform_float_values: [0.1, 0.5, 2.0]
47 # layout(set = 0, binding = 1) uniform buf1
48 # {
49 #     float _GLF_uniform_float_values[3];
50 # };
51 #
52 # layout(location = 0) out vec4 _GLF_color;
53 #
54 # void main()
55 # {
56 #     // All components of I are denormalized.
57 #     vec4 I = uintBitsToFloat(uvec4(_int_768, _int_1792, _int_45056, 0x16b39));
58 #     vec4 N = vec4(_float_0_5);
59 #
60 #     // Whether or not denormalized values are supported or flushed to zero,
61 #     // the result of "reflect" should match the reference result.
62 #     vec4 R = reflect(I, vec4(0.5));
63 #     vec4 ref = I - _float_2_0 * dot(N, I) * N;
64 #
65 #     if (distance(R, ref) < _float_0_1)
66 #     {
67 #         _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
68 #     }
69 #     else
70 #     {
71 #         _GLF_color = vec4(_int_0);
72 #     }
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; 8
78 ; Bound: 91
79 ; Schema: 0
80                OpCapability Shader
81           %1 = OpExtInstImport "GLSL.std.450"
82                OpMemoryModel Logical GLSL450
83                OpEntryPoint Fragment %4 "main" %72
84                OpExecutionMode %4 OriginUpperLeft
85                OpSource ESSL 310
86                OpName %4 "main"
87                OpName %9 "I"
88                OpName %14 "buf0"
89                OpMemberName %14 0 "_GLF_uniform_int_values"
90                OpName %16 ""
91                OpName %35 "N"
92                OpName %38 "buf1"
93                OpMemberName %38 0 "_GLF_uniform_float_values"
94                OpName %40 ""
95                OpName %46 "R"
96                OpName %51 "ref"
97                OpName %72 "_GLF_color"
98                OpDecorate %13 ArrayStride 16
99                OpMemberDecorate %14 0 Offset 0
100                OpDecorate %14 Block
101                OpDecorate %16 DescriptorSet 0
102                OpDecorate %16 Binding 0
103                OpDecorate %37 ArrayStride 16
104                OpMemberDecorate %38 0 Offset 0
105                OpDecorate %38 Block
106                OpDecorate %40 DescriptorSet 0
107                OpDecorate %40 Binding 1
108                OpDecorate %72 Location 0
109           %2 = OpTypeVoid
110           %3 = OpTypeFunction %2
111           %6 = OpTypeFloat 32
112           %7 = OpTypeVector %6 4
113           %8 = OpTypePointer Function %7
114          %10 = OpTypeInt 32 1
115          %11 = OpTypeInt 32 0
116          %12 = OpConstant %11 5
117          %13 = OpTypeArray %10 %12
118          %14 = OpTypeStruct %13
119          %15 = OpTypePointer Uniform %14
120          %16 = OpVariable %15 Uniform
121          %17 = OpConstant %10 0
122          %18 = OpConstant %10 2
123          %19 = OpTypePointer Uniform %10
124          %23 = OpConstant %10 3
125          %27 = OpConstant %10 4
126          %31 = OpConstant %11 92985
127          %32 = OpTypeVector %11 4
128          %36 = OpConstant %11 3
129          %37 = OpTypeArray %6 %36
130          %38 = OpTypeStruct %37
131          %39 = OpTypePointer Uniform %38
132          %40 = OpVariable %39 Uniform
133          %41 = OpConstant %10 1
134          %42 = OpTypePointer Uniform %6
135          %48 = OpConstant %6 0.5
136          %49 = OpConstantComposite %7 %48 %48 %48 %48
137          %67 = OpTypeBool
138          %71 = OpTypePointer Output %7
139          %72 = OpVariable %71 Output
140           %4 = OpFunction %2 None %3
141           %5 = OpLabel
142           %9 = OpVariable %8 Function
143          %35 = OpVariable %8 Function
144          %46 = OpVariable %8 Function
145          %51 = OpVariable %8 Function
146          %20 = OpAccessChain %19 %16 %17 %18
147          %21 = OpLoad %10 %20
148          %22 = OpBitcast %11 %21
149          %24 = OpAccessChain %19 %16 %17 %23
150          %25 = OpLoad %10 %24
151          %26 = OpBitcast %11 %25
152          %28 = OpAccessChain %19 %16 %17 %27
153          %29 = OpLoad %10 %28
154          %30 = OpBitcast %11 %29
155          %33 = OpCompositeConstruct %32 %22 %26 %30 %31
156          %34 = OpBitcast %7 %33
157                OpStore %9 %34
158          %43 = OpAccessChain %42 %40 %17 %41
159          %44 = OpLoad %6 %43
160          %45 = OpCompositeConstruct %7 %44 %44 %44 %44
161                OpStore %35 %45
162          %47 = OpLoad %7 %9
163          %50 = OpExtInst %7 %1 Reflect %47 %49
164                OpStore %46 %50
165          %52 = OpLoad %7 %9
166          %53 = OpAccessChain %42 %40 %17 %18
167          %54 = OpLoad %6 %53
168          %55 = OpLoad %7 %35
169          %56 = OpLoad %7 %9
170          %57 = OpDot %6 %55 %56
171          %58 = OpFMul %6 %54 %57
172          %59 = OpLoad %7 %35
173          %60 = OpVectorTimesScalar %7 %59 %58
174          %61 = OpFSub %7 %52 %60
175                OpStore %51 %61
176          %62 = OpLoad %7 %46
177          %63 = OpLoad %7 %51
178          %64 = OpExtInst %6 %1 Distance %62 %63
179          %65 = OpAccessChain %42 %40 %17 %17
180          %66 = OpLoad %6 %65
181          %68 = OpFOrdLessThan %67 %64 %66
182                OpSelectionMerge %70 None
183                OpBranchConditional %68 %69 %86
184          %69 = OpLabel
185          %73 = OpAccessChain %19 %16 %17 %17
186          %74 = OpLoad %10 %73
187          %75 = OpConvertSToF %6 %74
188          %76 = OpAccessChain %19 %16 %17 %41
189          %77 = OpLoad %10 %76
190          %78 = OpConvertSToF %6 %77
191          %79 = OpAccessChain %19 %16 %17 %41
192          %80 = OpLoad %10 %79
193          %81 = OpConvertSToF %6 %80
194          %82 = OpAccessChain %19 %16 %17 %17
195          %83 = OpLoad %10 %82
196          %84 = OpConvertSToF %6 %83
197          %85 = OpCompositeConstruct %7 %75 %78 %81 %84
198                OpStore %72 %85
199                OpBranch %70
200          %86 = OpLabel
201          %87 = OpAccessChain %19 %16 %17 %41
202          %88 = OpLoad %10 %87
203          %89 = OpConvertSToF %6 %88
204          %90 = OpCompositeConstruct %7 %89 %89 %89 %89
205                OpStore %72 %90
206                OpBranch %70
207          %70 = OpLabel
208                OpReturn
209                OpFunctionEnd
210 END
211
212 # uniforms for variant
213
214 # _GLF_uniform_float_values
215 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
216  0.1 0.5 2.0
217 END
218 # _GLF_uniform_int_values
219 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
220  1 0 768 1792 45056
221 END
222
223 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
224
225 PIPELINE graphics variant_pipeline
226   ATTACH variant_vertex_shader
227   ATTACH variant_fragment_shader
228   FRAMEBUFFER_SIZE 16 16
229   BIND BUFFER variant_framebuffer AS color LOCATION 0
230   BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1
231   BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
232 END
233 CLEAR_COLOR variant_pipeline 0 0 0 255
234
235 CLEAR variant_pipeline
236 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 16 16
237
238 EXPECT variant_framebuffer IDX 0 0 SIZE 16 16 EQ_RGBA 255 0 0 255