Precision fix for inversesqrt.
Fixes all dEQP failures in inversesqrt and normalize.
Change-Id: Ifd1ac2714fa95bab1c720b65c95a27bbf23ea933
Reviewed-on: https://swiftshader-review.googlesource.com/13728
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Shader/ShaderCore.cpp b/src/Shader/ShaderCore.cpp
index 29fea75..53644b8 100644
--- a/src/Shader/ShaderCore.cpp
+++ b/src/Shader/ShaderCore.cpp
@@ -227,7 +227,7 @@
Float4 rsq;
- if(!pp && rsqPrecision >= IEEE)
+ if(!pp)
{
rsq = Float4(1.0f) / Sqrt(abs);
}
@@ -239,10 +239,9 @@
{
rsq = rsq * (Float4(3.0f) - rsq * rsq * abs) * Float4(0.5f);
}
- }
- int big = 0x7F7FFFFF;
- rsq = Min(rsq, Float4((float&)big));
+ rsq = As<Float4>(CmpNEQ(As<Int4>(abs), Int4(0x7F800000)) & As<Int4>(rsq));
+ }
return rsq;
}