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