From c62804ed7d17d0c254308a8a9a0ab0f0bc83818e Mon Sep 17 00:00:00 2001 From: Fabian Bieler Date: Mon, 22 Apr 2013 19:50:51 +0200 Subject: [PATCH] glsl: Improve the accuracy of the asin() builtin function. To: mesa-dev@lists.freedesktop.org Extended the 3rd degree Series by two elements to 5th degree. The function is now approximated by: asin(x) = sign(x) * (pi/2 - pi/2 * sqrt(1 - |x|) * (1 + |x| * ((1/2 - 2/pi) + |x| * (A + |x| * (B + |x| * (C + |x| * D)))))) with constants A, B, C, D found by numerical fitting. --- src/glsl/builtins/ir/asin.ir | 80 +++++++++++++++++++++++++++++------------- 1 file changed, 56 insertions(+), 24 deletions(-) diff --git a/src/glsl/builtins/ir/asin.ir b/src/glsl/builtins/ir/asin.ir index 45d9e67..4259447 100644 --- a/src/glsl/builtins/ir/asin.ir +++ b/src/glsl/builtins/ir/asin.ir @@ -19,12 +19,20 @@ (constant float (-0.21460183)) (expression float * (expression float abs (var_ref x)) - (expression float + - (constant float (0.086566724)) - (expression float * - (expression float abs (var_ref x)) - (constant float (-0.03102955)) - )))))))))))) + (expression float + + (constant float (0.08873435)) + (expression float * + (expression float abs (var_ref x)) + (expression float + + (constant float (-0.047800794)) + (expression float * + (expression float abs (var_ref x)) + (expression float + + (constant float (0.023164911)) + (expression float * + (expression float abs (var_ref x)) + (constant float (-0.006116644)) + )))))))))))))))) (signature vec2 (parameters @@ -46,12 +54,20 @@ (constant float (-0.21460183)) (expression vec2 * (expression vec2 abs (var_ref x)) - (expression vec2 + - (constant float (0.086566724)) - (expression vec2 * - (expression vec2 abs (var_ref x)) - (constant float (-0.03102955)) - )))))))))))) + (expression vec2 + + (constant float (0.08873435)) + (expression vec2 * + (expression vec2 abs (var_ref x)) + (expression vec2 + + (constant float (-0.047800794)) + (expression vec2 * + (expression vec2 abs (var_ref x)) + (expression vec2 + + (constant float (0.023164911)) + (expression vec2 * + (expression vec2 abs (var_ref x)) + (constant float (-0.006116644)) + )))))))))))))))) (signature vec3 (parameters @@ -73,12 +89,20 @@ (constant float (-0.21460183)) (expression vec3 * (expression vec3 abs (var_ref x)) - (expression vec3 + - (constant float (0.086566724)) - (expression vec3 * - (expression vec3 abs (var_ref x)) - (constant float (-0.03102955)) - )))))))))))) + (expression vec3 + + (constant float (0.08873435)) + (expression vec3 * + (expression vec3 abs (var_ref x)) + (expression vec3 + + (constant float (-0.047800794)) + (expression vec3 * + (expression vec3 abs (var_ref x)) + (expression vec3 + + (constant float (0.023164911)) + (expression vec3 * + (expression vec3 abs (var_ref x)) + (constant float (-0.006116644)) + )))))))))))))))) (signature vec4 (parameters @@ -100,10 +124,18 @@ (constant float (-0.21460183)) (expression vec4 * (expression vec4 abs (var_ref x)) - (expression vec4 + - (constant float (0.086566724)) - (expression vec4 * - (expression vec4 abs (var_ref x)) - (constant float (-0.03102955)) - )))))))))))) + (expression vec4 + + (constant float (0.08873435)) + (expression vec4 * + (expression vec4 abs (var_ref x)) + (expression vec4 + + (constant float (-0.047800794)) + (expression vec4 * + (expression vec4 abs (var_ref x)) + (expression vec4 + + (constant float (0.023164911)) + (expression vec4 * + (expression vec4 abs (var_ref x)) + (constant float (-0.006116644)) + )))))))))))))))) )) -- 1.7.10.4