3 # Copyright 2020 Google LLC
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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.
18 # A test for a coverage-gap found by the GraphicsFuzz project.
20 # Short description: A fragment shader that covers a specific floating point code path
22 # The test passes because the shader always writes red.
24 SHADER vertex variant_vertex_shader PASSTHROUGH
26 # variant_fragment_shader is derived from the following GLSL:
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]
32 # precision highp float;
33 # precision highp int;
35 # // Contents of _GLF_uniform_float_values: 0.0
36 # layout(set = 0, binding = 0) uniform buf0
38 # float _GLF_uniform_float_values[1];
41 # // Contents of _GLF_uniform_int_values: [0, 1]
42 # layout(set = 0, binding = 1) uniform buf1
44 # int _GLF_uniform_int_values[2];
47 # layout(location = 0) out vec4 _GLF_color;
51 # float f0 = mod(10.0, 0.000001);
53 # float s1 = 0.00000000000000000000000000000000000001;
59 # float f1 = mod(10.0, s1);
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.
65 # || (f0 == f1 || (f0 > 0.99 && f0 < 0.01) || (f1 > 0.99 && f1 < 0.01))
68 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
72 # _GLF_color = vec4(_int_0);
75 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
78 ; Generator: Khronos Glslang Reference Front End; 8
82 %1 = OpExtInstImport "GLSL.std.450"
83 OpMemoryModel Logical GLSL450
84 OpEntryPoint Fragment %4 "main" %63
85 OpExecutionMode %4 OriginUpperLeft
91 OpName %63 "_GLF_color"
93 OpMemberName %68 0 "_GLF_uniform_int_values"
96 OpMemberName %94 0 "_GLF_uniform_float_values"
98 OpDecorate %63 Location 0
99 OpDecorate %67 ArrayStride 16
100 OpMemberDecorate %68 0 Offset 0
102 OpDecorate %70 DescriptorSet 0
103 OpDecorate %70 Binding 1
104 OpDecorate %93 ArrayStride 16
105 OpMemberDecorate %94 0 Offset 0
107 OpDecorate %96 DescriptorSet 0
108 OpDecorate %96 Binding 0
110 %3 = OpTypeFunction %2
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
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
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
141 %8 = OpVariable %7 Function
142 %12 = OpVariable %7 Function
143 %21 = OpVariable %7 Function
144 %11 = OpFMod %6 %9 %10
148 %17 = OpFOrdEqual %16 %14 %15
149 OpSelectionMerge %19 None
150 OpBranchConditional %17 %18 %19
156 %23 = OpFMod %6 %9 %22
159 %25 = OpIsInf %16 %24
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
169 %34 = OpFOrdEqual %16 %32 %33
170 %35 = OpLogicalNot %16 %34
171 OpSelectionMerge %37 None
172 OpBranchConditional %35 %36 %37
175 %40 = OpFOrdGreaterThan %16 %38 %39
177 %43 = OpFOrdLessThan %16 %41 %42
178 %44 = OpLogicalAnd %16 %40 %43
181 %45 = OpPhi %16 %34 %30 %44 %36
182 %46 = OpLogicalNot %16 %45
183 OpSelectionMerge %48 None
184 OpBranchConditional %46 %47 %48
187 %50 = OpFOrdGreaterThan %16 %49 %39
189 %52 = OpFOrdLessThan %16 %51 %42
190 %53 = OpLogicalAnd %16 %50 %52
193 %54 = OpPhi %16 %45 %37 %53 %47
196 %55 = OpPhi %16 %28 %19 %54 %48
198 %57 = OpFOrdEqual %16 %56 %9
199 %58 = OpLogicalOr %16 %55 %57
200 OpSelectionMerge %60 None
201 OpBranchConditional %58 %59 %87
203 %74 = OpAccessChain %73 %70 %71 %72
205 %76 = OpConvertSToF %6 %75
206 %77 = OpAccessChain %73 %70 %71 %71
208 %79 = OpConvertSToF %6 %78
209 %80 = OpAccessChain %73 %70 %71 %71
211 %82 = OpConvertSToF %6 %81
212 %83 = OpAccessChain %73 %70 %71 %72
214 %85 = OpConvertSToF %6 %84
215 %86 = OpCompositeConstruct %61 %76 %79 %82 %85
219 %88 = OpAccessChain %73 %70 %71 %71
221 %90 = OpConvertSToF %6 %89
222 %91 = OpCompositeConstruct %61 %90 %90 %90 %90
230 # uniforms for variant
232 # _GLF_uniform_int_values
233 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
236 # _GLF_uniform_float_values
237 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
241 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
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
251 CLEAR_COLOR variant_pipeline 0 0 0 255
253 CLEAR variant_pipeline
254 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
256 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255