nir: fix nir_intrinsic_copy_const_indices for large indices

Fixes: 4ba581887e ("nir: support intrinsic indicies larger than 32 bits")

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40323>
This commit is contained in:
Georg Lehmann 2026-03-11 09:49:36 +01:00 committed by Marge Bot
parent c9b2986607
commit 26f5a6d6cc
2 changed files with 18 additions and 2 deletions

View file

@ -3353,8 +3353,11 @@ nir_intrinsic_copy_const_indices(nir_intrinsic_instr *dst, nir_intrinsic_instr *
/* require that dst instruction also uses the same const_index[]: */
assert(dst_info->index_map[i] > 0);
dst->const_index[dst_info->index_map[i] - 1] =
src->const_index[src_info->index_map[i] - 1];
unsigned size = nir_intrinsic_index_size(i);
memcpy(&dst->const_index[dst_info->index_map[i] - 1],
&src->const_index[src_info->index_map[i] - 1],
sizeof(dst->const_index[0]) * size);
}
}

View file

@ -73,6 +73,19 @@ nir_intrinsic_has_${name}(const nir_intrinsic_instr *instr)
}
% endfor
static inline unsigned
nir_intrinsic_index_size(nir_intrinsic_index_flag index)
{
switch (index) {
% for index in INTR_INDICES:
% if index.size != 1:
case ${"NIR_INTRINSIC_" + index.name.upper()}: return ${index.size};
% endif
% endfor
default: return 1;
}
}
#endif /* _NIR_INTRINSICS_INDICES_ */
"""