• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 APFloat code path
21
22# The test passes because the shader always writes red.
23
24SHADER vertex variant_vertex_shader PASSTHROUGH
25
26# variant_fragment_shader is derived from the following GLSL:
27# #version 310 es
28# #define _float_1_0 _GLF_uniform_float_values[0]
29#
30# precision highp float;
31#
32# // Contents of _GLF_uniform_float_values: 1.0
33# layout(set = 0, binding = 0) uniform buf0
34# {
35#     float _GLF_uniform_float_values[1];
36# };
37#
38# // Contents of v1: [0.0, 1.0]
39# layout(set = 0, binding = 1) uniform buf1
40# {
41#     highp vec2 v1;
42# };
43#
44# layout(location = 0) out vec4 _GLF_color;
45#
46# void main()
47# {
48#     mat2 m24 = mat2x2(_float_1_0, _float_1_0, dot(v1.x, 1.0), _float_1_0);
49#
50#     // a becomes 0.0.
51#     float a = float(m24);
52#
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));
56#
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));
60#
61#     _GLF_color = vec4(_float_1_0, v3, _float_1_0);
62#
63#     if (v1.y == _float_1_0)
64#     {
65#         _GLF_color.yz = vec2(0.0);
66#     }
67#     else
68#     {
69#         _GLF_color = vec4(0.0);
70#     }
71# }
72SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
73; SPIR-V
74; Version: 1.0
75; Generator: Khronos Glslang Reference Front End; 10
76; Bound: 75
77; Schema: 0
78               OpCapability Shader
79          %1 = OpExtInstImport "GLSL.std.450"
80               OpMemoryModel Logical GLSL450
81               OpEntryPoint Fragment %4 "main" %53
82               OpExecutionMode %4 OriginUpperLeft
83               OpSource ESSL 310
84               OpName %4 "main"
85               OpName %10 "m24"
86               OpName %14 "buf0"
87               OpMemberName %14 0 "_GLF_uniform_float_values"
88               OpName %16 ""
89               OpName %24 "buf1"
90               OpMemberName %24 0 "v1"
91               OpName %26 ""
92               OpName %39 "a"
93               OpName %43 "v2"
94               OpName %46 "v3"
95               OpName %53 "_GLF_color"
96               OpDecorate %13 ArrayStride 16
97               OpMemberDecorate %14 0 Offset 0
98               OpDecorate %14 Block
99               OpDecorate %16 DescriptorSet 0
100               OpDecorate %16 Binding 0
101               OpMemberDecorate %24 0 Offset 0
102               OpDecorate %24 Block
103               OpDecorate %26 DescriptorSet 0
104               OpDecorate %26 Binding 1
105               OpDecorate %53 Location 0
106          %2 = OpTypeVoid
107          %3 = OpTypeFunction %2
108          %6 = OpTypeFloat 32
109          %7 = OpTypeVector %6 2
110          %8 = OpTypeMatrix %7 2
111          %9 = OpTypePointer Function %8
112         %11 = OpTypeInt 32 0
113         %12 = OpConstant %11 1
114         %13 = OpTypeArray %6 %12
115         %14 = OpTypeStruct %13
116         %15 = OpTypePointer Uniform %14
117         %16 = OpVariable %15 Uniform
118         %17 = OpTypeInt 32 1
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
134         %66 = OpTypeBool
135         %70 = OpConstantComposite %7 %34 %34
136         %74 = OpConstantComposite %51 %34 %34 %34 %34
137          %4 = OpFunction %2 None %3
138          %5 = OpLabel
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
144         %21 = OpLoad %6 %20
145         %22 = OpAccessChain %19 %16 %18 %18
146         %23 = OpLoad %6 %22
147         %28 = OpAccessChain %19 %26 %18 %27
148         %29 = OpLoad %6 %28
149         %31 = OpFMul %6 %29 %30
150         %32 = OpAccessChain %19 %16 %18 %18
151         %33 = OpLoad %6 %32
152         %35 = OpCompositeConstruct %7 %21 %23
153         %36 = OpCompositeConstruct %7 %31 %33
154         %37 = OpCompositeConstruct %8 %35 %36
155               OpStore %10 %37
156         %40 = OpLoad %8 %10
157         %41 = OpCompositeExtract %6 %40 0 0
158               OpStore %39 %41
159               OpStore %43 %45
160         %47 = OpLoad %7 %43
161         %48 = OpLoad %6 %39
162         %49 = OpCompositeConstruct %7 %48 %30
163         %50 = OpExtInst %7 %1 Reflect %47 %49
164               OpStore %46 %50
165         %54 = OpAccessChain %19 %16 %18 %18
166         %55 = OpLoad %6 %54
167         %56 = OpLoad %7 %46
168         %57 = OpAccessChain %19 %16 %18 %18
169         %58 = OpLoad %6 %57
170         %59 = OpCompositeExtract %6 %56 0
171         %60 = OpCompositeExtract %6 %56 1
172         %61 = OpCompositeConstruct %51 %55 %59 %60 %58
173               OpStore %53 %61
174         %62 = OpAccessChain %19 %26 %18 %12
175         %63 = OpLoad %6 %62
176         %64 = OpAccessChain %19 %16 %18 %18
177         %65 = OpLoad %6 %64
178         %67 = OpFOrdEqual %66 %63 %65
179               OpSelectionMerge %69 None
180               OpBranchConditional %67 %68 %73
181         %68 = OpLabel
182         %71 = OpLoad %51 %53
183         %72 = OpVectorShuffle %51 %71 %70 0 4 5 3
184               OpStore %53 %72
185               OpBranch %69
186         %73 = OpLabel
187               OpStore %53 %74
188               OpBranch %69
189         %69 = OpLabel
190               OpReturn
191               OpFunctionEnd
192END
193
194# uniforms for variant
195
196# v1
197BUFFER variant_v1 DATA_TYPE vec2<float> STD140 DATA
198 0.0 1.0
199END
200# _GLF_uniform_float_values
201BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
202 1.0
203END
204
205BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
206
207PIPELINE 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
214END
215CLEAR_COLOR variant_pipeline 0 0 0 255
216
217CLEAR variant_pipeline
218RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
219
220EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255
221