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 GraphicsFuzz.
20 # Short description: A fragment shader that covers a specific arbitrary precision float usage.
22 # The test passes because shader always writes red.
24 SHADER vertex variant_vertex_shader PASSTHROUGH
26 # variant_fragment_shader is derived from the following GLSL:
28 # precision highp float;
30 # layout(location = 0) out vec4 _GLF_color;
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));
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);
42 # _GLF_color = vec4(0);
44 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
47 ; Generator: Khronos Glslang Reference Front End; 8
51 %1 = OpExtInstImport "GLSL.std.450"
52 OpMemoryModel Logical GLSL450
53 OpEntryPoint Fragment %4 "main" %44
54 OpExecutionMode %4 OriginUpperLeft
60 OpName %44 "_GLF_color"
61 OpDecorate %44 Location 0
63 %3 = OpTypeFunction %2
65 %7 = OpTypeVector %6 4
66 %8 = OpTypePointer Function %7
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
80 %43 = OpTypePointer Output %7
81 %44 = OpVariable %43 Output
83 %46 = OpConstantComposite %7 %10 %45 %45 %10
84 %48 = OpConstantComposite %7 %45 %45 %45 %45
85 %4 = OpFunction %2 None %3
87 %9 = OpVariable %8 Function
88 %16 = OpVariable %15 Function
89 %25 = OpVariable %15 Function
92 %18 = OpExtInst %7 %1 Tanh %17
94 %20 = OpExtInst %7 %1 Sinh %19
96 %22 = OpExtInst %7 %1 Cosh %21
97 %23 = OpFDiv %7 %20 %22
98 %24 = OpExtInst %6 %1 Distance %18 %23
101 %27 = OpExtInst %7 %1 Tanh %26
102 %33 = OpExtInst %6 %1 Distance %27 %32
105 %37 = OpFOrdLessThan %36 %34 %35
107 %39 = OpFOrdLessThan %36 %38 %35
108 %40 = OpLogicalAnd %36 %37 %39
109 OpSelectionMerge %42 None
110 OpBranchConditional %40 %41 %47
123 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
125 PIPELINE 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
131 CLEAR_COLOR variant_pipeline 0 0 0 255
133 CLEAR variant_pipeline
134 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
136 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255