zink: delete samplers after the current cmdbuf
authorErik Faye-Lund <erik.faye-lund@collabora.com>
Tue, 26 Mar 2019 21:22:41 +0000 (22:22 +0100)
committerErik Faye-Lund <erik.faye-lund@collabora.com>
Mon, 28 Oct 2019 08:51:44 +0000 (08:51 +0000)
This makes them zombies for a little while.

Acked-by: Jordan Justen <jordan.l.justen@intel.com>
src/gallium/drivers/zink/zink_cmdbuf.c
src/gallium/drivers/zink/zink_cmdbuf.h
src/gallium/drivers/zink/zink_context.c

index 44c4d941b8de82da83dd044a4dcc9fc1653d157f..5928254cc0fc46e75923da0d1074f0520885c332 100644 (file)
@@ -29,6 +29,11 @@ reset_cmdbuf(struct zink_screen *screen, struct zink_cmdbuf *cmdbuf)
       pipe_resource_reference(&pres, NULL);
    }
    _mesa_set_clear(cmdbuf->resources, NULL);
+
+   util_dynarray_foreach(&cmdbuf->zombie_samplers, VkSampler, samp) {
+      vkDestroySampler(screen->dev, *samp, NULL);
+   }
+   util_dynarray_clear(&cmdbuf->zombie_samplers);
 }
 
 struct zink_cmdbuf *
index f0159d91120c58b768e81d988ac1ebf96c26787e..ffc6e29757da77441b2d6e9c795f1fe9cbe52290 100644 (file)
@@ -26,6 +26,8 @@
 
 #include <vulkan/vulkan.h>
 
+#include "util/u_dynarray.h"
+
 struct zink_context;
 struct zink_fence;
 struct zink_framebuffer;
@@ -40,6 +42,8 @@ struct zink_cmdbuf {
    struct zink_framebuffer *fb;
 
    struct set *resources;
+
+   struct util_dynarray zombie_samplers;
 };
 
 struct zink_cmdbuf *
index 13e630ca65b0ef15d166aa4252b7d50698317e8a..fd9cd6e3717a339b58092d127d7b3ee5faef8b74 100644 (file)
@@ -164,8 +164,9 @@ static void
 zink_delete_sampler_state(struct pipe_context *pctx,
                           void *sampler_state)
 {
-   struct zink_screen *screen = zink_screen(pctx->screen);
-   vkDestroySampler(screen->dev, sampler_state, NULL);
+   struct zink_cmdbuf *cmdbuf = zink_context_curr_cmdbuf(zink_context(pctx));
+   util_dynarray_append(&cmdbuf->zombie_samplers,
+                        VkSampler, sampler_state);
 }
 
 
@@ -1271,6 +1272,8 @@ zink_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
                                                    _mesa_key_pointer_equal);
       if (!ctx->cmdbufs[i].resources)
          goto fail;
+
+      util_dynarray_init(&ctx->cmdbufs[i].zombie_samplers, NULL);
    }
 
    VkDescriptorPoolSize sizes[] = {