Module: Mesa Branch: master Commit: aa973fc14e140753d3c5b47eda79e451c1dc61ed URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=aa973fc14e140753d3c5b47eda79e451c1dc61ed
Author: Boris Brezillon <[email protected]> Date: Fri Jan 24 09:22:48 2020 +0100 panfrost/midgard: Add a condense_writemask() helper This way we can convert an 8-bit writemask (Midgard specific representation) into the more common 1-bit/component representation. 8-bit mode is not supported yet, as we're not sure how the writemask is encoded for this mode. Signed-off-by: Boris Brezillon <[email protected]> Reviewed-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3536> --- src/panfrost/midgard/helpers.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/panfrost/midgard/helpers.h b/src/panfrost/midgard/helpers.h index d2bfc18273e..66223f3fd78 100644 --- a/src/panfrost/midgard/helpers.h +++ b/src/panfrost/midgard/helpers.h @@ -254,6 +254,28 @@ expand_writemask(unsigned mask, unsigned channels) return o; } +/* Tansform an expanded writemask (duplicated 8-bit format) into its condensed + * form (one bit per component) */ + +static inline unsigned +condense_writemask(unsigned expanded_mask, + unsigned bits_per_component) +{ + if (bits_per_component == 8) + unreachable("XXX TODO: sort out how 8-bit constant encoding works"); + + unsigned slots_per_component = bits_per_component / 16; + unsigned max_comp = (16 * 8) / bits_per_component; + unsigned condensed_mask = 0; + + for (unsigned i = 0; i < max_comp; i++) { + if (expanded_mask & (1 << (i * slots_per_component))) + condensed_mask |= (1 << i); + } + + return condensed_mask; +} + /* Coerce structs to integer */ static inline unsigned _______________________________________________ mesa-commit mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-commit
