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

Author: Rob Clark <[email protected]>
Date:   Thu Mar  4 12:43:51 2021 -0800

freedreno: Add transfer_pool_unsync

With threaded_context, in the TC_TRANSFER_MAP_UNSYNC case, we are
getting called from the frontend thread, rather than driver thread.
So we need a different slab_child_pool for that.

Signed-off-by: Rob Clark <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9323>

---

 src/gallium/drivers/freedreno/freedreno_context.c  |  2 ++
 src/gallium/drivers/freedreno/freedreno_context.h  |  1 +
 src/gallium/drivers/freedreno/freedreno_resource.c | 10 +++++++++-
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/freedreno/freedreno_context.c 
b/src/gallium/drivers/freedreno/freedreno_context.c
index a074acb1a89..93c57e4a6b0 100644
--- a/src/gallium/drivers/freedreno/freedreno_context.c
+++ b/src/gallium/drivers/freedreno/freedreno_context.c
@@ -325,6 +325,7 @@ fd_context_destroy(struct pipe_context *pctx)
                util_primconvert_destroy(ctx->primconvert);
 
        slab_destroy_child(&ctx->transfer_pool);
+       slab_destroy_child(&ctx->transfer_pool_unsync);
 
        for (i = 0; i < ARRAY_SIZE(ctx->vsc_pipe_bo); i++) {
                if (!ctx->vsc_pipe_bo[i])
@@ -577,6 +578,7 @@ fd_context_init(struct fd_context *ctx, struct pipe_screen 
*pscreen,
        pctx->const_uploader = pctx->stream_uploader;
 
        slab_create_child(&ctx->transfer_pool, &screen->transfer_pool);
+       slab_create_child(&ctx->transfer_pool_unsync, &screen->transfer_pool);
 
        fd_draw_init(pctx);
        fd_resource_context_init(pctx);
diff --git a/src/gallium/drivers/freedreno/freedreno_context.h 
b/src/gallium/drivers/freedreno/freedreno_context.h
index d10588bd7e9..491746590c4 100644
--- a/src/gallium/drivers/freedreno/freedreno_context.h
+++ b/src/gallium/drivers/freedreno/freedreno_context.h
@@ -204,6 +204,7 @@ struct fd_context {
 
        /* slab for pipe_transfer allocations: */
        struct slab_child_pool transfer_pool dt;
+       struct slab_child_pool transfer_pool_unsync; /* for threaded_context */
 
        /**
         * query related state:
diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c 
b/src/gallium/drivers/freedreno/freedreno_resource.c
index 649532fc56e..ef6297dc83e 100644
--- a/src/gallium/drivers/freedreno/freedreno_resource.c
+++ b/src/gallium/drivers/freedreno/freedreno_resource.c
@@ -667,6 +667,9 @@ fd_resource_transfer_unmap(struct pipe_context *pctx,
 
        assert(trans->b.staging == NULL); /* for threaded context only */
 
+       /* 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);
 }
 
@@ -928,7 +931,12 @@ fd_resource_transfer_map(struct pipe_context *pctx,
                return NULL;
        }
 
-       ptrans = slab_alloc(&ctx->transfer_pool);
+       if (usage & TC_TRANSFER_MAP_THREADED_UNSYNC) {
+               ptrans = slab_alloc(&ctx->transfer_pool_unsync);
+       } else {
+               ptrans = slab_alloc(&ctx->transfer_pool);
+       }
+
        if (!ptrans)
                return NULL;
 

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to