From 1db51b5af59b4a77764c087db26d8b7c12c01551 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 27 Apr 2022 01:38:10 -0700 Subject: [PATCH] crocus: Fall back if iris_map_copy_region can't create a staging resource If we can't create a staging resource, then fall back to direct CPU mapping (possibly with a stall). This is a rare case, but it could happen for very large staging buffers. Reviewed-by: Dave Airlie Part-of: --- src/gallium/drivers/crocus/crocus_resource.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/crocus/crocus_resource.c b/src/gallium/drivers/crocus/crocus_resource.c index 7ce0399..3265483 100644 --- a/src/gallium/drivers/crocus/crocus_resource.c +++ b/src/gallium/drivers/crocus/crocus_resource.c @@ -1258,7 +1258,12 @@ crocus_map_copy_region(struct crocus_transfer *map) templ.target = PIPE_TEXTURE_2D; map->staging = crocus_resource_create(pscreen, &templ); - assert(map->staging); + + /* If we fail to create a staging resource, the caller will fallback + * to mapping directly on the CPU. + */ + if (!map->staging) + return; if (templ.target != PIPE_BUFFER) { struct isl_surf *surf = &((struct crocus_resource *) map->staging)->surf; @@ -1703,9 +1708,12 @@ crocus_transfer_map(struct pipe_context *ctx, map->batch = &ice->batches[CROCUS_BATCH_RENDER]; map->blorp = &ice->blorp; crocus_map_copy_region(map); - } else { - /* Otherwise we're free to map on the CPU. */ + } + /* If we've requested a direct mapping, or crocus_map_copy_region failed + * to create a staging resource, then map it directly on the CPU. + */ + if (!map->ptr) { if (resource->target != PIPE_BUFFER) { crocus_resource_access_raw(ice, res, level, box->z, box->depth, -- 2.7.4