diff options
-rw-r--r-- | src/gallium/auxiliary/util/u_screen.c | 1 | ||||
-rw-r--r-- | src/gallium/docs/source/screen.rst | 1 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_buffer.c | 17 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_get.c | 1 | ||||
-rw-r--r-- | src/gallium/include/pipe/p_defines.h | 8 |
5 files changed, 23 insertions, 5 deletions
diff --git a/src/gallium/auxiliary/util/u_screen.c b/src/gallium/auxiliary/util/u_screen.c index b3484beef25..54ebe77420d 100644 --- a/src/gallium/auxiliary/util/u_screen.c +++ b/src/gallium/auxiliary/util/u_screen.c @@ -422,6 +422,7 @@ u_pipe_screen_get_param_defaults(struct pipe_screen *pscreen, case PIPE_CAP_VIEWPORT_TRANSFORM_LOWERED: case PIPE_CAP_PSIZ_CLAMPED: + case PIPE_CAP_MAP_UNSYNCHRONIZED_THREAD_SAFE: return 0; case PIPE_CAP_GL_BEGIN_END_BUFFER_SIZE: diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst index a16e4994903..3a9ccb4246b 100644 --- a/src/gallium/docs/source/screen.rst +++ b/src/gallium/docs/source/screen.rst @@ -576,6 +576,7 @@ The integer capabilities: * ``PIPE_CAP_VIEWPORT_SWIZZLE``: Whether pipe_viewport_state::swizzle can be used to specify pre-clipping swizzling of coordinates (see GL_NV_viewport_swizzle). * ``PIPE_CAP_SYSTEM_SVM``: True if all application memory can be shared with the GPU without explicit mapping. * ``PIPE_CAP_VIEWPORT_MASK``: Whether ``TGSI_SEMANTIC_VIEWPORT_MASK`` and ``TGSI_PROPERTY_LAYER_VIEWPORT_RELATIVE`` are supported (see GL_NV_viewport_array2). +* ``PIPE_CAP_MAP_UNSYNCHRONIZED_THREAD_SAFE``: Whether mapping a buffer as unsynchronized from any thread is safe. .. _pipe_capf: diff --git a/src/gallium/drivers/radeonsi/si_buffer.c b/src/gallium/drivers/radeonsi/si_buffer.c index eb71636d346..6b58aebee2d 100644 --- a/src/gallium/drivers/radeonsi/si_buffer.c +++ b/src/gallium/drivers/radeonsi/si_buffer.c @@ -324,7 +324,9 @@ static void *si_buffer_get_transfer(struct pipe_context *ctx, struct pipe_resour struct si_context *sctx = (struct si_context *)ctx; struct si_transfer *transfer; - if (usage & TC_TRANSFER_MAP_THREADED_UNSYNC) + if (usage & PIPE_TRANSFER_THREAD_SAFE) + transfer = malloc(sizeof(*transfer)); + else if (usage & TC_TRANSFER_MAP_THREADED_UNSYNC) transfer = slab_alloc(&sctx->pool_transfers_unsync); else transfer = slab_alloc(&sctx->pool_transfers); @@ -461,7 +463,7 @@ static void *si_buffer_transfer_map(struct pipe_context *ctx, struct pipe_resour (buf->flags & RADEON_FLAG_SPARSE)) { struct si_resource *staging; - assert(!(usage & TC_TRANSFER_MAP_THREADED_UNSYNC)); + assert(!(usage & (TC_TRANSFER_MAP_THREADED_UNSYNC | PIPE_TRANSFER_THREAD_SAFE))); staging = si_resource(pipe_buffer_create(ctx->screen, 0, PIPE_USAGE_STAGING, box->width + (box->x % SI_MAP_BUFFER_ALIGNMENT))); if (staging) { @@ -574,9 +576,14 @@ static void si_buffer_transfer_unmap(struct pipe_context *ctx, struct pipe_trans assert(stransfer->b.staging == NULL); /* for threaded context only */ pipe_resource_reference(&transfer->resource, NULL); - /* Don't use pool_transfers_unsync. We are always in the driver - * thread. */ - slab_free(&sctx->pool_transfers, transfer); + if (transfer->usage & PIPE_TRANSFER_THREAD_SAFE) { + free(transfer); + } 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(&sctx->pool_transfers, transfer); + } } static void si_buffer_subdata(struct pipe_context *ctx, struct pipe_resource *buffer, diff --git a/src/gallium/drivers/radeonsi/si_get.c b/src/gallium/drivers/radeonsi/si_get.c index 0ec0d025b57..8de60018627 100644 --- a/src/gallium/drivers/radeonsi/si_get.c +++ b/src/gallium/drivers/radeonsi/si_get.c @@ -161,6 +161,7 @@ static int si_get_param(struct pipe_screen *pscreen, enum pipe_cap param) case PIPE_CAP_GL_SPIRV: case PIPE_CAP_DRAW_INFO_START_WITH_USER_INDICES: case PIPE_CAP_ALPHA_TO_COVERAGE_DITHER_CONTROL: + case PIPE_CAP_MAP_UNSYNCHRONIZED_THREAD_SAFE: return 1; case PIPE_CAP_QUERY_SO_OVERFLOW: diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index a3a53735b39..13e124bf728 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -346,6 +346,13 @@ enum pipe_transfer_usage PIPE_TRANSFER_COHERENT = (1 << 14), /** + * Map a resource in a thread-safe manner, because the calling thread can + * be any thread. It can only be used if both WRITE and UNSYNCHRONIZED are + * set. + */ + PIPE_TRANSFER_THREAD_SAFE = 1 << 15, + + /** * This and higher bits are reserved for private use by drivers. Drivers * should use this as (PIPE_TRANSFER_DRV_PRV << i). */ @@ -938,6 +945,7 @@ enum pipe_cap PIPE_CAP_SYSTEM_SVM, PIPE_CAP_VIEWPORT_MASK, PIPE_CAP_ALPHA_TO_COVERAGE_DITHER_CONTROL, + PIPE_CAP_MAP_UNSYNCHRONIZED_THREAD_SAFE, }; /** |