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;
35 # float det1 = determinant(mat4(0, 1, 0, 1,
40 # float det2 = determinant(mat3(1, 0, 1,
44 # float det3 = determinant(mat3(1, 0, 1,
48 # float det4 = determinant(mat3(1, 0, 1,
52 # float ref = -det2 + det3 - 5.0 * det4;
54 # if (abs(ref - det1) < 0.1) // Always true.
55 # _GLF_color = vec4(1, 0, 0, 1);
57 # _GLF_color = vec4(0);
59 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
62 ; Generator: Khronos Glslang Reference Front End; 8
66 %1 = OpExtInstImport "GLSL.std.450"
67 OpMemoryModel Logical GLSL450
68 OpEntryPoint Fragment %4 "main" %59
69 OpExecutionMode %4 OriginUpperLeft
77 OpName %59 "_GLF_color"
78 OpDecorate %59 Location 0
80 %3 = OpTypeFunction %2
82 %7 = OpTypePointer Function %6
83 %9 = OpTypeVector %6 4
84 %10 = OpTypeMatrix %9 4
87 %13 = OpConstantComposite %9 %11 %12 %11 %12
89 %15 = OpConstantComposite %9 %12 %12 %12 %14
92 %18 = OpConstantComposite %9 %12 %16 %17 %12
94 %20 = OpConstant %6 35
96 %22 = OpConstant %6 63
97 %23 = OpConstantComposite %9 %19 %20 %21 %22
98 %24 = OpConstantComposite %10 %13 %15 %18 %23
99 %27 = OpTypeVector %6 3
100 %28 = OpTypeMatrix %27 3
101 %29 = OpConstantComposite %27 %12 %11 %12
102 %30 = OpConstantComposite %27 %16 %17 %12
103 %31 = OpConstantComposite %27 %20 %21 %22
104 %32 = OpConstantComposite %28 %29 %30 %31
105 %35 = OpConstantComposite %27 %12 %12 %14
106 %36 = OpConstantComposite %28 %29 %35 %31
107 %39 = OpConstantComposite %28 %29 %35 %30
108 %53 = OpConstant %6 0.100000001
110 %58 = OpTypePointer Output %9
111 %59 = OpVariable %58 Output
112 %60 = OpConstantComposite %9 %12 %11 %11 %12
113 %62 = OpConstantComposite %9 %11 %11 %11 %11
114 %4 = OpFunction %2 None %3
116 %8 = OpVariable %7 Function
117 %26 = OpVariable %7 Function
118 %34 = OpVariable %7 Function
119 %38 = OpVariable %7 Function
120 %41 = OpVariable %7 Function
121 %25 = OpExtInst %6 %1 Determinant %24
123 %33 = OpExtInst %6 %1 Determinant %32
125 %37 = OpExtInst %6 %1 Determinant %36
127 %40 = OpExtInst %6 %1 Determinant %39
130 %43 = OpFNegate %6 %42
132 %45 = OpFAdd %6 %43 %44
134 %47 = OpFMul %6 %19 %46
135 %48 = OpFSub %6 %45 %47
139 %51 = OpFSub %6 %49 %50
140 %52 = OpExtInst %6 %1 FAbs %51
141 %55 = OpFOrdLessThan %54 %52 %53
142 OpSelectionMerge %57 None
143 OpBranchConditional %55 %56 %61
156 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
158 PIPELINE graphics variant_pipeline
159 ATTACH variant_vertex_shader
160 ATTACH variant_fragment_shader
161 FRAMEBUFFER_SIZE 256 256
162 BIND BUFFER variant_framebuffer AS color LOCATION 0
164 CLEAR_COLOR variant_pipeline 0 0 0 255
166 CLEAR variant_pipeline
167 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
169 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255