• 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 X86 ISel lowering and AP Float code paths
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_1 _GLF_uniform_int_values[0]
29# #define _int_0 _GLF_uniform_int_values[1]
30# #define _float_0_54 _GLF_uniform_float_values[0]
31# #define _float_0_55 _GLF_uniform_float_values[1]
32#
33# precision highp float;
34# precision highp int;
35#
36# // Contents of _GLF_uniform_int_values: [1, 0]
37# layout(set = 0, binding = 0) uniform buf0
38# {
39#     int _GLF_uniform_int_values[2];
40# };
41#
42# // Contents of _GLF_uniform_float_values: [0.54, 0.55]
43# layout(set = 0, binding = 1) uniform buf1
44# {
45#     float _GLF_uniform_float_values[2];
46# };
47#
48# layout(location = 0) out vec4 _GLF_color;
49#
50# void main()
51# {
52#     // uintbitstofloat(1) gives a very small denormalized value. The cos of this value
53#     // should be very close to 1; perhaps marginally smaller.  The cosine of *that* value
54#     // should then be bounded below by 0.54, and might be slightly larger,
55#     // so that 0.55 is a suitable upper bound.
56#     vec2 v1 = cos(cos(intBitsToFloat(ivec2(-1, _int_1))));
57#     _GLF_color = vec4(v1.x);
58#
59#     if (v1.y > _float_0_54 && v1.y < _float_0_55)
60#     {
61#         _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
62#     }
63#     else
64#     {
65#         _GLF_color = vec4(_int_0);
66#     }
67# }
68SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
69; SPIR-V
70; Version: 1.0
71; Generator: Khronos Glslang Reference Front End; 8
72; Bound: 76
73; Schema: 0
74               OpCapability Shader
75          %1 = OpExtInstImport "GLSL.std.450"
76               OpMemoryModel Logical GLSL450
77               OpEntryPoint Fragment %4 "main" %29
78               OpExecutionMode %4 OriginUpperLeft
79               OpSource ESSL 310
80               OpName %4 "main"
81               OpName %9 "v1"
82               OpName %15 "buf0"
83               OpMemberName %15 0 "_GLF_uniform_int_values"
84               OpName %17 ""
85               OpName %29 "_GLF_color"
86               OpName %40 "buf1"
87               OpMemberName %40 0 "_GLF_uniform_float_values"
88               OpName %42 ""
89               OpDecorate %14 ArrayStride 16
90               OpMemberDecorate %15 0 Offset 0
91               OpDecorate %15 Block
92               OpDecorate %17 DescriptorSet 0
93               OpDecorate %17 Binding 0
94               OpDecorate %29 Location 0
95               OpDecorate %39 ArrayStride 16
96               OpMemberDecorate %40 0 Offset 0
97               OpDecorate %40 Block
98               OpDecorate %42 DescriptorSet 0
99               OpDecorate %42 Binding 1
100          %2 = OpTypeVoid
101          %3 = OpTypeFunction %2
102          %6 = OpTypeFloat 32
103          %7 = OpTypeVector %6 2
104          %8 = OpTypePointer Function %7
105         %10 = OpTypeInt 32 1
106         %11 = OpConstant %10 -1
107         %12 = OpTypeInt 32 0
108         %13 = OpConstant %12 2
109         %14 = OpTypeArray %10 %13
110         %15 = OpTypeStruct %14
111         %16 = OpTypePointer Uniform %15
112         %17 = OpVariable %16 Uniform
113         %18 = OpConstant %10 0
114         %19 = OpTypePointer Uniform %10
115         %22 = OpTypeVector %10 2
116         %27 = OpTypeVector %6 4
117         %28 = OpTypePointer Output %27
118         %29 = OpVariable %28 Output
119         %30 = OpConstant %12 0
120         %31 = OpTypePointer Function %6
121         %35 = OpTypeBool
122         %36 = OpConstant %12 1
123         %39 = OpTypeArray %6 %13
124         %40 = OpTypeStruct %39
125         %41 = OpTypePointer Uniform %40
126         %42 = OpVariable %41 Uniform
127         %43 = OpTypePointer Uniform %6
128         %51 = OpConstant %10 1
129          %4 = OpFunction %2 None %3
130          %5 = OpLabel
131          %9 = OpVariable %8 Function
132         %20 = OpAccessChain %19 %17 %18 %18
133         %21 = OpLoad %10 %20
134         %23 = OpCompositeConstruct %22 %11 %21
135         %24 = OpBitcast %7 %23
136         %25 = OpExtInst %7 %1 Cos %24
137         %26 = OpExtInst %7 %1 Cos %25
138               OpStore %9 %26
139         %32 = OpAccessChain %31 %9 %30
140         %33 = OpLoad %6 %32
141         %34 = OpCompositeConstruct %27 %33 %33 %33 %33
142               OpStore %29 %34
143         %37 = OpAccessChain %31 %9 %36
144         %38 = OpLoad %6 %37
145         %44 = OpAccessChain %43 %42 %18 %18
146         %45 = OpLoad %6 %44
147         %46 = OpFOrdGreaterThan %35 %38 %45
148               OpSelectionMerge %48 None
149               OpBranchConditional %46 %47 %48
150         %47 = OpLabel
151         %49 = OpAccessChain %31 %9 %36
152         %50 = OpLoad %6 %49
153         %52 = OpAccessChain %43 %42 %18 %51
154         %53 = OpLoad %6 %52
155         %54 = OpFOrdLessThan %35 %50 %53
156               OpBranch %48
157         %48 = OpLabel
158         %55 = OpPhi %35 %46 %5 %54 %47
159               OpSelectionMerge %57 None
160               OpBranchConditional %55 %56 %71
161         %56 = OpLabel
162         %58 = OpAccessChain %19 %17 %18 %18
163         %59 = OpLoad %10 %58
164         %60 = OpConvertSToF %6 %59
165         %61 = OpAccessChain %19 %17 %18 %51
166         %62 = OpLoad %10 %61
167         %63 = OpConvertSToF %6 %62
168         %64 = OpAccessChain %19 %17 %18 %51
169         %65 = OpLoad %10 %64
170         %66 = OpConvertSToF %6 %65
171         %67 = OpAccessChain %19 %17 %18 %18
172         %68 = OpLoad %10 %67
173         %69 = OpConvertSToF %6 %68
174         %70 = OpCompositeConstruct %27 %60 %63 %66 %69
175               OpStore %29 %70
176               OpBranch %57
177         %71 = OpLabel
178         %72 = OpAccessChain %19 %17 %18 %51
179         %73 = OpLoad %10 %72
180         %74 = OpConvertSToF %6 %73
181         %75 = OpCompositeConstruct %27 %74 %74 %74 %74
182               OpStore %29 %75
183               OpBranch %57
184         %57 = OpLabel
185               OpReturn
186               OpFunctionEnd
187END
188
189# uniforms for variant
190
191# _GLF_uniform_float_values
192BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
193 0.54 0.55
194END
195# _GLF_uniform_int_values
196BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
197 1 0
198END
199
200BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
201
202PIPELINE graphics variant_pipeline
203  ATTACH variant_vertex_shader
204  ATTACH variant_fragment_shader
205  FRAMEBUFFER_SIZE 16 16
206  BIND BUFFER variant_framebuffer AS color LOCATION 0
207  BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1
208  BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
209END
210CLEAR_COLOR variant_pipeline 0 0 0 255
211
212CLEAR variant_pipeline
213RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 16 16
214
215EXPECT variant_framebuffer IDX 0 0 SIZE 16 16 EQ_RGBA 255 0 0 255
216