[Mesa-dev] [PATCH 02/12] nir: Create the params array in function_impl_create

Jason Ekstrand jason at jlekstrand.net
Sat Dec 26 11:09:25 PST 2015


---
 src/glsl/nir/glsl_to_nir.cpp | 3 ---
 src/glsl/nir/nir.c           | 6 ++++--
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp
index 0d1d0f4..2210e5a 100644
--- a/src/glsl/nir/glsl_to_nir.cpp
+++ b/src/glsl/nir/glsl_to_nir.cpp
@@ -498,9 +498,6 @@ nir_visitor::visit(ir_function_signature *ir)
       nir_function_impl *impl = nir_function_impl_create(func);
       this->impl = impl;
 
-      unsigned num_params = func->num_params;
-      impl->num_params = num_params;
-      impl->params = ralloc_array(this->shader, nir_variable *, num_params);
       unsigned i = 0;
       foreach_in_list(ir_variable, param, &ir->parameters) {
          param->accept(this);
diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c
index 60395ae..13de29d 100644
--- a/src/glsl/nir/nir.c
+++ b/src/glsl/nir/nir.c
@@ -270,8 +270,10 @@ nir_function_impl_create(nir_function *function)
    exec_list_make_empty(&impl->body);
    exec_list_make_empty(&impl->registers);
    exec_list_make_empty(&impl->locals);
-   impl->num_params = 0;
-   impl->params = NULL;
+
+   impl->num_params = function->num_params;
+   impl->params = ralloc_array(mem_ctx, nir_variable *, impl->num_params);
+
    impl->return_var = NULL;
    impl->reg_alloc = 0;
    impl->ssa_alloc = 0;
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list