zink: free pipeline cache during program destroy
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Wed, 3 Jun 2020 15:42:10 +0000 (11:42 -0400)
committerMarge Bot <eric+marge@anholt.net>
Sat, 18 Jul 2020 07:51:37 +0000 (07:51 +0000)
more leaks

Reviewed-by: Antonio Caggiano <antonio.caggiano@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5887>

src/gallium/drivers/zink/zink_program.c

index 0de286d4691447628f783a55dcc3fb60ce1c2a4f..341c3293ac2a2dea0d8bd9a310603d92dfcdb6d5 100644 (file)
 #include "util/u_memory.h"
 #include "tgsi/tgsi_from_mesa.h"
 
+struct pipeline_cache_entry {
+   struct zink_gfx_pipeline_state state;
+   VkPipeline pipeline;
+};
+
 static VkDescriptorSetLayout
 create_desc_set_layout(VkDevice dev,
                        struct zink_shader *stages[PIPE_SHADER_TYPES - 1],
@@ -187,14 +192,19 @@ zink_destroy_gfx_program(struct zink_screen *screen,
       _mesa_set_destroy(prog->render_passes, NULL);
    }
 
+   for (int i = 0; i < ARRAY_SIZE(prog->pipelines); ++i) {
+      hash_table_foreach(prog->pipelines[i], entry) {
+         struct pipeline_cache_entry *pc_entry = entry->data;
+
+         vkDestroyPipeline(screen->dev, pc_entry->pipeline, NULL);
+         free(pc_entry);
+      }
+      _mesa_hash_table_destroy(prog->pipelines[i], NULL);
+   }
+
    FREE(prog);
 }
 
-struct pipeline_cache_entry {
-   struct zink_gfx_pipeline_state state;
-   VkPipeline pipeline;
-};
-
 static VkPrimitiveTopology
 primitive_topology(enum pipe_prim_type mode)
 {