From: Jason Ekstrand Date: Wed, 29 Apr 2015 21:34:06 +0000 (-0700) Subject: nir/spirv: Rework the way values are added X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2b570a49a92458f4771252c7faf1bac5a3c9dca5;p=mesa.git 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. --- diff --git a/src/glsl/nir/spirv_to_nir.c b/src/glsl/nir/spirv_to_nir.c index 76ddce62c1c..e4bddbb6bdc 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: