Mesa (master): vc4: Fix leak of the compiled shader programs in the cache.

Eric Anholt anholt at kemper.freedesktop.org
Mon Dec 15 07:12:46 UTC 2014


Module: Mesa
Branch: master
Commit: 80ed075e6033eba68b034fbd748da4e0b82a27f4
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=80ed075e6033eba68b034fbd748da4e0b82a27f4

Author: Eric Anholt <eric at anholt.net>
Date:   Sun Dec 14 20:29:10 2014 -0800

vc4: Fix leak of the compiled shader programs in the cache.

---

 src/gallium/drivers/vc4/vc4_context.c |    2 ++
 src/gallium/drivers/vc4/vc4_context.h |    1 +
 src/gallium/drivers/vc4/vc4_program.c |   21 +++++++++++++++++++++
 3 files changed, 24 insertions(+)

diff --git a/src/gallium/drivers/vc4/vc4_context.c b/src/gallium/drivers/vc4/vc4_context.c
index b26c071..3535ebb 100644
--- a/src/gallium/drivers/vc4/vc4_context.c
+++ b/src/gallium/drivers/vc4/vc4_context.c
@@ -431,6 +431,8 @@ vc4_context_destroy(struct pipe_context *pctx)
 
         util_slab_destroy(&vc4->transfer_pool);
 
+        vc4_program_fini(pctx);
+
         ralloc_free(vc4);
 }
 
diff --git a/src/gallium/drivers/vc4/vc4_context.h b/src/gallium/drivers/vc4/vc4_context.h
index ba92cb3..962abbf 100644
--- a/src/gallium/drivers/vc4/vc4_context.h
+++ b/src/gallium/drivers/vc4/vc4_context.h
@@ -293,6 +293,7 @@ struct pipe_context *vc4_context_create(struct pipe_screen *pscreen,
 void vc4_draw_init(struct pipe_context *pctx);
 void vc4_state_init(struct pipe_context *pctx);
 void vc4_program_init(struct pipe_context *pctx);
+void vc4_program_fini(struct pipe_context *pctx);
 void vc4_query_init(struct pipe_context *pctx);
 void vc4_simulator_init(struct vc4_screen *screen);
 int vc4_simulator_flush(struct vc4_context *vc4,
diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c
index 007c181..3af738f 100644
--- a/src/gallium/drivers/vc4/vc4_program.c
+++ b/src/gallium/drivers/vc4/vc4_program.c
@@ -2777,3 +2777,24 @@ vc4_program_init(struct pipe_context *pctx)
         vc4->vs_cache = _mesa_hash_table_create(pctx, vs_cache_hash,
                                                 vs_cache_compare);
 }
+
+void
+vc4_program_fini(struct pipe_context *pctx)
+{
+        struct vc4_context *vc4 = vc4_context(pctx);
+
+        struct hash_entry *entry;
+        hash_table_foreach(vc4->fs_cache, entry) {
+                struct vc4_compiled_shader *shader = entry->data;
+                vc4_bo_unreference(&shader->bo);
+                ralloc_free(shader);
+                _mesa_hash_table_remove(vc4->fs_cache, entry);
+        }
+
+        hash_table_foreach(vc4->vs_cache, entry) {
+                struct vc4_compiled_shader *shader = entry->data;
+                vc4_bo_unreference(&shader->bo);
+                ralloc_free(shader);
+                _mesa_hash_table_remove(vc4->vs_cache, entry);
+        }
+}




More information about the mesa-commit mailing list