[Mesa-dev] [PATCH 3/9] spirv: Re-arrange vtn_builder initialization

Jason Ekstrand jason at jlekstrand.net
Thu Aug 17 17:22:17 UTC 2017


This simply moves allocating the vtn_builder and initializing it to the
very beginning before we even parse the header.
---
 src/compiler/spirv/spirv_to_nir.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index e0d6c75a..a3e143a 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -3321,6 +3321,13 @@ spirv_to_nir(const uint32_t *words, size_t word_count,
              const struct nir_spirv_supported_extensions *ext,
              const nir_shader_compiler_options *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->ext = ext;
+
    const uint32_t *word_end = words + word_count;
 
    /* Handle the SPIR-V header (first 4 dwords)  */
@@ -3334,14 +3341,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->ext = ext;
 
    /* Handle all the preamble instructions */
    words = vtn_foreach_instruction(b, words, word_end,
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list