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