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_01 _GLF_uniform_float_values[0]
31 # #define _float_1_0 _GLF_uniform_float_values[1]
33 # precision highp float;
34 # precision highp int;
36 # // Contents of _GLF_uniform_float_values: [0.01, 1.0]
37 # layout(set = 0, binding = 0) uniform buf0
39 # float _GLF_uniform_float_values[2];
42 # // Contents of _GLF_uniform_int_values: [0, 1]
43 # layout(set = 0, binding = 1) uniform buf1
45 # int _GLF_uniform_int_values[2];
48 # layout(location = 0) out vec4 _GLF_color;
52 # float f0 = mod(10.0, 0.000001);
53 # float s1 = 0.00000000000000000000000000000000000001;
58 # float f1 = mod(10.0, s1);
61 # if ((f0 > -_float_0_01 && f0 < _float_0_01) || f0 == f1)
62 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
64 # _GLF_color = vec4(_int_0);
66 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
69 ; Generator: Khronos Glslang Reference Front End; 8
73 %1 = OpExtInstImport "GLSL.std.450"
74 OpMemoryModel Logical GLSL450
75 OpEntryPoint Fragment %4 "main" %55
76 OpExecutionMode %4 OriginUpperLeft
82 OpMemberName %23 0 "_GLF_uniform_float_values"
85 OpName %55 "_GLF_color"
87 OpMemberName %57 0 "_GLF_uniform_int_values"
89 OpDecorate %22 ArrayStride 16
90 OpMemberDecorate %23 0 Offset 0
92 OpDecorate %25 DescriptorSet 0
93 OpDecorate %25 Binding 0
94 OpDecorate %55 Location 0
95 OpDecorate %56 ArrayStride 16
96 OpMemberDecorate %57 0 Offset 0
98 OpDecorate %59 DescriptorSet 0
99 OpDecorate %59 Binding 1
101 %3 = OpTypeFunction %2
103 %7 = OpTypePointer Function %6
104 %9 = OpConstant %6 10
105 %10 = OpConstant %6 9.99999997e-07
106 %13 = OpConstant %6 0x1.b38fb8p-127
107 %15 = OpConstant %6 0
110 %21 = OpConstant %20 2
111 %22 = OpTypeArray %6 %21
112 %23 = OpTypeStruct %22
113 %24 = OpTypePointer Uniform %23
114 %25 = OpVariable %24 Uniform
116 %27 = OpConstant %26 0
117 %28 = OpConstant %26 1
118 %29 = OpTypePointer Uniform %6
119 %53 = OpTypeVector %6 4
120 %54 = OpTypePointer Output %53
121 %55 = OpVariable %54 Output
122 %56 = OpTypeArray %26 %21
123 %57 = OpTypeStruct %56
124 %58 = OpTypePointer Uniform %57
125 %59 = OpVariable %58 Uniform
126 %60 = OpTypePointer Uniform %26
127 %4 = OpFunction %2 None %3
129 %8 = OpVariable %7 Function
130 %12 = OpVariable %7 Function
131 %32 = OpVariable %7 Function
132 %11 = OpFMod %6 %9 %10
136 %17 = OpFOrdEqual %16 %14 %15
137 OpSelectionMerge %19 None
138 OpBranchConditional %17 %18 %19
140 %30 = OpAccessChain %29 %25 %27 %28
146 %34 = OpFMod %6 %9 %33
149 %36 = OpAccessChain %29 %25 %27 %27
151 %38 = OpFNegate %6 %37
152 %39 = OpFOrdGreaterThan %16 %35 %38
153 OpSelectionMerge %41 None
154 OpBranchConditional %39 %40 %41
157 %43 = OpAccessChain %29 %25 %27 %27
159 %45 = OpFOrdLessThan %16 %42 %44
162 %46 = OpPhi %16 %39 %19 %45 %40
165 %49 = OpFOrdEqual %16 %47 %48
166 %50 = OpLogicalOr %16 %46 %49
167 OpSelectionMerge %52 None
168 OpBranchConditional %50 %51 %74
170 %61 = OpAccessChain %60 %59 %27 %28
172 %63 = OpConvertSToF %6 %62
173 %64 = OpAccessChain %60 %59 %27 %27
175 %66 = OpConvertSToF %6 %65
176 %67 = OpAccessChain %60 %59 %27 %27
178 %69 = OpConvertSToF %6 %68
179 %70 = OpAccessChain %60 %59 %27 %28
181 %72 = OpConvertSToF %6 %71
182 %73 = OpCompositeConstruct %53 %63 %66 %69 %72
186 %75 = OpAccessChain %60 %59 %27 %27
188 %77 = OpConvertSToF %6 %76
189 %78 = OpCompositeConstruct %53 %77 %77 %77 %77
197 # uniforms for variant
199 # _GLF_uniform_int_values
200 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
203 # _GLF_uniform_float_values
204 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
208 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
210 PIPELINE graphics variant_pipeline
211 ATTACH variant_vertex_shader
212 ATTACH variant_fragment_shader
213 FRAMEBUFFER_SIZE 256 256
214 BIND BUFFER variant_framebuffer AS color LOCATION 0
215 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
216 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
218 CLEAR_COLOR variant_pipeline 0 0 0 255
220 CLEAR variant_pipeline
221 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
223 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255