diff --git a/src/gallium/drivers/iris/iris_resource.c b/src/gallium/drivers/iris/iris_resource.c index 77c185ffe2f..9fbf636970c 100644 --- a/src/gallium/drivers/iris/iris_resource.c +++ b/src/gallium/drivers/iris/iris_resource.c @@ -1998,6 +1998,20 @@ iris_transfer_map(struct pipe_context *ctx, usage |= PIPE_MAP_UNSYNCHRONIZED; } + /* Avoid using GPU copies for persistent/coherent buffers, as the idea + * there is to access them simultaneously on the CPU & GPU. This also + * avoids trying to use GPU copies for our u_upload_mgr buffers which + * contain state we're constructing for a GPU draw call, which would + * kill us with infinite stack recursion. + */ + if (usage & (PIPE_MAP_PERSISTENT | PIPE_MAP_COHERENT)) + usage |= PIPE_MAP_DIRECTLY; + + /* We cannot provide a direct mapping of tiled resources */ + if (surf->tiling != ISL_TILING_LINEAR && + (usage & PIPE_MAP_DIRECTLY)) + return NULL; + bool map_would_stall = false; if (!(usage & PIPE_MAP_UNSYNCHRONIZED)) { @@ -2010,10 +2024,6 @@ iris_transfer_map(struct pipe_context *ctx, return NULL; } - if (surf->tiling != ISL_TILING_LINEAR && - (usage & PIPE_MAP_DIRECTLY)) - return NULL; - struct iris_transfer *map; if (usage & TC_TRANSFER_MAP_THREADED_UNSYNC) @@ -2042,15 +2052,6 @@ iris_transfer_map(struct pipe_context *ctx, if (usage & PIPE_MAP_WRITE) util_range_add(&res->base.b, &res->valid_buffer_range, box->x, box->x + box->width); - /* Avoid using GPU copies for persistent/coherent buffers, as the idea - * there is to access them simultaneously on the CPU & GPU. This also - * avoids trying to use GPU copies for our u_upload_mgr buffers which - * contain state we're constructing for a GPU draw call, which would - * kill us with infinite stack recursion. - */ - if (usage & (PIPE_MAP_PERSISTENT | PIPE_MAP_COHERENT)) - usage |= PIPE_MAP_DIRECTLY; - /* GPU copies are not useful for buffer reads. Instead of stalling to * read from the original buffer, we'd simply copy it to a temporary... * then stall (a bit longer) to read from that buffer.