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 <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13060>
This commit is contained in:
Boris Brezillon 2021-09-25 14:08:58 +02:00
parent 3e07b8d4f8
commit 7cd402c9c8

View file

@ -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;