diff options
author | Lionel Landwerlin <[email protected]> | 2019-07-01 14:57:54 +0300 |
---|---|---|
committer | Lionel Landwerlin <[email protected]> | 2019-07-26 14:09:55 +0000 |
commit | 86b53770e1ea6e79452ccc97bab829ad58ffc5fd (patch) | |
tree | 441f97e2885e2c3a43435e3b8fa94eebc1fc4afe /src/compiler/spirv/vtn_variables.c | |
parent | 8c330728f3094f2c836e022e57f003d0c82953ef (diff) |
spirv: wrap push ssa/pointer values
This refactor allows for common code to apply decoration on all
ssa/pointer values. In particular this will allow to propagage access
qualifiers.
Signed-off-by: Lionel Landwerlin <[email protected]>
Suggested-by: Caio Marcelo de Oliveira Filho <[email protected]>
Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]>
Diffstat (limited to 'src/compiler/spirv/vtn_variables.c')
-rw-r--r-- | src/compiler/spirv/vtn_variables.c | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c index 5bdfd758040..0b03c224af7 100644 --- a/src/compiler/spirv/vtn_variables.c +++ b/src/compiler/spirv/vtn_variables.c @@ -30,6 +30,35 @@ #include "nir_deref.h" #include <vulkan/vulkan_core.h> +static void ptr_decoration_cb(struct vtn_builder *b, + struct vtn_value *val, int member, + const struct vtn_decoration *dec, + void *void_ptr); + +struct vtn_value * +vtn_push_value_pointer(struct vtn_builder *b, uint32_t value_id, + struct vtn_pointer *ptr) +{ + struct vtn_value *val = vtn_push_value(b, value_id, vtn_value_type_pointer); + val->pointer = ptr; + vtn_foreach_decoration(b, val, ptr_decoration_cb, ptr); + return val; +} + +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; + if (type->base_type == vtn_base_type_pointer) { + val = vtn_push_value_pointer(b, value_id, 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; +} + static struct vtn_access_chain * vtn_access_chain_create(struct vtn_builder *b, unsigned length) { @@ -2460,11 +2489,10 @@ vtn_handle_variables(struct vtn_builder *b, SpvOp opcode, val->sampled_image->sampler); } else { vtn_assert(base_val->value_type == vtn_value_type_pointer); - struct vtn_value *val = - vtn_push_value(b, w[2], vtn_value_type_pointer); - val->pointer = vtn_pointer_dereference(b, base_val->pointer, chain); - val->pointer->ptr_type = ptr_type; - vtn_foreach_decoration(b, val, ptr_decoration_cb, val->pointer); + struct vtn_pointer *ptr = + vtn_pointer_dereference(b, base_val->pointer, chain); + ptr->ptr_type = ptr_type; + vtn_push_value_pointer(b, w[2], ptr); } break; } @@ -2489,7 +2517,7 @@ vtn_handle_variables(struct vtn_builder *b, SpvOp opcode, if (glsl_type_is_image(res_type->type) || glsl_type_is_sampler(res_type->type)) { - vtn_push_value(b, w[2], vtn_value_type_pointer)->pointer = src; + vtn_push_value_pointer(b, w[2], src); return; } |