From fb29cef8ddabdd05aeddc5220017bb28a83bb19c Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sun, 7 Feb 2021 21:10:08 -0500 Subject: 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 Part-of: --- src/util/bitset.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/util/bitset.h') 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 -- cgit v1.2.3