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>
This commit is contained in:

committed by
Jason Ekstrand

parent
fc9c4f89b8
commit
e94a027af8
@@ -998,6 +998,7 @@ typedef enum {
|
||||
nir_deref_type_var,
|
||||
nir_deref_type_array,
|
||||
nir_deref_type_array_wildcard,
|
||||
nir_deref_type_ptr_as_array,
|
||||
nir_deref_type_struct,
|
||||
nir_deref_type_cast,
|
||||
} nir_deref_type;
|
||||
@@ -1031,6 +1032,10 @@ typedef struct {
|
||||
struct {
|
||||
unsigned index;
|
||||
} strct;
|
||||
|
||||
struct {
|
||||
unsigned ptr_stride;
|
||||
} cast;
|
||||
};
|
||||
|
||||
/** Destination to store the resulting "pointer" */
|
||||
@@ -1078,6 +1083,8 @@ bool nir_deref_instr_has_indirect(nir_deref_instr *instr);
|
||||
|
||||
bool nir_deref_instr_remove_if_unused(nir_deref_instr *instr);
|
||||
|
||||
unsigned nir_deref_instr_ptr_as_array_stride(nir_deref_instr *instr);
|
||||
|
||||
typedef struct {
|
||||
nir_instr instr;
|
||||
|
||||
|
Reference in New Issue
Block a user