summaryrefslogtreecommitdiffstats
path: root/src/util/register_allocate.h
diff options
context:
space:
mode:
authorErik Faye-Lund <[email protected]>2014-09-26 18:11:19 +0200
committerOlivier Galibert <[email protected]>2014-10-10 20:44:27 +0200
commit326e303175ab700d59602f0e344e8d84e15f1aa8 (patch)
tree45c92344e8824cbc66021a1b1a244bc23d8deded /src/util/register_allocate.h
parent070b2c2efc415f459e9c32415b401609acded565 (diff)
glsl: improve accuracy of atan()
Our current atan()-approximation is pretty inaccurate at 1.0, so let's try to improve the situation by doing a direct approximation without going through atan. This new implementation uses an 11th degree polynomial to approximate atan in the [-1..1] range, and the following identitiy to reduce the entire range to [-1..1]: atan(x) = 0.5 * pi * sign(x) - atan(1.0 / x) This range-reduction idea is taken from the paper "Fast computation of Arctangent Functions for Embedded Applications: A Comparative Analysis" (Ukil et al. 2011). The polynomial that approximates atan(x) is: x * 0.9999793128310355 - x^3 * 0.3326756418091246 + x^5 * 0.1938924977115610 - x^7 * 0.1173503194786851 + x^9 * 0.0536813784310406 - x^11 * 0.0121323213173444 This polynomial was found with the following GNU Octave script: x = linspace(0, 1); y = atan(x); n = [1, 3, 5, 7, 9, 11]; format long; polyfitc(x, y, n) The polyfitc function is not built-in, but too long to include here. It can be downloaded from the following URL: http://www.mathworks.com/matlabcentral/fileexchange/47851-constraint-polynomial-fit/content/polyfitc.m This fixes the following piglit test: shaders/glsl-const-folding-01 Signed-off-by: Erik Faye-Lund <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/util/register_allocate.h')
0 files changed, 0 insertions, 0 deletions