Mesa (main): r300: use nir lowering for sin and cos on R300 and R400

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Feb 11 16:18:39 UTC 2022


Module: Mesa
Branch: main
Commit: 1109381e0ebc11c1c31745e4f0f0383dc462493e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=1109381e0ebc11c1c31745e4f0f0383dc462493e

Author: Pavel Ondračka <pavel.ondracka at gmail.com>
Date:   Wed Feb  9 10:36:08 2022 +0100

r300: use nir lowering for sin and cos on R300 and R400

The nir approximation is a bit more precise so there is one more
instruction for the scalar version but if the shader actually uses
vector one or some other stuff like sin(x) followed by cos(x) we
save more.

This nir approximation importantly seems to have better precision
so this should also fix some piglits/dEQPs.

With my shader-db and faked R300:
total instructions in shared programs: 67751 -> 65978 (-2.62%)
instructions in affected programs: 8637 -> 6864 (-20.53%)
total temps in shared programs: 9191 -> 9137 (-0.59%)
temps in affected programs: 486 -> 432 (-11.11%)
total consts in shared programs: 45427 -> 45412 (-0.03%)
consts in affected programs: 856 -> 841 (-1.75%)
total lits in shared programs: 2317 -> 2346 (1.25%)
lits in affected programs: 69 -> 98 (42.03%)

Reviewed-by: Emma Anholt <emma at anholt.net>
Signed-off-by: Pavel Ondračka <pavel.ondracka at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14957>

---

 src/gallium/drivers/r300/r300_screen.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c
index 06be9f0d78d..4b176fe8de8 100644
--- a/src/gallium/drivers/r300/r300_screen.c
+++ b/src/gallium/drivers/r300/r300_screen.c
@@ -571,6 +571,7 @@ static const nir_shader_compiler_options r300_vs_compiler_options = {
    .lower_rotate = true,
    .lower_uniforms_to_ubo = true,
    .lower_vector_cmp = true,
+   .lower_sincos = true,
 
    /* Note: has HW loops support, but only 256 ALU instructions. */
    .max_unroll_iterations = 32,
@@ -596,6 +597,7 @@ static const nir_shader_compiler_options r300_fs_compiler_options = {
    .lower_rotate = true,
    .lower_uniforms_to_ubo = true,
    .lower_vector_cmp = true,
+   .lower_sincos = true,
 
     /* No HW loops support, so set it equal to ALU instr max */
    .max_unroll_iterations = 64,



More information about the mesa-commit mailing list