• 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 GraphicsFuzz.
19
20# Short description: A fragment shader that covers a specific arbitrary precision float usage.
21
22# The test passes because 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# precision highp float;
29#
30# layout(location = 0) out vec4 _GLF_color;
31#
32# void main()
33# {
34#     vec4 v = vec4(1, 2, 3, 4);
35#     float dist1 = distance(tanh(v), sinh(v) / cosh(v));
36#     float dist2 = distance(tanh(v), vec4(0.76159, 0.96403, 0.99505, 0.99933));
37#
38#     // tanh(v) == sinh(v) / cosh(v). Allow some room for precision errors.
39#     if (dist1 < 0.1 && dist2 < 0.1)
40#         _GLF_color = vec4(1, 0, 0, 1);
41#     else
42#         _GLF_color = vec4(0);
43# }
44SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
45; SPIR-V
46; Version: 1.0
47; Generator: Khronos Glslang Reference Front End; 8
48; Bound: 49
49; Schema: 0
50               OpCapability Shader
51          %1 = OpExtInstImport "GLSL.std.450"
52               OpMemoryModel Logical GLSL450
53               OpEntryPoint Fragment %4 "main" %44
54               OpExecutionMode %4 OriginUpperLeft
55               OpSource ESSL 310
56               OpName %4 "main"
57               OpName %9 "v"
58               OpName %16 "dist1"
59               OpName %25 "dist2"
60               OpName %44 "_GLF_color"
61               OpDecorate %44 Location 0
62          %2 = OpTypeVoid
63          %3 = OpTypeFunction %2
64          %6 = OpTypeFloat 32
65          %7 = OpTypeVector %6 4
66          %8 = OpTypePointer Function %7
67         %10 = OpConstant %6 1
68         %11 = OpConstant %6 2
69         %12 = OpConstant %6 3
70         %13 = OpConstant %6 4
71         %14 = OpConstantComposite %7 %10 %11 %12 %13
72         %15 = OpTypePointer Function %6
73         %28 = OpConstant %6 0.761590004
74         %29 = OpConstant %6 0.964030027
75         %30 = OpConstant %6 0.995050013
76         %31 = OpConstant %6 0.999329984
77         %32 = OpConstantComposite %7 %28 %29 %30 %31
78         %35 = OpConstant %6 0.100000001
79         %36 = OpTypeBool
80         %43 = OpTypePointer Output %7
81         %44 = OpVariable %43 Output
82         %45 = OpConstant %6 0
83         %46 = OpConstantComposite %7 %10 %45 %45 %10
84         %48 = OpConstantComposite %7 %45 %45 %45 %45
85          %4 = OpFunction %2 None %3
86          %5 = OpLabel
87          %9 = OpVariable %8 Function
88         %16 = OpVariable %15 Function
89         %25 = OpVariable %15 Function
90               OpStore %9 %14
91         %17 = OpLoad %7 %9
92         %18 = OpExtInst %7 %1 Tanh %17
93         %19 = OpLoad %7 %9
94         %20 = OpExtInst %7 %1 Sinh %19
95         %21 = OpLoad %7 %9
96         %22 = OpExtInst %7 %1 Cosh %21
97         %23 = OpFDiv %7 %20 %22
98         %24 = OpExtInst %6 %1 Distance %18 %23
99               OpStore %16 %24
100         %26 = OpLoad %7 %9
101         %27 = OpExtInst %7 %1 Tanh %26
102         %33 = OpExtInst %6 %1 Distance %27 %32
103               OpStore %25 %33
104         %34 = OpLoad %6 %16
105         %37 = OpFOrdLessThan %36 %34 %35
106         %38 = OpLoad %6 %25
107         %39 = OpFOrdLessThan %36 %38 %35
108         %40 = OpLogicalAnd %36 %37 %39
109               OpSelectionMerge %42 None
110               OpBranchConditional %40 %41 %47
111         %41 = OpLabel
112               OpStore %44 %46
113               OpBranch %42
114         %47 = OpLabel
115               OpStore %44 %48
116               OpBranch %42
117         %42 = OpLabel
118               OpReturn
119               OpFunctionEnd
120END
121
122
123BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
124
125PIPELINE graphics variant_pipeline
126  ATTACH variant_vertex_shader
127  ATTACH variant_fragment_shader
128  FRAMEBUFFER_SIZE 256 256
129  BIND BUFFER variant_framebuffer AS color LOCATION 0
130END
131CLEAR_COLOR variant_pipeline 0 0 0 255
132
133CLEAR variant_pipeline
134RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
135
136EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255
137