summaryrefslogtreecommitdiff
path: root/src/compiler/nir/nir_print.c
diff options
context:
space:
mode:
authorJason Ekstrand <jason.ekstrand@intel.com>2018-11-28 12:26:52 -0600
committerJason Ekstrand <jason@jlekstrand.net>2019-01-08 00:38:30 +0000
commite94a027af8953ba22f4daa3009ab71479b35c78f (patch)
tree03a9b69081808ff3bd79f9bfcb257ac7023719ad /src/compiler/nir/nir_print.c
parentfc9c4f89b85c0116c0dc22a3eaf25f5df88ad657 (diff)
downloadmesa-e94a027af8953ba22f4daa3009ab71479b35c78f.tar.gz
nir: Add a ptr_as_array deref type
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. Reviewed-by: Alejandro PiƱeiro <apinheiro@igalia.com> Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Diffstat (limited to 'src/compiler/nir/nir_print.c')
-rw-r--r--src/compiler/nir/nir_print.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c
index 95d9bc85656..a73b9d37ae5 100644
--- a/src/compiler/nir/nir_print.c
+++ b/src/compiler/nir/nir_print.c
@@ -636,7 +636,8 @@ print_deref_link(const nir_deref_instr *instr, bool whole_chain, print_state *st
glsl_get_struct_elem_name(parent->type, instr->strct.index));
break;
- case nir_deref_type_array: {
+ case nir_deref_type_array:
+ case nir_deref_type_ptr_as_array: {
nir_const_value *const_index = nir_src_as_const_value(instr->arr.index);
if (const_index) {
fprintf(fp, "[%u]", const_index->u32[0]);
@@ -678,6 +679,9 @@ print_deref_instr(nir_deref_instr *instr, print_state *state)
case nir_deref_type_cast:
fprintf(fp, " = deref_cast ");
break;
+ case nir_deref_type_ptr_as_array:
+ fprintf(fp, " = deref_ptr_as_array ");
+ break;
default:
unreachable("Invalid deref instruction type");
}