From: Kenneth Graunke Date: Wed, 27 Apr 2022 08:30:18 +0000 (-0700) Subject: iris: Fall back if iris_map_copy_region can't create a staging resource X-Git-Tag: upstream/22.3.5~3934 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fcad737cbae384f1eca2a7c499e884a1e5e045cc;p=platform%2Fupstream%2Fmesa.git iris: 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 Tested-by: Mark Janes markjanes@swizzler.org Part-of: --- diff --git a/src/gallium/drivers/iris/iris_resource.c b/src/gallium/drivers/iris/iris_resource.c index bb5cfe1..0204b1d 100644 --- a/src/gallium/drivers/iris/iris_resource.c +++ b/src/gallium/drivers/iris/iris_resource.c @@ -1998,7 +1998,12 @@ iris_map_copy_region(struct iris_transfer *map) templ.target = PIPE_TEXTURE_2D; map->staging = iris_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 iris_resource *) map->staging)->surf; @@ -2437,9 +2442,12 @@ iris_transfer_map(struct pipe_context *ctx, map->batch = &ice->batches[IRIS_BATCH_RENDER]; map->blorp = &ice->blorp; iris_map_copy_region(map); - } else { - /* Otherwise we're free to map on the CPU. */ + } + /* If we've requested a direct mapping, or iris_map_copy_region failed + * to create a staging resource, then map it directly on the CPU. + */ + if (!map->ptr) { if (resource->target != PIPE_BUFFER) { iris_resource_access_raw(ice, res, level, box->z, box->depth, usage & PIPE_MAP_WRITE);