About Social Code
aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorMarek Olšák <marek.olsak@amd.com>2021-02-07 21:10:08 -0500
committerMarge Bot <eric+marge@anholt.net>2021-04-13 05:07:42 +0000
commitfb29cef8ddabdd05aeddc5220017bb28a83bb19c (patch)
treeadc5ba499c751fff9726ea3f2d23e153e253712b /src/util
parent73f532e5bfd702bac6db9d34e1464d0f997c3cf0 (diff)
nir: add many passes that lower and optimize 16-bit input/outputs and samplers
Added: * a pass that renumbers bases of IO intrinsics * a pass that converts mediump IO to 16 bits, optionally using the new packed varying slots * a pass that sets (forces) mediump in IO intrinsics (for testing) * a pass that remaps VARYING_SLOT_VAR[0..15]_16BIT to VARYING_SLOT_VAR[0..31] (if some shader stages don't want packed varyings) * a pass that folds type conversions around texture opcodes into those opcodes (e.g. tex(f2f32(coord), ..) is changed into tex accepting f16) * a pass that changes (legalizes) sampler src and dst types based on specified hw constraints (e.g. derivatives must be the same type as coordinates) Reviewed-by: Matt Turner <mattst88@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9050>
Diffstat (limited to 'src/util')
-rw-r--r--src/util/bitset.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/util/bitset.h b/src/util/bitset.h
index 29de65e839c..b9e968293b1 100644
--- a/src/util/bitset.h
+++ b/src/util/bitset.h
@@ -80,6 +80,25 @@
((x)[BITSET_BITWORD(b)] &= ~BITSET_RANGE(b, e)) : \
(assert (!"BITSET_CLEAR_RANGE: bit range crosses word boundary"), 0))
+static inline unsigned
+__bitset_prefix_sum(const BITSET_WORD *x, unsigned b, unsigned n)
+{
+ unsigned prefix = 0;
+
+ for (unsigned i = 0; i < n; i++) {
+ if ((i + 1) * BITSET_WORDBITS <= b) {
+ prefix += util_bitcount(x[i]);
+ } else {
+ prefix += util_bitcount(x[i] & BITFIELD_MASK(b - i * BITSET_WORDBITS));
+ break;
+ }
+ }
+ return prefix;
+}
+
+#define BITSET_PREFIX_SUM(x, b) \
+ __bitset_prefix_sum(x, b, ARRAY_SIZE(x))
+
/* Get first bit set in a bitset.
*/
static inline int