Commit 929c6b00 by Alexis Hetu Committed by Alexis Hétu

High precision implementation for sin/cos/tan

This implementation allows all dEQP precision test to pass for sin, cos and tan function tests. Change-Id: I33a24497dea68ab2de2e65931f50f2dd4298523c Reviewed-on: https://swiftshader-review.googlesource.com/13555Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarAlexis Hétu <sugoi@google.com>
parent 5bf97084
...@@ -1894,6 +1894,12 @@ namespace glsl ...@@ -1894,6 +1894,12 @@ namespace glsl
instruction->dst.integer = (dst->getBasicType() == EbtInt); instruction->dst.integer = (dst->getBasicType() == EbtInt);
} }
if(src0)
{
TIntermTyped* src = src0->getAsTyped();
instruction->dst.partialPrecision = src && (src->getPrecision() <= EbpLow);
}
argument(instruction->src[0], src0, index0); argument(instruction->src[0], src0, index0);
argument(instruction->src[1], src1, index1); argument(instruction->src[1], src1, index1);
argument(instruction->src[2], src2, index2); argument(instruction->src[2], src2, index2);
......
...@@ -287,6 +287,21 @@ namespace sw ...@@ -287,6 +287,21 @@ namespace sw
Float4 y = x * Float4(1.59154943e-1f); // 1/2pi Float4 y = x * Float4(1.59154943e-1f); // 1/2pi
y = y - Round(y); y = y - Round(y);
if(!pp)
{
// From the paper: "A Fast, Vectorizable Algorithm for Producing Single-Precision Sine-Cosine Pairs"
// This implementation passes OpenGL ES 3.0 precision requirements, at the cost of more operations:
// !pp : 17 mul, 7 add, 1 sub, 1 reciprocal
// pp : 4 mul, 2 add, 2 abs
Float4 y2 = y * y;
Float4 c1 = y2 * (y2 * (y2 * Float4(-0.0204391631f) + Float4(0.2536086171f)) + Float4(-1.2336977925f)) + Float4(1.0f);
Float4 s1 = y * (y2 * (y2 * (y2 * Float4(-0.0046075748f) + Float4(0.0796819754f)) + Float4(-0.645963615f)) + Float4(1.5707963235f));
Float4 c2 = (c1 * c1) - (s1 * s1);
Float4 s2 = Float4(2.0f) * s1 * c1;
return Float4(2.0f) * s2 * c2 * reciprocal(s2 * s2 + c2 * c2, pp, true);
}
const Float4 A = Float4(-16.0f); const Float4 A = Float4(-16.0f);
const Float4 B = Float4(8.0f); const Float4 B = Float4(8.0f);
const Float4 C = Float4(7.75160950e-1f); const Float4 C = Float4(7.75160950e-1f);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment