[Mesa-dev] [PATCH 0/4] radeonsi: add DDIV for double division instead of RCP+MUL

Nicolai Hähnle nhaehnle at gmail.com
Mon Jan 16 16:20:39 UTC 2017


Hi all,

This series fixes one of the last remaining CTS failures for radeonsi,
GL45-CTS.gpu_shader_fp64.built_in_functions.

Specifically, that test checks that mod(13.375, 13.375) == 0.0. As part of
the lowering of modulo, we compute 13.375 / 13.375, which is of course 1.0.
Unfortunately, when each of the steps in 13.375 * (1.0 / 13.375) is
computed with double precision and rounded to nearest, the result is the
largest number strictly smaller than 1.0. Computing the floor of that
becomes 0.0, hence we get a very wrong result.

With this series, we keep the division as a division, and let LLVM produce
the correct code for it. The resulting shader code is actually faster
than the RCP+MUL sequence, at least as long as the denominator isn't
re-used (not that anybody really cares about the performance of double
precision in OpenGL, but whatever). Please review!

Thanks,
Nicolai
--
 src/compiler/glsl/ir_optimization.h          |  4 +++-
 src/compiler/glsl/lower_instructions.cpp     | 19 ++++++++++--------
 .../auxiliary/gallivm/lp_bld_tgsi_action.c   |  2 ++
 src/gallium/auxiliary/tgsi/tgsi_info.c       |  2 ++
 src/gallium/docs/source/screen.rst           |  2 ++
 src/gallium/docs/source/tgsi.rst             |  9 +++++++++
 .../drivers/freedreno/freedreno_screen.c     |  3 ++-
 src/gallium/drivers/i915/i915_screen.c       |  1 +
 src/gallium/drivers/ilo/ilo_screen.c         |  1 +
 src/gallium/drivers/llvmpipe/lp_screen.c     |  1 +
 .../drivers/nouveau/nv30/nv30_screen.c       |  1 +
 .../drivers/nouveau/nv50/nv50_screen.c       |  1 +
 .../drivers/nouveau/nvc0/nvc0_screen.c       |  1 +
 src/gallium/drivers/r300/r300_screen.c       |  1 +
 src/gallium/drivers/r600/r600_pipe.c         |  3 ++-
 src/gallium/drivers/radeonsi/si_pipe.c       |  3 ++-
 src/gallium/drivers/softpipe/sp_screen.c     |  1 +
 src/gallium/drivers/svga/svga_screen.c       |  1 +
 src/gallium/drivers/swr/swr_screen.cpp       |  1 +
 src/gallium/drivers/vc4/vc4_screen.c         |  1 +
 src/gallium/drivers/virgl/virgl_screen.c     |  1 +
 src/gallium/include/pipe/p_defines.h         |  1 +
 src/gallium/include/pipe/p_shader_tokens.h   |  5 ++++-
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp   | 11 +++++-----
 24 files changed, 57 insertions(+), 19 deletions(-)



More information about the mesa-dev mailing list