summaryrefslogtreecommitdiffstats
path: root/src/compiler/spirv/vtn_private.h
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2018-03-23 08:22:54 -0700
committerJason Ekstrand <[email protected]>2018-06-22 20:15:57 -0700
commitd5930c222c0452becffb157052833e2b35ad6fbd (patch)
treebf7819e9f894e11161fd3c5e56b180293c939d29 /src/compiler/spirv/vtn_private.h
parentfdd5ffee32bd125dbb51e6b2087db186ea09c470 (diff)
spirv: Allow pointers to have a deref at the base
Previously, pointers fell into two categories: index/offset for UBOs, SSBOs, etc. and var + access chain for logical pointers. This commit adds another logical pointer mode that's deref + access chain. It's tempting to think that we can just replace variable-based pointers with deref-based or at least replace the access chain with a deref chain. Unfortunately, there are a few sticky bits that prevent this: 1) We can't return deref-based pointers from OpVariable because those opcodes may come outside of a function so there's no place to emit the deref instructions. 2) We can't always use variable-based pointers because we may not always know the variable. (We do now, but he upcoming function rework will take that option away.) 3) We also can't replace the access chain struct with a deref. Due to the re-ordering we do in order to handle loop continues, the derefs we would emit as part of OpAccessChain may not dominate their uses. We normally fix this up with nir_repair_ssa but that generates phi nodes which we don't want in the middle of our deref chains. All in all, we have no real better option than to support partial access chains while also re-emitting the deref instructions on the spot. Acked-by: Rob Clark <[email protected]> Acked-by: Bas Nieuwenhuizen <[email protected]> Acked-by: Dave Airlie <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/compiler/spirv/vtn_private.h')
-rw-r--r--src/compiler/spirv/vtn_private.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/compiler/spirv/vtn_private.h b/src/compiler/spirv/vtn_private.h
index 26c5a03aa51..bd4d28b4f37 100644
--- a/src/compiler/spirv/vtn_private.h
+++ b/src/compiler/spirv/vtn_private.h
@@ -433,10 +433,17 @@ struct vtn_pointer {
/** The referenced variable, if known
*
* This field may be NULL if the pointer uses a (block_index, offset) pair
- * instead of an access chain.
+ * instead of an access chain or if the access chain starts at a deref.
*/
struct vtn_variable *var;
+ /** The deref at the base of the chain
+ *
+ * This field may be NULL if the pointer uses a (block_index, offset) pair
+ * instead of an access chain or if the access chain starts at a variable.
+ */
+ nir_deref_instr *deref;
+
/** An access chain describing how to get from var to the referenced data
*
* This field may be NULL if the pointer references the entire variable or