[Mesa-dev] [PATCH] Ensure that acos(1)==0.

Olivier Galibert galibert at pobox.com
Tue May 8 02:51:39 PDT 2012


The apparent cost of the calibration is eaten by the constant
propagation optimization pass.
    
Signed-off-by: Olivier Galibert <galibert at pobox.com>

diff --git a/src/glsl/builtins/ir/acos.ir b/src/glsl/builtins/ir/acos.ir
index f0078f8..d321057 100644
--- a/src/glsl/builtins/ir/acos.ir
+++ b/src/glsl/builtins/ir/acos.ir
@@ -3,27 +3,35 @@
      (parameters
        (declare (in) float x))
      ((declare () float s)
+      (declare () float t)
       (call asin (var_ref s) ((var_ref x)))
-      (return (expression float - (constant float (1.5707963)) (var_ref s)))))
+      (call asin (var_ref t) ((constant float (1))))
+      (return (expression float - (var_ref t) (var_ref s)))))
 
    (signature vec2
      (parameters
        (declare (in) vec2 x))
      ((declare () vec2 s)
+      (declare () float t)
       (call asin (var_ref s) ((var_ref x)))
-      (return (expression vec2 - (constant float (1.5707963)) (var_ref s)))))
+      (call asin (var_ref t) ((constant float (1))))
+      (return (expression vec2 - (var_ref t) (var_ref s)))))
 
    (signature vec3
      (parameters
        (declare (in) vec3 x))
      ((declare () vec3 s)
+      (declare () float t)
       (call asin (var_ref s) ((var_ref x)))
-      (return (expression vec3 - (constant float (1.5707963)) (var_ref s)))))
+      (call asin (var_ref t) ((constant float (1))))
+      (return (expression vec3 - (var_ref t) (var_ref s)))))
 
    (signature vec4
      (parameters
        (declare (in) vec4 x))
      ((declare () vec4 s)
+      (declare () float t)
       (call asin (var_ref s) ((var_ref x)))
-      (return (expression vec4 - (constant float (1.5707963)) (var_ref s)))))
+      (call asin (var_ref t) ((constant float (1))))
+      (return (expression vec4 - (var_ref t) (var_ref s)))))
 ))


More information about the mesa-dev mailing list