From 4ae362c0efa660242d79ac6df772649e1469d986 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Tue, 26 Mar 2019 22:22:41 +0100 Subject: [PATCH] zink: delete samplers after the current cmdbuf This makes them zombies for a little while. Acked-by: Jordan Justen --- src/gallium/drivers/zink/zink_cmdbuf.c | 5 +++++ src/gallium/drivers/zink/zink_cmdbuf.h | 4 ++++ src/gallium/drivers/zink/zink_context.c | 7 +++++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/zink/zink_cmdbuf.c b/src/gallium/drivers/zink/zink_cmdbuf.c index 44c4d941b8d..5928254cc0f 100644 --- a/src/gallium/drivers/zink/zink_cmdbuf.c +++ b/src/gallium/drivers/zink/zink_cmdbuf.c @@ -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 * diff --git a/src/gallium/drivers/zink/zink_cmdbuf.h b/src/gallium/drivers/zink/zink_cmdbuf.h index f0159d91120..ffc6e29757d 100644 --- a/src/gallium/drivers/zink/zink_cmdbuf.h +++ b/src/gallium/drivers/zink/zink_cmdbuf.h @@ -26,6 +26,8 @@ #include +#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 * diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index 13e630ca65b..fd9cd6e3717 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -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[] = { -- 2.30.2