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 APFloat 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 _float_1_0 _GLF_uniform_float_values[0]
30 # precision highp float;
32 # // Contents of _GLF_uniform_float_values: 1.0
33 # layout(set = 0, binding = 0) uniform buf0
35 # float _GLF_uniform_float_values[1];
38 # // Contents of v1: [0.0, 1.0]
39 # layout(set = 0, binding = 1) uniform buf1
44 # layout(location = 0) out vec4 _GLF_color;
48 # mat2 m24 = mat2x2(_float_1_0, _float_1_0, dot(v1.x, 1.0), _float_1_0);
51 # float a = float(m24);
53 # // Since a negative value is given to inversesqrt this results in an undefined value,
54 # // but not in undefined behavior.
55 # vec2 v2 = inversesqrt(vec2(-1.0, 1.0));
57 # // Since v2 includes an undefined value this results in an undefined value,
58 # // but not in undefined behavior.
59 # vec2 v3 = reflect(v2, vec2(a, 1.0));
61 # _GLF_color = vec4(_float_1_0, v3, _float_1_0);
63 # if (v1.y == _float_1_0)
65 # _GLF_color.yz = vec2(0.0);
69 # _GLF_color = vec4(0.0);
72 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
75 ; Generator: Khronos Glslang Reference Front End; 10
79 %1 = OpExtInstImport "GLSL.std.450"
80 OpMemoryModel Logical GLSL450
81 OpEntryPoint Fragment %4 "main" %53
82 OpExecutionMode %4 OriginUpperLeft
87 OpMemberName %14 0 "_GLF_uniform_float_values"
90 OpMemberName %24 0 "v1"
95 OpName %53 "_GLF_color"
96 OpDecorate %13 ArrayStride 16
97 OpMemberDecorate %14 0 Offset 0
99 OpDecorate %16 DescriptorSet 0
100 OpDecorate %16 Binding 0
101 OpMemberDecorate %24 0 Offset 0
103 OpDecorate %26 DescriptorSet 0
104 OpDecorate %26 Binding 1
105 OpDecorate %53 Location 0
107 %3 = OpTypeFunction %2
109 %7 = OpTypeVector %6 2
110 %8 = OpTypeMatrix %7 2
111 %9 = OpTypePointer Function %8
113 %12 = OpConstant %11 1
114 %13 = OpTypeArray %6 %12
115 %14 = OpTypeStruct %13
116 %15 = OpTypePointer Uniform %14
117 %16 = OpVariable %15 Uniform
119 %18 = OpConstant %17 0
120 %19 = OpTypePointer Uniform %6
121 %24 = OpTypeStruct %7
122 %25 = OpTypePointer Uniform %24
123 %26 = OpVariable %25 Uniform
124 %27 = OpConstant %11 0
125 %30 = OpConstant %6 1
126 %34 = OpConstant %6 0
127 %38 = OpTypePointer Function %6
128 %42 = OpTypePointer Function %7
129 %44 = OpConstant %6 -0x1.8p+128
130 %45 = OpConstantComposite %7 %44 %30
131 %51 = OpTypeVector %6 4
132 %52 = OpTypePointer Output %51
133 %53 = OpVariable %52 Output
135 %70 = OpConstantComposite %7 %34 %34
136 %74 = OpConstantComposite %51 %34 %34 %34 %34
137 %4 = OpFunction %2 None %3
139 %10 = OpVariable %9 Function
140 %39 = OpVariable %38 Function
141 %43 = OpVariable %42 Function
142 %46 = OpVariable %42 Function
143 %20 = OpAccessChain %19 %16 %18 %18
145 %22 = OpAccessChain %19 %16 %18 %18
147 %28 = OpAccessChain %19 %26 %18 %27
149 %31 = OpFMul %6 %29 %30
150 %32 = OpAccessChain %19 %16 %18 %18
152 %35 = OpCompositeConstruct %7 %21 %23
153 %36 = OpCompositeConstruct %7 %31 %33
154 %37 = OpCompositeConstruct %8 %35 %36
157 %41 = OpCompositeExtract %6 %40 0 0
162 %49 = OpCompositeConstruct %7 %48 %30
163 %50 = OpExtInst %7 %1 Reflect %47 %49
165 %54 = OpAccessChain %19 %16 %18 %18
168 %57 = OpAccessChain %19 %16 %18 %18
170 %59 = OpCompositeExtract %6 %56 0
171 %60 = OpCompositeExtract %6 %56 1
172 %61 = OpCompositeConstruct %51 %55 %59 %60 %58
174 %62 = OpAccessChain %19 %26 %18 %12
176 %64 = OpAccessChain %19 %16 %18 %18
178 %67 = OpFOrdEqual %66 %63 %65
179 OpSelectionMerge %69 None
180 OpBranchConditional %67 %68 %73
183 %72 = OpVectorShuffle %51 %71 %70 0 4 5 3
194 # uniforms for variant
197 BUFFER variant_v1 DATA_TYPE vec2<float> STD140 DATA
200 # _GLF_uniform_float_values
201 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
205 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
207 PIPELINE graphics variant_pipeline
208 ATTACH variant_vertex_shader
209 ATTACH variant_fragment_shader
210 FRAMEBUFFER_SIZE 256 256
211 BIND BUFFER variant_framebuffer AS color LOCATION 0
212 BIND BUFFER variant_v1 AS uniform DESCRIPTOR_SET 0 BINDING 1
213 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
215 CLEAR_COLOR variant_pipeline 0 0 0 255
217 CLEAR variant_pipeline
218 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
220 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255