mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 15:48:36 +02:00
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>
(cherry picked from commit 0e1862a2ab)
This commit is contained in:
parent
933f7a68d1
commit
9ec4e8aa47
2 changed files with 11 additions and 8 deletions
|
|
@ -24,7 +24,7 @@
|
|||
"description": "panfrost: protect alpha calculation from accessing non-existent component",
|
||||
"nominated": true,
|
||||
"nomination_type": 0,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": null,
|
||||
"notes": null
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue