From 7cd402c9c890b6f868299a79960bad5c70897f29 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Sat, 25 Sep 2021 14:08:58 +0200 Subject: [PATCH] nir/lower_blend: Shrink blended result if needed Make sure the new and old sources have the same number of components, otherwise the NIR validation pass complains. Signed-off-by: Boris Brezillon Reviewed-by: Alyssa Rosenzweig Part-of: --- src/compiler/nir/nir_lower_blend.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/compiler/nir/nir_lower_blend.c b/src/compiler/nir/nir_lower_blend.c index 659ecf9e70c..5e6a04f0ec7 100644 --- a/src/compiler/nir/nir_lower_blend.c +++ b/src/compiler/nir/nir_lower_blend.c @@ -374,6 +374,9 @@ nir_lower_blend_instr(nir_builder *b, nir_instr *instr, void *data) /* Apply a colormask */ blended = nir_color_mask(b, options->rt[rt].colormask, blended, dst); + if (src_num_comps != 4) + blended = nir_channels(b, blended, BITFIELD_MASK(src_num_comps)); + /* Write out the final color instead of the input */ nir_instr_rewrite_src_ssa(instr, &intr->src[1], blended); return true;