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_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]
40 # precision highp float;
41 # precision highp int;
43 # // Contents of _GLF_uniform_float_values: 0.0
44 # layout(set = 0, binding = 0) uniform buf0
46 # float _GLF_uniform_float_values[1];
49 # // Contents of _GLF_uniform_int_values: [1, 2, 3, 4, 5, 6, 7, 8, 0]
50 # layout(set = 0, binding = 1) uniform buf1
52 # int _GLF_uniform_int_values[10];
55 # layout(location = 0) out vec4 _GLF_color;
59 # float nan = intBitsToFloat(-1);
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);
65 # if (_int_1 == _also_1 || undefined.x > _float_0_0)
67 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
71 # _GLF_color = vec4(_int_0);
74 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
77 ; Generator: Khronos Glslang Reference Front End; 8
81 %1 = OpExtInstImport "GLSL.std.450"
82 OpMemoryModel Logical GLSL450
83 OpEntryPoint Fragment %4 "main" %85
84 OpExecutionMode %4 OriginUpperLeft
88 OpName %14 "undefined"
90 OpMemberName %18 0 "_GLF_uniform_int_values"
93 OpMemberName %74 0 "_GLF_uniform_float_values"
95 OpName %85 "_GLF_color"
96 OpDecorate %17 ArrayStride 16
97 OpMemberDecorate %18 0 Offset 0
99 OpDecorate %20 DescriptorSet 0
100 OpDecorate %20 Binding 1
101 OpDecorate %73 ArrayStride 16
102 OpMemberDecorate %74 0 Offset 0
104 OpDecorate %76 DescriptorSet 0
105 OpDecorate %76 Binding 0
106 OpDecorate %85 Location 0
108 %3 = OpTypeFunction %2
110 %7 = OpTypePointer Function %6
112 %10 = OpConstant %9 -1
113 %12 = OpTypeVector %6 4
114 %13 = OpTypePointer Function %12
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
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
144 %8 = OpVariable %7 Function
145 %14 = OpVariable %13 Function
146 %11 = OpBitcast %6 %10
148 %23 = OpAccessChain %22 %20 %21 %21
150 %25 = OpConvertSToF %6 %24
151 %27 = OpAccessChain %22 %20 %21 %26
153 %29 = OpConvertSToF %6 %28
154 %31 = OpAccessChain %22 %20 %21 %30
156 %33 = OpConvertSToF %6 %32
157 %35 = OpAccessChain %22 %20 %21 %34
159 %37 = OpConvertSToF %6 %36
160 %38 = OpCompositeConstruct %12 %25 %29 %33 %37
161 %40 = OpAccessChain %22 %20 %21 %39
163 %42 = OpConvertSToF %6 %41
164 %44 = OpAccessChain %22 %20 %21 %43
166 %46 = OpConvertSToF %6 %45
167 %48 = OpAccessChain %22 %20 %21 %47
169 %50 = OpConvertSToF %6 %49
170 %52 = OpAccessChain %22 %20 %21 %51
172 %54 = OpConvertSToF %6 %53
173 %55 = OpCompositeConstruct %12 %42 %46 %50 %54
175 %57 = OpCompositeConstruct %12 %56 %56 %56 %56
176 %58 = OpExtInst %12 %1 FMix %38 %55 %57
178 %60 = OpAccessChain %22 %20 %21 %21
180 %63 = OpAccessChain %22 %20 %21 %62
182 %65 = OpIEqual %59 %61 %64
183 %66 = OpLogicalNot %59 %65
184 OpSelectionMerge %68 None
185 OpBranchConditional %66 %67 %68
187 %70 = OpAccessChain %7 %14 %69
189 %78 = OpAccessChain %77 %76 %21 %21
191 %80 = OpFOrdGreaterThan %59 %71 %79
194 %81 = OpPhi %59 %65 %5 %80 %67
195 OpSelectionMerge %83 None
196 OpBranchConditional %81 %82 %100
198 %86 = OpAccessChain %22 %20 %21 %21
200 %88 = OpConvertSToF %6 %87
201 %90 = OpAccessChain %22 %20 %21 %89
203 %92 = OpConvertSToF %6 %91
204 %93 = OpAccessChain %22 %20 %21 %89
206 %95 = OpConvertSToF %6 %94
207 %96 = OpAccessChain %22 %20 %21 %21
209 %98 = OpConvertSToF %6 %97
210 %99 = OpCompositeConstruct %12 %88 %92 %95 %98
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
225 # uniforms for variant
227 # _GLF_uniform_int_values
228 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
231 # _GLF_uniform_float_values
232 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
236 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
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
246 CLEAR_COLOR variant_pipeline 0 0 0 255
248 CLEAR variant_pipeline
249 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
251 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255