Module: Mesa
Branch: main
Commit: e664082d3507d790ac31f721e8900417efd3a95b
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e664082d3507d790ac31f721e8900417efd3a95b

Author: Alyssa Rosenzweig <[email protected]>
Date:   Sat Dec 17 23:56:52 2022 -0500

nir/lower_blend: No-op nir_color_mask if no mask

In this usual case, do a quick check to avoid generating 5 useless instructions
(mov/vec4 instructions). They'll get copypropped but that creates more work for
the optimizer and nir/lower_blend runs in a hot variant path on both Asahi and
Panfrost.

Signed-off-by: Alyssa Rosenzweig <[email protected]>
Acked-by: Emma Anholt <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20016>

---

 src/compiler/nir/nir_lower_blend.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/compiler/nir/nir_lower_blend.c 
b/src/compiler/nir/nir_lower_blend.c
index 610b3411fba..1b60f160e7a 100644
--- a/src/compiler/nir/nir_lower_blend.c
+++ b/src/compiler/nir/nir_lower_blend.c
@@ -503,8 +503,9 @@ nir_lower_blend_store(nir_builder *b, nir_intrinsic_instr 
*store,
       blended = nir_blend(b, options, rt, src, options->src1, dst);
    }
 
-   /* Apply a colormask */
-   blended = nir_color_mask(b, options->rt[rt].colormask, blended, dst);
+   /* Apply a colormask if necessary */
+   if (options->rt[rt].colormask != BITFIELD_MASK(4))
+      blended = nir_color_mask(b, options->rt[rt].colormask, blended, dst);
 
    const unsigned num_components = glsl_get_vector_elements(var->type);
 

Reply via email to