Mesa (main): d3d12: Use thread safe slab allocators in transfer_map handling

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Nov 9 01:32:00 UTC 2021


Module: Mesa
Branch: main
Commit: cd41ed53b2332769eb3b35e5974379715bfb8093
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=cd41ed53b2332769eb3b35e5974379715bfb8093

Author: Jesse Natalie <jenatali at microsoft.com>
Date:   Wed Nov  3 10:32:04 2021 -0700

d3d12: Use thread safe slab allocators in transfer_map handling

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

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13670>

---

 src/gallium/drivers/d3d12/d3d12_context.cpp  | 2 ++
 src/gallium/drivers/d3d12/d3d12_context.h    | 1 +
 src/gallium/drivers/d3d12/d3d12_resource.cpp | 4 +++-
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/d3d12/d3d12_context.cpp b/src/gallium/drivers/d3d12/d3d12_context.cpp
index 0d38fbb6cf8..e64d687ba10 100644
--- a/src/gallium/drivers/d3d12/d3d12_context.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_context.cpp
@@ -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);
diff --git a/src/gallium/drivers/d3d12/d3d12_context.h b/src/gallium/drivers/d3d12/d3d12_context.h
index 859336b7dfd..9332aa8dfa0 100644
--- a/src/gallium/drivers/d3d12/d3d12_context.h
+++ b/src/gallium/drivers/d3d12/d3d12_context.h
@@ -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;
diff --git a/src/gallium/drivers/d3d12/d3d12_resource.cpp b/src/gallium/drivers/d3d12/d3d12_resource.cpp
index ef13aad469b..7965865f786 100644
--- a/src/gallium/drivers/d3d12/d3d12_resource.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_resource.cpp
@@ -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;



More information about the mesa-commit mailing list