util: import public domain code for integer division by a constant

Graphics / Mesa 3D Graphics Library / Mesa - Marek Olšák [amd.com] - 10 October 2018 18:13 EDT

Compilers can use this to generate optimal code for integer division by a constant.

Additionally, an unsigned division by a uniform that is constant but not known at compile time can still be optimized by passing 2-4 division factors to the shader as uniforms and executing one of the fast_udiv*
variants. The signed division algorithm doesn't have this capability.

2940c257a6 util: import public domain code for integer division by a constant
src/util/Makefile.sources | 2 +
src/util/fast_idiv_by_const.c | 224 ++++++++++++++++++++++++++++++++++++++++++
src/util/fast_idiv_by_const.h | 137 ++++++++++++++++++++++++++
src/util/meson.build | 2 +
4 files changed, 365 insertions(+)

Upstream: cgit.freedesktop.org


  • Share