mesa/src/amd
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
..
addrlib amd: allow addrlib to enable SIMD if possible 2026-04-21 10:14:42 +00:00
ci glsl, spirv: Improve accuracy of asin() and acos() 2026-04-21 21:10:22 +00:00
common ac/parse_ib: Fix printing enc recon VAs on VCN5 2026-04-21 08:09:09 +00:00
compiler aco: use RegisterDemand::operator[] more 2026-04-21 11:16:26 +00:00
drm-shim ac/tests: use amdgpu shim devices 2026-04-14 12:06:20 +00:00
gmlib meson: Relax -Wmaybe-uninitialized errors 2025-09-16 06:16:20 +00:00
lanczoslib meson: Relax -Wmaybe-uninitialized errors 2025-09-16 06:16:20 +00:00
llvm ac,radv,radeonsi: don't use nir_intrinsic_base for FS inputs 2026-04-15 18:12:11 +00:00
packets amd: switch to new packet definitions for all packets 2026-04-10 03:42:45 +00:00
registers amd: switch to new packet definitions for all packets 2026-04-10 03:42:45 +00:00
vpelib amd/vpelib: Apply external CSC 2026-03-04 13:17:26 +08:00
vulkan vulkan,treewide: stop passing vk_device to vk_pipeline_robustness_state_fill() 2026-04-21 17:29:04 +00:00
meson.build radv/tests: require drm-shim and use it instead of RADV_FORCE_FAMILY 2025-11-19 07:11:05 +00:00