From afa867b973c03f5d516ecdb91a4fbf17ecc87e56 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 30 Jul 2021 10:25:28 -0400 Subject: [PATCH] zink: break out transfer map destroy Reviewed-by: Dave Airlie Part-of: --- src/gallium/drivers/zink/zink_resource.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c index 66c7a3f1125..23fd797126f 100644 --- a/src/gallium/drivers/zink/zink_resource.c +++ b/src/gallium/drivers/zink/zink_resource.c @@ -1051,6 +1051,19 @@ create_transfer(struct zink_context *ctx, struct pipe_resource *pres, unsigned u return trans; } +static void +destroy_transfer(struct zink_context *ctx, struct zink_transfer *trans) +{ + if (trans->base.b.usage & PIPE_MAP_THREAD_SAFE) { + free(trans); + } else { + /* Don't use pool_transfers_unsync. We are always in the driver + * thread. Freeing an object into a different pool is allowed. + */ + slab_free(&ctx->transfer_pool, trans); + } +} + static void * zink_buffer_map(struct pipe_context *pctx, struct pipe_resource *pres, @@ -1372,14 +1385,7 @@ transfer_unmap(struct pipe_context *pctx, struct pipe_transfer *ptrans) pipe_resource_reference(&trans->staging_res, NULL); pipe_resource_reference(&trans->base.b.resource, NULL); - if (trans->base.b.usage & PIPE_MAP_THREAD_SAFE) { - free(trans); - } else { - /* Don't use pool_transfers_unsync. We are always in the driver - * thread. Freeing an object into a different pool is allowed. - */ - slab_free(&ctx->transfer_pool, ptrans); - } + destroy_transfer(ctx, trans); } static void