nir/builder: Add a build_deref_array_imm helper

Unlike most of the cases in which we do this by hand, the new helper
properly handles non-32-bit pointers.

Reviewed-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
This commit is contained in:
Jason Ekstrand
2019-03-07 11:45:13 -06:00
committed by Jason Ekstrand
parent fcf2a0122e
commit 1664de5924
8 changed files with 26 additions and 18 deletions
@@ -44,7 +44,7 @@ build_constant_load(nir_builder *b, nir_deref_instr *deref, nir_constant *c)
nir_load_const_instr_create(b->shader, rows, bit_size);
load->value = c->values[i];
nir_builder_instr_insert(b, &load->instr);
nir_store_deref(b, nir_build_deref_array(b, deref, nir_imm_int(b, i)),
nir_store_deref(b, nir_build_deref_array_imm(b, deref, i),
&load->def, ~0);
}
} else if (glsl_type_is_struct_or_ifc(deref->type)) {
@@ -58,7 +58,7 @@ build_constant_load(nir_builder *b, nir_deref_instr *deref, nir_constant *c)
unsigned len = glsl_get_length(deref->type);
for (unsigned i = 0; i < len; i++) {
build_constant_load(b,
nir_build_deref_array(b, deref, nir_imm_int(b, i)),
nir_build_deref_array_imm(b, deref, i),
c->elements[i]);
}
}