iris: Use thread safe slab allocators in transfer_map handling
pipe->transfer_map can be called from u_threaded_context's thread rather than the driver thread. We need to use two different slab allocators, one for each thread. transfer_unmap, on the other hand, is only ever called from the driver thread. Reviewed-by: Zoltán Böszörményi <zboszor@gmail.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8964>
This commit is contained in:
@@ -252,6 +252,7 @@ iris_destroy_context(struct pipe_context *ctx)
|
||||
iris_destroy_binder(&ice->state.binder);
|
||||
|
||||
slab_destroy_child(&ice->transfer_pool);
|
||||
slab_destroy_child(&ice->transfer_pool_unsync);
|
||||
|
||||
ralloc_free(ice);
|
||||
}
|
||||
@@ -328,6 +329,7 @@ iris_create_context(struct pipe_screen *pscreen, void *priv, unsigned flags)
|
||||
iris_init_binder(ice);
|
||||
|
||||
slab_create_child(&ice->transfer_pool, &screen->transfer_pool);
|
||||
slab_create_child(&ice->transfer_pool_unsync, &screen->transfer_pool);
|
||||
|
||||
ice->state.surface_uploader =
|
||||
u_upload_create(ctx, 16384, PIPE_BIND_CUSTOM, PIPE_USAGE_IMMUTABLE,
|
||||
|
@@ -576,6 +576,9 @@ struct iris_context {
|
||||
/** Slab allocator for iris_transfer_map objects. */
|
||||
struct slab_child_pool transfer_pool;
|
||||
|
||||
/** Slab allocator for threaded_context's iris_transfer_map objects */
|
||||
struct slab_child_pool transfer_pool_unsync;
|
||||
|
||||
struct blorp_context blorp;
|
||||
|
||||
struct iris_batch batches[IRIS_BATCH_COUNT];
|
||||
|
@@ -1865,7 +1865,12 @@ iris_transfer_map(struct pipe_context *ctx,
|
||||
(usage & PIPE_MAP_DIRECTLY))
|
||||
return NULL;
|
||||
|
||||
struct iris_transfer *map = slab_alloc(&ice->transfer_pool);
|
||||
struct iris_transfer *map;
|
||||
|
||||
if (usage & TC_TRANSFER_MAP_THREADED_UNSYNC)
|
||||
map = slab_alloc(&ice->transfer_pool_unsync);
|
||||
else
|
||||
map = slab_alloc(&ice->transfer_pool);
|
||||
|
||||
if (!map)
|
||||
return NULL;
|
||||
@@ -2020,6 +2025,11 @@ iris_transfer_unmap(struct pipe_context *ctx, struct pipe_transfer *xfer)
|
||||
map->unmap(map);
|
||||
|
||||
pipe_resource_reference(&xfer->resource, NULL);
|
||||
|
||||
/* transfer_unmap is always called from the driver thread, so we have to
|
||||
* use transfer_pool, not transfer_pool_unsync. Freeing an object into a
|
||||
* different pool is allowed, however.
|
||||
*/
|
||||
slab_free(&ice->transfer_pool, map);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user