vc4/lower_blend: don't read non-existent channels

nir_lower_texcoord_replace_late had swapped parameters in nir_undef.

Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32173>
This commit is contained in:
Marek Olšák 2024-11-15 15:26:42 -05:00 committed by Marge Bot
parent 4da5b11ca9
commit 3affe3cb17
4 changed files with 10 additions and 19 deletions

View File

@ -767,6 +767,15 @@ nir_channel(nir_builder *b, nir_def *def, unsigned c)
return nir_swizzle(b, def, &c, 1);
}
static inline nir_def *
nir_channel_or_undef(nir_builder *b, nir_def *def, signed int channel)
{
if (channel >= 0 && channel < def->num_components)
return nir_channel(b, def, channel);
else
return nir_undef(b, 1, def->bit_size);
}
static inline nir_def *
nir_channels(nir_builder *b, nir_def *def, nir_component_mask_t mask)
{

View File

@ -13,15 +13,6 @@ struct opts {
bool point_coord_is_sysval;
};
static nir_def *
nir_channel_or_undef(nir_builder *b, nir_def *def, signed int channel)
{
if (channel >= 0 && channel < def->num_components)
return nir_channel(b, def, channel);
else
return nir_undef(b, def->bit_size, 1);
}
static bool
pass(nir_builder *b, nir_instr *instr, void *data)
{

View File

@ -1473,15 +1473,6 @@ agx_nir_lower_clip_m1_1(nir_builder *b, nir_intrinsic_instr *intr,
return true;
}
static nir_def *
nir_channel_or_undef(nir_builder *b, nir_def *def, signed int channel)
{
if (channel >= 0 && channel < def->num_components)
return nir_channel(b, def, channel);
else
return nir_undef(b, 1, def->bit_size);
}
/*
* To implement point sprites, we'll replace TEX0...7 with point coordinate
* reads as required. However, the .zw needs to read back 0.0/1.0. This pass

View File

@ -443,7 +443,7 @@ vc4_nir_blend_pipeline(struct vc4_compile *c, nir_builder *b, nir_def *src,
nir_def *dst_vec4 = nir_unpack_unorm_4x8(b, packed_dst_color);
nir_def *src_color[4], *unpacked_dst_color[4];
for (unsigned i = 0; i < 4; i++) {
src_color[i] = nir_channel(b, src, i);
src_color[i] = nir_channel_or_undef(b, src, i);
unpacked_dst_color[i] = nir_channel(b, dst_vec4, i);
}