nir: allow cloning indirect array derefs in nir_clone_deref_instr
but only if cloning within the same shader. This will be used to fix nir_lower_io_to_temporaries. Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32344>
This commit is contained in:
@@ -1202,9 +1202,18 @@ nir_clone_deref_instr(nir_builder *b, nir_variable *var,
|
||||
*/
|
||||
switch (deref->deref_type) {
|
||||
case nir_deref_type_array: {
|
||||
nir_load_const_instr *index =
|
||||
nir_instr_as_load_const(deref->arr.index.ssa->parent_instr);
|
||||
return nir_build_deref_array_imm(b, parent, index->value->i64);
|
||||
if (b->shader ==
|
||||
nir_cf_node_get_function(&deref->instr.block->cf_node)->function->shader) {
|
||||
/* Cloning within the same shader. */
|
||||
return nir_build_deref_array(b, parent, deref->arr.index.ssa);
|
||||
} else {
|
||||
/* Cloning to a different shader. The index must be constant because
|
||||
* we don't implement cloning the index SSA here.
|
||||
*/
|
||||
nir_load_const_instr *index =
|
||||
nir_instr_as_load_const(deref->arr.index.ssa->parent_instr);
|
||||
return nir_build_deref_array_imm(b, parent, index->value->i64);
|
||||
}
|
||||
}
|
||||
case nir_deref_type_ptr_as_array: {
|
||||
nir_load_const_instr *index =
|
||||
|
||||
Reference in New Issue
Block a user