aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler/spirv
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2017-08-16 16:10:23 -0700
committerJason Ekstrand <[email protected]>2017-12-04 09:21:09 -0800
commit11bd753c4ece5eafa6fc7c416d25f60371758e1b (patch)
treea28758972a4533e6ab389a9a0308fe679cd30fae /src/compiler/spirv
parentd74bec1a544e8d2df5e92504bd095a542bb8a4ac (diff)
spirv: Re-arrange vtn_builder initialization
This simply moves allocating the vtn_builder and initializing it to the very beginning before we even parse the header. Reviewed-by: Tapani Pälli <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/compiler/spirv')
-rw-r--r--src/compiler/spirv/spirv_to_nir.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index 353d99cc613..46ba005945d 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -3319,6 +3319,13 @@ spirv_to_nir(const uint32_t *words, size_t word_count,
const struct spirv_to_nir_options *options,
const nir_shader_compiler_options *nir_options)
{
+ /* Initialize the stn_builder object */
+ struct vtn_builder *b = rzalloc(NULL, struct vtn_builder);
+ exec_list_make_empty(&b->functions);
+ b->entry_point_stage = stage;
+ b->entry_point_name = entry_point_name;
+ b->options = options;
+
const uint32_t *word_end = words + word_count;
/* Handle the SPIR-V header (first 4 dwords) */
@@ -3332,14 +3339,8 @@ spirv_to_nir(const uint32_t *words, size_t word_count,
words+= 5;
- /* Initialize the stn_builder object */
- struct vtn_builder *b = rzalloc(NULL, struct vtn_builder);
b->value_id_bound = value_id_bound;
b->values = rzalloc_array(b, struct vtn_value, value_id_bound);
- exec_list_make_empty(&b->functions);
- b->entry_point_stage = stage;
- b->entry_point_name = entry_point_name;
- b->options = options;
/* Handle all the preamble instructions */
words = vtn_foreach_instruction(b, words, word_end,