From 2b570a49a92458f4771252c7faf1bac5a3c9dca5 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Wed, 29 Apr 2015 14:34:06 -0700 Subject: [PATCH] nir/spirv: Rework the way values are added Instead of having functions to add values and set various things, we just have a function that does a few asserts and then returns the value. The caller is then responsible for setting the various fields. --- src/glsl/nir/spirv_to_nir.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/glsl/nir/spirv_to_nir.c b/src/glsl/nir/spirv_to_nir.c index 76ddce6..e4bddbb 100644 --- a/src/glsl/nir/spirv_to_nir.c +++ b/src/glsl/nir/spirv_to_nir.c @@ -69,22 +69,16 @@ struct vtn_builder { struct vtn_value *entry_point; }; -static void +static struct vtn_value * vtn_push_value(struct vtn_builder *b, uint32_t value_id, - enum vtn_value_type value_type, void *ptr) + enum vtn_value_type value_type) { assert(value_id < b->value_id_bound); assert(b->values[value_id].value_type == vtn_value_type_invalid); b->values[value_id].value_type = value_type; - b->values[value_id].ptr = ptr; -} -static void -vtn_push_token(struct vtn_builder *b, uint32_t value_id, - enum vtn_value_type value_type) -{ - vtn_push_value(b, value_id, value_type, NULL); + return &b->values[value_id]; } static char * @@ -149,7 +143,7 @@ vtn_handle_decoration(struct vtn_builder *b, SpvOp opcode, { switch (opcode) { case SpvOpDecorationGroup: - vtn_push_token(b, w[1], vtn_value_type_undef); + vtn_push_value(b, w[1], vtn_value_type_undef); break; case SpvOpDecorate: { @@ -243,12 +237,12 @@ vtn_handle_instruction(struct vtn_builder *b, SpvOp opcode, break; case SpvOpString: - vtn_push_value(b, w[1], vtn_value_type_string, - vtn_string_literal(b, &w[2], count - 2)); + vtn_push_value(b, w[1], vtn_value_type_string)->str = + vtn_string_literal(b, &w[2], count - 2); break; case SpvOpUndef: - vtn_push_token(b, w[2], vtn_value_type_undef); + vtn_push_value(b, w[2], vtn_value_type_undef); break; case SpvOpMemoryModel: -- 2.7.4