mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 19:40:10 +01:00
pan/bi: Handle small vectors in bi_src_index()
bit_size <= 32 does not actually guarantee a single component, which nir_src_as_uint() requires. We could just check num_components == 1 but it's easy enough to support any vector that fits in 32 bits. Cc: mesa-stable Reviewed-by: Romaric Jodin <rjodin@google.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38772>
This commit is contained in:
parent
a051d4ee6b
commit
d3a890a58e
1 changed files with 11 additions and 4 deletions
|
|
@ -1229,11 +1229,18 @@ bi_def_index(nir_def *def)
|
|||
static inline bi_index
|
||||
bi_src_index(nir_src *src)
|
||||
{
|
||||
if (nir_src_is_const(*src) && nir_src_bit_size(*src) <= 32) {
|
||||
return bi_imm_u32(nir_src_as_uint(*src));
|
||||
} else {
|
||||
return bi_def_index(src->ssa);
|
||||
if (nir_src_is_const(*src)) {
|
||||
unsigned bit_size = nir_src_bit_size(*src);
|
||||
unsigned num_comps = nir_src_num_components(*src);
|
||||
if (bit_size * num_comps <= 32) {
|
||||
uint32_t imm = 0;
|
||||
for (uint32_t i = 0; i < num_comps; i++)
|
||||
imm |= nir_src_comp_as_uint(*src, i) << (i * bit_size);
|
||||
return bi_imm_u32(imm);
|
||||
}
|
||||
}
|
||||
|
||||
return bi_def_index(src->ssa);
|
||||
}
|
||||
|
||||
/* Iterators for Bifrost IR */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue