panfrost: protect alpha calculation from accessing non-existent component
We had a "Don't read out-of-bounds" sanity check for creating an alpha when ATEST was needed, but that check happened only after we already did a bi_extract(), which meant that the bi_extract could get into trouble and assert() when there weren't enough components. Fixed by re-arranging the calculation. Signed-off-by: Eric R. Smith <eric.smith@collabora.com> Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com> Reviewed-by: Erik Faye-Lund <erik.faye-lund>@collabora.com> Cc: mesa-stable Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28045>
This commit is contained in:
@@ -837,15 +837,18 @@ bi_emit_fragment_out(bi_builder *b, nir_intrinsic_instr *instr)
|
||||
nir_alu_type T = nir_intrinsic_src_type(instr);
|
||||
|
||||
bi_index rgba = bi_src_index(&instr->src[0]);
|
||||
bi_index alpha = (T == nir_type_float16)
|
||||
? bi_half(bi_extract(b, rgba, 1), true)
|
||||
: (T == nir_type_float32) ? bi_extract(b, rgba, 3)
|
||||
: bi_dontcare(b);
|
||||
bi_index alpha;
|
||||
|
||||
/* Don't read out-of-bounds */
|
||||
if (nir_src_num_components(instr->src[0]) < 4)
|
||||
if (nir_src_num_components(instr->src[0]) < 4) {
|
||||
/* Don't read out-of-bounds */
|
||||
alpha = bi_imm_f32(1.0);
|
||||
|
||||
} else if (T == nir_type_float16) {
|
||||
alpha = bi_half(bi_extract(b, rgba, 1), true);
|
||||
} else if (T == nir_type_float32) {
|
||||
alpha = bi_extract(b, rgba, 3);
|
||||
} else {
|
||||
alpha = bi_dontcare(b);
|
||||
}
|
||||
bi_emit_atest(b, alpha);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user