Mesa (master): glsl: improve the accuracy of the radians() builtin function

Paul Berry stereotype441 at kemper.freedesktop.org
Thu Jul 28 17:47:37 UTC 2011


Module: Mesa
Branch: master
Commit: fe33c886a79f49378e5719909a51e794b7bb1c38
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=fe33c886a79f49378e5719909a51e794b7bb1c38

Author: Paul Berry <stereotype441 at gmail.com>
Date:   Wed Jul 27 10:35:17 2011 -0700

glsl: improve the accuracy of the radians() builtin function

The constant used in the radians() function didn't have enough
precision, causing a relative error of 1.676e-5, which is far worse
than the precision of 32-bit floats.  This patch reduces the relative
error to 1.14e-9, which is the best we can do in 32 bits.

Fixes piglit tests {fs,vs}-radians-{float,vec2,vec3,vec4}.

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

---

 src/glsl/builtins/ir/radians |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/glsl/builtins/ir/radians b/src/glsl/builtins/ir/radians
index 6a0f5d2..a419101 100644
--- a/src/glsl/builtins/ir/radians
+++ b/src/glsl/builtins/ir/radians
@@ -2,20 +2,20 @@
    (signature float
      (parameters
        (declare (in) float arg0))
-     ((return (expression float * (var_ref arg0) (constant float (0.017453))))))
+     ((return (expression float * (var_ref arg0) (constant float (0.0174532925))))))
 
    (signature vec2
      (parameters
        (declare (in) vec2 arg0))
-     ((return (expression vec2 * (var_ref arg0) (constant float (0.017453))))))
+     ((return (expression vec2 * (var_ref arg0) (constant float (0.0174532925))))))
 
    (signature vec3
      (parameters
        (declare (in) vec3 arg0))
-     ((return (expression vec3 * (var_ref arg0) (constant float (0.017453))))))
+     ((return (expression vec3 * (var_ref arg0) (constant float (0.0174532925))))))
 
    (signature vec4
      (parameters
        (declare (in) vec4 arg0))
-     ((return (expression vec4 * (var_ref arg0) (constant float (0.017453))))))
+     ((return (expression vec4 * (var_ref arg0) (constant float (0.0174532925))))))
 ))




More information about the mesa-commit mailing list