diff options
author | Jason Ekstrand <[email protected]> | 2017-06-28 00:45:36 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2017-07-18 09:43:12 -0700 |
commit | f2fe74a462ea6e019678c89632a99d8037a2f153 (patch) | |
tree | 32b5700a74780003cdf1df6db6f00d8f1e748ce5 /src/compiler/spirv/vtn_private.h | |
parent | 182950ceaf9034e0f6f6e641784af2641d8d178f (diff) |
nir/spirv: Add support for SPV_KHR_variable_pointers
Reviewed-by: Iago Toral Quiroga <[email protected]>
Diffstat (limited to 'src/compiler/spirv/vtn_private.h')
-rw-r--r-- | src/compiler/spirv/vtn_private.h | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/compiler/spirv/vtn_private.h b/src/compiler/spirv/vtn_private.h index 8d745bb4a03..84584620fc1 100644 --- a/src/compiler/spirv/vtn_private.h +++ b/src/compiler/spirv/vtn_private.h @@ -369,6 +369,13 @@ struct vtn_pointer { struct nir_ssa_def *offset; }; +static inline bool +vtn_pointer_uses_ssa_offset(struct vtn_pointer *ptr) +{ + return ptr->mode == vtn_variable_mode_ubo || + ptr->mode == vtn_variable_mode_ssbo; +} + struct vtn_variable { enum vtn_variable_mode mode; @@ -501,6 +508,12 @@ struct vtn_builder { bool has_loop_continue; }; +nir_ssa_def * +vtn_pointer_to_ssa(struct vtn_builder *b, struct vtn_pointer *ptr); +struct vtn_pointer * +vtn_pointer_from_ssa(struct vtn_builder *b, nir_ssa_def *ssa, + struct vtn_type *ptr_type); + static inline struct vtn_value * vtn_push_value(struct vtn_builder *b, uint32_t value_id, enum vtn_value_type value_type) @@ -517,8 +530,14 @@ static inline struct vtn_value * vtn_push_ssa(struct vtn_builder *b, uint32_t value_id, struct vtn_type *type, struct vtn_ssa_value *ssa) { - struct vtn_value *val = vtn_push_value(b, value_id, vtn_value_type_ssa); - val->ssa = ssa; + struct vtn_value *val; + if (type->base_type == vtn_base_type_pointer) { + val = vtn_push_value(b, value_id, vtn_value_type_pointer); + val->pointer = vtn_pointer_from_ssa(b, ssa->def, type); + } else { + val = vtn_push_value(b, value_id, vtn_value_type_ssa); + val->ssa = ssa; + } return val; } |