util: import public domain code for integer division by a constant
authorMarek Olšák <marek.olsak@amd.com>
Sun, 23 Sep 2018 16:57:51 +0000 (12:57 -0400)
committerJason Ekstrand <jason.ekstrand@intel.com>
Wed, 10 Oct 2018 18:13:12 +0000 (13:13 -0500)
commit2940c257a640e7c0f40a457c513a1bc199c204a4
tree876a76c9f751e8f0e8d282e13e95eaf95de45fbf
parent0dca6730b420f940794a51e8342f6c331934608f
util: import public domain code for integer division by a constant

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.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/util/Makefile.sources
src/util/fast_idiv_by_const.c [new file with mode: 0644]
src/util/fast_idiv_by_const.h [new file with mode: 0644]
src/util/meson.build