* ``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:
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);
(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) {
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,
*/
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).
PIPE_CAP_SYSTEM_SVM,
PIPE_CAP_VIEWPORT_MASK,
PIPE_CAP_ALPHA_TO_COVERAGE_DITHER_CONTROL,
+ PIPE_CAP_MAP_UNSYNCHRONIZED_THREAD_SAFE,
};
/**