summaryrefslogtreecommitdiffstats
path: root/src/compiler/spirv/vtn_variables.c
diff options
context:
space:
mode:
authorLionel Landwerlin <[email protected]>2019-07-01 14:57:54 +0300
committerJuan A. Suarez Romero <[email protected]>2019-07-30 08:23:19 +0000
commit0801a8b906547f17e6d0ef5fb4062033211498a6 (patch)
tree34f9b91edd1472b0855642377557783ca04a4f47 /src/compiler/spirv/vtn_variables.c
parente1fdca74929d2ebbca92f82167ae86e5231ffb7b (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]> (cherry picked from commit 86b53770e1ea6e79452ccc97bab829ad58ffc5fd) [Lionel Landwerlin: patch adapted for 19.1 branch]
Diffstat (limited to 'src/compiler/spirv/vtn_variables.c')
-rw-r--r--src/compiler/spirv/vtn_variables.c40
1 files changed, 34 insertions, 6 deletions
diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c
index 6fbe6900e48..1bcf0b4f71c 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)
{
@@ -2404,11 +2433,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;
}
@@ -2433,7 +2461,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;
}