From e664082d3507d790ac31f721e8900417efd3a95b Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Sat, 17 Dec 2022 23:56:52 -0500 Subject: [PATCH] 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 Acked-by: Emma Anholt Part-of: --- 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);