mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-07 19:30:12 +01:00
nir: add helper to copy const_index[]
It seems less brittle to not assume they are in the same order for src and dst instructions. Signed-off-by: Rob Clark <robdclark@chromium.org> Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com> Reviewed-by: Eric Anholt <eric@anholt.net>
This commit is contained in:
parent
3d3cfea78b
commit
a506d49fae
2 changed files with 28 additions and 2 deletions
|
|
@ -1763,6 +1763,33 @@ nir_intrinsic_dest_components(nir_intrinsic_instr *intr)
|
|||
return intr->num_components;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to copy const_index[] from src to dst, without assuming they
|
||||
* match in order.
|
||||
*/
|
||||
static inline void
|
||||
nir_intrinsic_copy_const_indices(nir_intrinsic_instr *dst, nir_intrinsic_instr *src)
|
||||
{
|
||||
if (src->intrinsic == dst->intrinsic) {
|
||||
memcpy(dst->const_index, src->const_index, sizeof(dst->const_index));
|
||||
return;
|
||||
}
|
||||
|
||||
const nir_intrinsic_info *src_info = &nir_intrinsic_infos[src->intrinsic];
|
||||
const nir_intrinsic_info *dst_info = &nir_intrinsic_infos[dst->intrinsic];
|
||||
|
||||
for (unsigned i = 0; i < NIR_INTRINSIC_NUM_INDEX_FLAGS; i++) {
|
||||
if (src_info->index_map[i] == 0)
|
||||
continue;
|
||||
|
||||
/* 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];
|
||||
}
|
||||
}
|
||||
|
||||
#define INTRINSIC_IDX_ACCESSORS(name, flag, type) \
|
||||
static inline type \
|
||||
nir_intrinsic_##name(const nir_intrinsic_instr *instr) \
|
||||
|
|
|
|||
|
|
@ -217,8 +217,7 @@ lower_offset_for_ssbo(nir_intrinsic_instr *intrinsic, nir_builder *b,
|
|||
for (unsigned i = 0; i < num_srcs; i++)
|
||||
new_intrinsic->src[i] = nir_src_for_ssa(intrinsic->src[i].ssa);
|
||||
|
||||
for (unsigned i = 0; i < NIR_INTRINSIC_MAX_CONST_INDEX; i++)
|
||||
new_intrinsic->const_index[i] = intrinsic->const_index[i];
|
||||
nir_intrinsic_copy_const_indices(new_intrinsic, intrinsic);
|
||||
|
||||
new_intrinsic->num_components = intrinsic->num_components;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue