Mesa (master): freedreno/ir3: don't fetch unused tex components

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Dec 7 18:50:40 UTC 2018


Module: Mesa
Branch: master
Commit: 0d240c22141d9f5d387b8a3b6d18dfd9688b136d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0d240c22141d9f5d387b8a3b6d18dfd9688b136d

Author: Rob Clark <robdclark at gmail.com>
Date:   Tue Dec  4 09:52:14 2018 -0500

freedreno/ir3: don't fetch unused tex components

Detect when a component of an (for example) texture fetch is unused and
propagate the updated wrmask back to the parent instruction.

Signed-off-by: Rob Clark <robdclark at gmail.com>

---

 src/freedreno/ir3/ir3_depth.c | 27 +++++++++++++++++++++++++++
 src/freedreno/ir3/ir3_ra.c    |  2 ++
 2 files changed, 29 insertions(+)

diff --git a/src/freedreno/ir3/ir3_depth.c b/src/freedreno/ir3/ir3_depth.c
index 73bf5e1992..77f9af6173 100644
--- a/src/freedreno/ir3/ir3_depth.c
+++ b/src/freedreno/ir3/ir3_depth.c
@@ -174,6 +174,33 @@ remove_unused_by_block(struct ir3_block *block)
 		if (instr->opc == OPC_END)
 			continue;
 		if (instr->flags & IR3_INSTR_UNUSED) {
+			if (instr->opc == OPC_META_FO) {
+				struct ir3_instruction *src = ssa(instr->regs[1]);
+				if (src->regs[0]->wrmask > 1) {
+					unsigned newn, lastn;
+
+					lastn = util_last_bit(src->regs[0]->wrmask);
+					src->regs[0]->wrmask &= ~(1 << instr->fo.off);
+					newn = util_last_bit(src->regs[0]->wrmask);
+
+					/* prune no-longer needed right-neighbors.  We could
+					 * probably do the same for left-neighbors (ie. tex
+					 * fetch that only need .yw components), but that
+					 * makes RA a bit more confusing than it already is
+					 */
+					if (newn < lastn) {
+						struct ir3_instruction *n = ir3_neighbor_first(instr);
+						for (unsigned i = 1; i < newn; i++) {
+							n = n->cp.right;
+						}
+						// XXX I don't think n should be null here!
+						if (n) {
+							debug_assert(n->cp.right->flags & IR3_INSTR_UNUSED);
+							n->cp.right = NULL;
+						}
+					}
+				}
+			}
 			list_delinit(&instr->node);
 			progress = true;
 		}
diff --git a/src/freedreno/ir3/ir3_ra.c b/src/freedreno/ir3/ir3_ra.c
index ad09c4018d..b202c14137 100644
--- a/src/freedreno/ir3/ir3_ra.c
+++ b/src/freedreno/ir3/ir3_ra.c
@@ -509,6 +509,8 @@ get_definer(struct ir3_ra_ctx *ctx, struct ir3_instruction *instr,
 		d = dd;
 	}
 
+	debug_assert(d->opc != OPC_META_FO);
+
 	id->defn = d;
 	id->sz = *sz;
 	id->off = *off;




More information about the mesa-commit mailing list