[Mesa-dev] [PATCH 3/5] nir/vc4: pass shader_info to nir_shader_create() in nir_shader_clone()

Timothy Arceri timothy.arceri at collabora.com
Fri Oct 28 06:27:35 UTC 2016


This requires us to free shader_info manually when there is no memory
context, st_program is the only thing that doesn't pass a context.

As far as I could tell freedreno is leaking nir_shader so this doesn't
free anything there.
---
 src/compiler/nir/nir_clone.c          | 3 ++-
 src/gallium/drivers/vc4/vc4_program.c | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/compiler/nir/nir_clone.c b/src/compiler/nir/nir_clone.c
index 4f7bdd9..6a27e7c 100644
--- a/src/compiler/nir/nir_clone.c
+++ b/src/compiler/nir/nir_clone.c
@@ -682,7 +682,8 @@ nir_shader_clone(void *mem_ctx, const nir_shader *s)
    clone_state state;
    init_clone_state(&state, true);
 
-   nir_shader *ns = nir_shader_create(mem_ctx, s->stage, s->options, NULL);
+   shader_info *sh_info = rzalloc(mem_ctx, shader_info);
+   nir_shader *ns = nir_shader_create(mem_ctx, s->stage, s->options, sh_info);
    state.ns = ns;
 
    clone_var_list(&state, &ns->uniforms, &s->uniforms);
diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c
index 11066c1..9362d1e 100644
--- a/src/gallium/drivers/vc4/vc4_program.c
+++ b/src/gallium/drivers/vc4/vc4_program.c
@@ -2289,6 +2289,7 @@ vc4_shader_ntq(struct vc4_context *vc4, enum qstage stage,
                         c->num_uniforms);
         }
 
+        ralloc_free(c->s->info);
         ralloc_free(c->s);
 
         return c;
@@ -2765,6 +2766,7 @@ vc4_shader_state_delete(struct pipe_context *pctx, void *hwcso)
                 delete_from_cache_if_matches(vc4->vs_cache, entry, so);
 
         ralloc_free(so->base.ir.nir);
+        ralloc_free(so->base.ir.nir->info);
         free(so);
 }
 
-- 
2.7.4



More information about the mesa-dev mailing list