• 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 floating point 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 _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]
32#
33# precision highp float;
34# precision highp int;
35#
36# // Contents of _GLF_uniform_float_values: [0.01, 1.0]
37# layout(set = 0, binding = 0) uniform buf0
38# {
39#     float _GLF_uniform_float_values[2];
40# };
41#
42# // Contents of _GLF_uniform_int_values: [0, 1]
43# layout(set = 0, binding = 1) uniform buf1
44# {
45#     int _GLF_uniform_int_values[2];
46# };
47#
48# layout(location = 0) out vec4 _GLF_color;
49#
50# void main()
51# {
52#     float f0 = mod(10.0, 0.000001);
53#     float s1 = 0.00000000000000000000000000000000000001;
54#
55#     if (s1 == 0.0)
56#         s1 = _float_1_0;
57#
58#     float f1 = mod(10.0, s1);
59#
60#     // Always true.
61#     if ((f0 > -_float_0_01 && f0 < _float_0_01) || f0 == f1)
62#         _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
63#     else
64#         _GLF_color = vec4(_int_0);
65# }
66SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
67; SPIR-V
68; Version: 1.0
69; Generator: Khronos Glslang Reference Front End; 8
70; Bound: 79
71; Schema: 0
72               OpCapability Shader
73          %1 = OpExtInstImport "GLSL.std.450"
74               OpMemoryModel Logical GLSL450
75               OpEntryPoint Fragment %4 "main" %55
76               OpExecutionMode %4 OriginUpperLeft
77               OpSource ESSL 310
78               OpName %4 "main"
79               OpName %8 "f0"
80               OpName %12 "s1"
81               OpName %23 "buf0"
82               OpMemberName %23 0 "_GLF_uniform_float_values"
83               OpName %25 ""
84               OpName %32 "f1"
85               OpName %55 "_GLF_color"
86               OpName %57 "buf1"
87               OpMemberName %57 0 "_GLF_uniform_int_values"
88               OpName %59 ""
89               OpDecorate %22 ArrayStride 16
90               OpMemberDecorate %23 0 Offset 0
91               OpDecorate %23 Block
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
97               OpDecorate %57 Block
98               OpDecorate %59 DescriptorSet 0
99               OpDecorate %59 Binding 1
100          %2 = OpTypeVoid
101          %3 = OpTypeFunction %2
102          %6 = OpTypeFloat 32
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
108         %16 = OpTypeBool
109         %20 = OpTypeInt 32 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
115         %26 = OpTypeInt 32 1
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
128          %5 = OpLabel
129          %8 = OpVariable %7 Function
130         %12 = OpVariable %7 Function
131         %32 = OpVariable %7 Function
132         %11 = OpFMod %6 %9 %10
133               OpStore %8 %11
134               OpStore %12 %13
135         %14 = OpLoad %6 %12
136         %17 = OpFOrdEqual %16 %14 %15
137               OpSelectionMerge %19 None
138               OpBranchConditional %17 %18 %19
139         %18 = OpLabel
140         %30 = OpAccessChain %29 %25 %27 %28
141         %31 = OpLoad %6 %30
142               OpStore %12 %31
143               OpBranch %19
144         %19 = OpLabel
145         %33 = OpLoad %6 %12
146         %34 = OpFMod %6 %9 %33
147               OpStore %32 %34
148         %35 = OpLoad %6 %8
149         %36 = OpAccessChain %29 %25 %27 %27
150         %37 = OpLoad %6 %36
151         %38 = OpFNegate %6 %37
152         %39 = OpFOrdGreaterThan %16 %35 %38
153               OpSelectionMerge %41 None
154               OpBranchConditional %39 %40 %41
155         %40 = OpLabel
156         %42 = OpLoad %6 %8
157         %43 = OpAccessChain %29 %25 %27 %27
158         %44 = OpLoad %6 %43
159         %45 = OpFOrdLessThan %16 %42 %44
160               OpBranch %41
161         %41 = OpLabel
162         %46 = OpPhi %16 %39 %19 %45 %40
163         %47 = OpLoad %6 %8
164         %48 = OpLoad %6 %32
165         %49 = OpFOrdEqual %16 %47 %48
166         %50 = OpLogicalOr %16 %46 %49
167               OpSelectionMerge %52 None
168               OpBranchConditional %50 %51 %74
169         %51 = OpLabel
170         %61 = OpAccessChain %60 %59 %27 %28
171         %62 = OpLoad %26 %61
172         %63 = OpConvertSToF %6 %62
173         %64 = OpAccessChain %60 %59 %27 %27
174         %65 = OpLoad %26 %64
175         %66 = OpConvertSToF %6 %65
176         %67 = OpAccessChain %60 %59 %27 %27
177         %68 = OpLoad %26 %67
178         %69 = OpConvertSToF %6 %68
179         %70 = OpAccessChain %60 %59 %27 %28
180         %71 = OpLoad %26 %70
181         %72 = OpConvertSToF %6 %71
182         %73 = OpCompositeConstruct %53 %63 %66 %69 %72
183               OpStore %55 %73
184               OpBranch %52
185         %74 = OpLabel
186         %75 = OpAccessChain %60 %59 %27 %27
187         %76 = OpLoad %26 %75
188         %77 = OpConvertSToF %6 %76
189         %78 = OpCompositeConstruct %53 %77 %77 %77 %77
190               OpStore %55 %78
191               OpBranch %52
192         %52 = OpLabel
193               OpReturn
194               OpFunctionEnd
195END
196
197# uniforms for variant
198
199# _GLF_uniform_int_values
200BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
201 0 1
202END
203# _GLF_uniform_float_values
204BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
205 0.01 1.0
206END
207
208BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
209
210PIPELINE 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
217END
218CLEAR_COLOR variant_pipeline 0 0 0 255
219
220CLEAR variant_pipeline
221RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
222
223EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255
224