mesa/src/gallium/drivers
Eric R. Smith 4ae192a3d9
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
glsl, spirv: Improve accuracy of asin() and acos()
The polynomial used for asin_expr() was suboptimal (and its source was
not documented).

A better approximation is found in the _Handbook_of_Mathematical_Functions_
by Abramowitz and Stegun, which is used in Nvidia's Cg toolkit. However,
while this approximation gives a good absolute error bound, its relative
error exceeds the 4096 ulp allowed by the Vulkan spec. Taking a page
from the spirv implementation of asin(), we implement a piecewise
approximation where a Taylor series is used for small values of |x|.
This patch also harmonizes the GLSL and Vulkan implementations by moving
the implementation to common code (nir_builder).

Running tests on asin() with a grid of 64000 samples between 0.0 and +1.0,
the original asin() at 32 bits has:
```
                       glsl                       spirv
  RMSE:            1.756451e-04                 1.609091e-04
  worst abs error: 3.904104e-04 at 0.937001     3.904104e-04 at 0.937001
  worst ulp error: 11800 at 6.2499e-05          3826 at 0.841331
```
whereas the new implementation has for both:
```
  RMSE:            2.528056e-05
  worst abs error: 4.962087e-05 at 0.451149
  worst ulp error: 2379 at 0.215106
```

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com>
Acked-by: Mel Henning <mhenning@darkrefraction.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40862>
2026-04-21 21:10:22 +00:00
..
asahi nir/gather_info: clear interpolation qualifiers only in fragment stage 2026-04-19 10:10:15 +00:00
crocus iris,crocus: remove benign but unsupported cap 2026-04-20 17:09:20 +00:00
d3d12 microsoft/compiler: Back-propagate interpolator modes from FS 2026-04-21 18:31:31 +00:00
ethosu ethosu: Move ethosu_allocate_feature_map() to ethosu_lower.c 2026-04-02 21:04:25 +00:00
etnaviv nir: add and use block predecessor helpers 2026-04-08 15:06:32 +00:00
freedreno ir3: Don't reset immediate count to 0 after lowering 2026-04-16 05:40:14 +00:00
i915 gallium: kill off pipe_surface::context 2026-03-23 16:58:15 +00:00
iris iris,crocus: remove benign but unsupported cap 2026-04-20 17:09:20 +00:00
lima gallium: kill off pipe_surface::context 2026-03-23 16:58:15 +00:00
llvmpipe llvmpipe: drop support for tgsi_tex_txf_lz cap 2026-04-20 17:09:20 +00:00
nouveau gallium: remove defunct pipe-cap 2026-04-20 17:09:21 +00:00
panfrost pan/lib: validate data_size_B in drivers 2026-04-20 16:00:56 +00:00
r300 r300/ci: update expectations 2026-04-12 18:49:23 +00:00
r600 r600: fix atomic_counter_post_dec 2026-04-20 15:04:42 +00:00
radeonsi radeonsi: remove old, unsupported cap 2026-04-20 17:09:20 +00:00
rocket gallium: add pipe_ml_device, pipe_screen::get_ml_device() 2026-03-25 16:58:05 +00:00
softpipe softpipe: delete pipe_context::create_surface 2026-03-23 16:58:11 +00:00
svga Uprev Piglit to 11ce9eb56edb00e6a7702d13168cc827ce5e0cbd 2026-04-10 21:21:52 +00:00
tegra tegra: delete pipe_context surface hooks 2026-03-23 16:58:13 +00:00
v3d v3d: mark mapped BO as initialized for valgrind 2026-04-16 07:55:39 +00:00
vc4 broadcom: use Mesa logging functions 2026-04-06 07:40:55 +00:00
virgl glsl, spirv: Improve accuracy of asin() and acos() 2026-04-21 21:10:22 +00:00
zink glsl, spirv: Improve accuracy of asin() and acos() 2026-04-21 21:10:22 +00:00