d3d12: Use thread safe slab allocators in transfer_map handling

Reviewed By: Bill Kristiansen <billkris@microsoft.com>

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13670>
This commit is contained in:
Jesse Natalie 2021-11-03 10:32:04 -07:00 committed by Marge Bot
parent 17a46e2cf9
commit cd41ed53b2
3 changed files with 6 additions and 1 deletions

View File

@ -73,6 +73,7 @@ d3d12_context_destroy(struct pipe_context *pctx)
d3d12_descriptor_pool_free(ctx->sampler_pool);
util_primconvert_destroy(ctx->primconvert);
slab_destroy_child(&ctx->transfer_pool);
slab_destroy_child(&ctx->transfer_pool_unsync);
d3d12_gs_variant_cache_destroy(ctx);
d3d12_gfx_pipeline_state_cache_destroy(ctx);
d3d12_root_signature_cache_destroy(ctx);
@ -1915,6 +1916,7 @@ d3d12_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
slab_create_child(&ctx->transfer_pool, &d3d12_screen(pscreen)->transfer_pool);
slab_create_child(&ctx->transfer_pool_unsync, &d3d12_screen(pscreen)->transfer_pool);
ctx->base.stream_uploader = u_upload_create_default(&ctx->base);
ctx->base.const_uploader = u_upload_create_default(&ctx->base);

View File

@ -149,6 +149,7 @@ class ResourceStateManager;
struct d3d12_context {
struct pipe_context base;
struct slab_child_pool transfer_pool;
struct slab_child_pool transfer_pool_unsync;
struct primconvert_context *primconvert;
struct blitter_context *blitter;
struct u_suballocator query_allocator;

View File

@ -900,7 +900,9 @@ d3d12_transfer_map(struct pipe_context *pctx,
if (usage & PIPE_MAP_DIRECTLY || !res->bo)
return NULL;
struct d3d12_transfer *trans = (struct d3d12_transfer *)slab_alloc(&ctx->transfer_pool);
slab_child_pool* transfer_pool = (usage & TC_TRANSFER_MAP_THREADED_UNSYNC) ?
&ctx->transfer_pool_unsync : &ctx->transfer_pool;
struct d3d12_transfer *trans = (struct d3d12_transfer *)slab_alloc(transfer_pool);
struct pipe_transfer *ptrans = &trans->base.b;
if (!trans)
return NULL;