If a dual source blend colour is never written, src1 will be null and it will be
invalid to dereference it. src1 is dereferenced both for the f2fN instruction
but also if a dual blend factor is used... even if the latter isn't strictly
valid, segfaulting in the NIR pass seems a lot meaner than blending with zero.
The referenced commit hosed Asahi, causing anything that used blending to crash.
Panfrost is unaffected since it always supplies a dual colour due to our crude
construction of blend shaders.
Fixes:
83130165437 ("nir/lower_blend: Consume dual stores")
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21544>
unsigned rt,
nir_ssa_def *src, nir_ssa_def *src1, nir_ssa_def *dst)
{
+ /* Don't crash if src1 isn't written. It doesn't matter what dual colour we
+ * blend with in that case, as long as we don't dereference NULL.
+ */
+ if (!src1)
+ src1 = nir_imm_zero(b, 4, src->bit_size);
+
/* Grab the blend constant ahead of time */
nir_ssa_def *bconst;
if (options->scalar_blend_const) {