Correct reciprocal approximation for power-of-two values.
Intel's reciprocal approximation instruction is not exact for power-of-two
values. It provides 12 bits of mantissa precision and keeps a balance between
positive and negative errors, but the reciprocal of 2^x is not 2^-x. This
affects conformance tests which expect varyings not to be affected by the
perspective division. Correct for this by multiplying by the inverse.
Bug 27165393
Change-Id: Ie52ec511a14a4f447adc47ce9c875bbad03cd274
Reviewed-on: https://swiftshader-review.googlesource.com/4903
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
diff --git a/src/Shader/ShaderCore.cpp b/src/Shader/ShaderCore.cpp
index ad9f426..f177a68 100644
--- a/src/Shader/ShaderCore.cpp
+++ b/src/Shader/ShaderCore.cpp
@@ -271,7 +271,7 @@
return exponential2(log, pp);
}
- Float4 reciprocal(RValue<Float4> x, bool pp, bool finite)
+ Float4 reciprocal(RValue<Float4> x, bool pp, bool finite, bool exactAtPow2)
{
Float4 rcp;
@@ -281,7 +281,7 @@
}
else
{
- rcp = Rcp_pp(x);
+ rcp = Rcp_pp(x, exactAtPow2);
if(!pp)
{