freedreno/ir3: add is_tex_or_prefetch()
authorRob Clark <robdclark@chromium.org>
Sat, 18 Jan 2020 19:03:38 +0000 (11:03 -0800)
committerMarge Bot <eric+marge@anholt.net>
Sat, 1 Feb 2020 02:40:22 +0000 (02:40 +0000)
Some of the aspects of tex prefetch are in common with normal tex
instructions, such as having a wrmask to control which components
are written.  Add a helper for this.

This should result in actually using the prefetch wrmask to avoid
fetching unneeded components.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3569>

src/freedreno/ir3/ir3.h
src/freedreno/ir3/ir3_depth.c
src/freedreno/ir3/ir3_legalize.c

index f78a7d6f3646243ea360a5ade5d556c0491cd25e..f1c15ca2519e47f359eb9e858419fe742c5ad64a 100644 (file)
@@ -710,6 +710,11 @@ static inline bool is_tex(struct ir3_instruction *instr)
        return (opc_cat(instr->opc) == 5);
 }
 
+static inline bool is_tex_or_prefetch(struct ir3_instruction *instr)
+{
+       return is_tex(instr) || (instr->opc == OPC_META_TEX_PREFETCH);
+}
+
 static inline bool is_mem(struct ir3_instruction *instr)
 {
        return (opc_cat(instr->opc) == 6);
index 59ea3af407bbc2de23b9f4d986829b49e4441488..135d4365d2ea5b3123705480e65ff093cf32a675 100644 (file)
@@ -114,7 +114,7 @@ remove_unused_by_block(struct ir3_block *block)
                                /* tex (cat5) instructions have a writemask, so we can
                                 * mask off unused components.  Other instructions do not.
                                 */
-                               if (is_tex(src) && (src->regs[0]->wrmask > 1)) {
+                               if (is_tex_or_prefetch(src) && (src->regs[0]->wrmask > 1)) {
                                        src->regs[0]->wrmask &= ~(1 << instr->split.off);
 
                                        /* prune no-longer needed right-neighbors.  We could
index 458629021a4caf0ab810ace270b8bdb90a6794b0..9c349bf27457eea2e199a1c770295f7fc5551f07 100644 (file)
@@ -236,7 +236,7 @@ legalize_block(struct ir3_legalize_ctx *ctx, struct ir3_block *block)
                if (is_sfu(n))
                        regmask_set(&state->needs_ss, n->regs[0]);
 
-               if (is_tex(n) || (n->opc == OPC_META_TEX_PREFETCH)) {
+               if (is_tex_or_prefetch(n)) {
                        regmask_set(&state->needs_sy, n->regs[0]);
                        ctx->so->need_pixlod = true;
                        if (n->opc == OPC_META_TEX_PREFETCH)