nir: Add a ptr_as_array deref type

Graphics / Mesa 3D Graphics Library / Mesa - Jason Ekstrand [intel.com] - 8 January 2019 00:38 EST

These correspond directly to SPIR-V's OpPtrAccessChain. As such, they treat whatever their parent gives them as if it's the first element in some array and dereferences that array. If the parent is, itself, an array deref, then the two indices can just be added together to get the final array deref. However, it can also be used in cases where what you have is a dereference to some random vec2 value somewhere. In this case, we require a cast before the ptr_as_array and use the ptr_stride field in the cast to provide a stride for the ptr_as_array derefs.

e94a027af8 nir: Add a ptr_as_array deref type
src/compiler/nir/nir.c | 6 ++++--
src/compiler/nir/nir.h | 7 +++++++
src/compiler/nir/nir_builder.h | 29 ++++++++++++++++++++++++++++-
src/compiler/nir/nir_clone.c | 6 +++++-
src/compiler/nir/nir_deref.c | 20 +++++++++++++++++++-
src/compiler/nir/nir_instr_set.c | 13 +++++++++++--
src/compiler/nir/nir_opt_copy_propagate.c | 3 ++-
src/compiler/nir/nir_print.c | 6 +++++-
src/compiler/nir/nir_serialize.c | 12 ++++++++++--
src/compiler/nir/nir_validate.c | 13 +++++++++++++
src/compiler/spirv/vtn_cfg.c | 2 +-
src/compiler/spirv/vtn_variables.c | 2 +-
12 files changed, 106 insertions(+), 13 deletions(-)

Upstream: cgit.freedesktop.org


  • Share