mesa/src
Erik Faye-Lund 326e303175 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 <kusmabite@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2014-10-10 20:44:27 +02:00
..
egl util: Include in Android builds 2014-10-03 01:25:28 +01:00
gallium vc4: Use the fnv1 hash function instead of gallium util's crc32. 2014-10-10 15:49:34 +02:00
gbm gbm: Log at least one dlerror() when we fail to open any drivers. 2014-07-30 22:31:30 -07:00
getopt
glsl glsl: improve accuracy of atan() 2014-10-10 20:44:27 +02:00
glx glx/dri3: Provide error diagnostics when DRI3 allocation fails 2014-09-30 21:23:04 -07:00
gtest gtest: Update to 1.7.0. 2014-04-14 00:06:53 -07:00
hgl gallium/targets: Break haiku state_tracker out to own directory 2014-08-28 21:27:29 -04:00
loader loader: Check dlsym() did not fail in libudev_get_device_name_for_fd() 2014-09-23 10:25:02 +03:00
mapi mesa: remove last DJGPP remains 2014-09-27 15:20:49 +01:00
mesa mesa: fix error reported on gTexSubImage2D when level not valid 2014-10-10 15:01:51 +03:00
util util: Include in Android builds 2014-10-03 01:25:28 +01:00
Makefile.am automake: handle gallium SUBDIRs in gallium/Makefile 2014-08-13 00:46:54 +01:00
SConscript util: Move ralloc to a new src/util directory. 2014-08-04 11:06:58 -07:00