vc4: Fix leak of the compiled shader programs in the cache.
authorEric Anholt <eric@anholt.net>
Mon, 15 Dec 2014 04:29:10 +0000 (20:29 -0800)
committerEric Anholt <eric@anholt.net>
Mon, 15 Dec 2014 07:12:11 +0000 (23:12 -0800)
src/gallium/drivers/vc4/vc4_context.c
src/gallium/drivers/vc4/vc4_context.h
src/gallium/drivers/vc4/vc4_program.c

index b26c07127a98050add5db1841da519d4b873eb2c..3535ebbb3edf2ed919bd6f4d8be348b8cd37a02c 100644 (file)
@@ -431,6 +431,8 @@ vc4_context_destroy(struct pipe_context *pctx)
 
         util_slab_destroy(&vc4->transfer_pool);
 
+        vc4_program_fini(pctx);
+
         ralloc_free(vc4);
 }
 
index ba92cb3696543fdebd186aa2adc38f2b5e75ea44..962abbfa9728e92ab7132683af68aafdebba1c0f 100644 (file)
@@ -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,
index 007c18118e678fea13d4c488158188e2045062b2..3af738f6c4bd736dc9f69eb3dc977a234370562c 100644 (file)
@@ -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);
+        }
+}