diff options
author | Jason Ekstrand <[email protected]> | 2018-11-28 12:26:52 -0600 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2019-01-08 00:38:30 +0000 |
commit | e94a027af8953ba22f4daa3009ab71479b35c78f (patch) | |
tree | 03a9b69081808ff3bd79f9bfcb257ac7023719ad /src/compiler/nir/nir_validate.c | |
parent | fc9c4f89b85c0116c0dc22a3eaf25f5df88ad657 (diff) |
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 <[email protected]>
Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]>
Diffstat (limited to 'src/compiler/nir/nir_validate.c')
-rw-r--r-- | src/compiler/nir/nir_validate.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c index ccd0cf782fe..9f8455d21cc 100644 --- a/src/compiler/nir/nir_validate.c +++ b/src/compiler/nir/nir_validate.c @@ -470,6 +470,19 @@ validate_deref_instr(nir_deref_instr *instr, validate_state *state) } break; + case nir_deref_type_ptr_as_array: + /* ptr_as_array derefs must have a parent that is either an array, + * ptr_as_array, or cast. If the parent is a cast, we get the stride + * information (if any) from the cast deref. + */ + validate_assert(state, + parent->deref_type == nir_deref_type_array || + parent->deref_type == nir_deref_type_ptr_as_array || + parent->deref_type == nir_deref_type_cast); + validate_src(&instr->arr.index, state, + nir_dest_bit_size(instr->dest), 1); + break; + default: unreachable("Invalid deref instruction type"); } |