Mesa (master): pan/midgard: Bytemasks should round up, not round down
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sat Jan 18 14:33:39 UTC 2020
Module: Mesa
Branch: master
Commit: 13c32e5fede9c3ff50d9c6da888914a713654c76
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=13c32e5fede9c3ff50d9c6da888914a713654c76
Author: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Date: Fri Jan 10 18:04:39 2020 -0500
pan/midgard: Bytemasks should round up, not round down
Otherwise we'll lost components in DCE.
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3462>
---
src/panfrost/midgard/compiler.h | 2 +-
src/panfrost/midgard/midgard_opt_dce.c | 2 +-
src/panfrost/midgard/mir.c | 13 ++++++-------
3 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/panfrost/midgard/compiler.h b/src/panfrost/midgard/compiler.h
index 172b6d70f69..ab9cc819ef6 100644
--- a/src/panfrost/midgard/compiler.h
+++ b/src/panfrost/midgard/compiler.h
@@ -537,7 +537,7 @@ midgard_reg_mode mir_mode_for_destsize(unsigned size);
uint16_t mir_from_bytemask(uint16_t bytemask, midgard_reg_mode mode);
uint16_t mir_to_bytemask(midgard_reg_mode mode, unsigned mask);
uint16_t mir_bytemask(midgard_instruction *ins);
-uint16_t mir_round_bytemask_down(uint16_t mask, midgard_reg_mode mode);
+uint16_t mir_round_bytemask_up(uint16_t mask, midgard_reg_mode mode);
void mir_set_bytemask(midgard_instruction *ins, uint16_t bytemask);
unsigned mir_upper_override(midgard_instruction *ins);
diff --git a/src/panfrost/midgard/midgard_opt_dce.c b/src/panfrost/midgard/midgard_opt_dce.c
index aaac84fe16e..0b2823be782 100644
--- a/src/panfrost/midgard/midgard_opt_dce.c
+++ b/src/panfrost/midgard/midgard_opt_dce.c
@@ -74,7 +74,7 @@ midgard_opt_dead_code_eliminate(compiler_context *ctx, midgard_block *block)
midgard_reg_mode mode = mir_typesize(ins);
unsigned oldmask = ins->mask;
- unsigned rounded = mir_round_bytemask_down(live[ins->dest], mode);
+ unsigned rounded = mir_round_bytemask_up(live[ins->dest], mode);
unsigned cmask = mir_from_bytemask(rounded, mode);
ins->mask &= cmask;
diff --git a/src/panfrost/midgard/mir.c b/src/panfrost/midgard/mir.c
index 506bcabe656..d4ce935934c 100644
--- a/src/panfrost/midgard/mir.c
+++ b/src/panfrost/midgard/mir.c
@@ -381,22 +381,21 @@ mir_from_bytemask(uint16_t bytemask, midgard_reg_mode mode)
return value;
}
-/* Rounds down a bytemask to fit a given component count. Iterate each
- * component, and check if all bytes in the component are masked on */
+/* Rounds up a bytemask to fill a given component count. Iterate each
+ * component, and check if any bytes in the component are masked on */
uint16_t
-mir_round_bytemask_down(uint16_t mask, midgard_reg_mode mode)
+mir_round_bytemask_up(uint16_t mask, midgard_reg_mode mode)
{
unsigned bytes = mir_bytes_for_mode(mode);
unsigned maxmask = mask_of(bytes);
unsigned channels = 16 / bytes;
for (unsigned c = 0; c < channels; ++c) {
- /* Get bytes in component */
- unsigned submask = (mask >> (c * bytes)) & maxmask;
+ unsigned submask = maxmask << (c * bytes);
- if (submask != maxmask)
- mask &= ~(maxmask << (c * bytes));
+ if (mask & submask)
+ mask |= submask;
}
return mask;
More information about the mesa-commit
mailing list