Module: Mesa Branch: main Commit: 6954a8ddbe9b512fa21789ee7ed9e67120d34929 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6954a8ddbe9b512fa21789ee7ed9e67120d34929
Author: Kenneth Graunke <[email protected]> Date: Thu Sep 29 17:38:53 2022 -0700 iris: Promote DISCARD_RANGE to DISCARD_WHOLE_RESOURCE where possible This allows us to replace the backing storage for a buffer, which means we'd have an idle buffer and thus could do an unsynchronized mapping where we otherwise wouldn't. Reviewed-by: Ian Romanick <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19209> --- src/gallium/drivers/iris/iris_resource.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/gallium/drivers/iris/iris_resource.c b/src/gallium/drivers/iris/iris_resource.c index 5546edf8d93..c797ad05a69 100644 --- a/src/gallium/drivers/iris/iris_resource.c +++ b/src/gallium/drivers/iris/iris_resource.c @@ -2383,6 +2383,16 @@ iris_transfer_map(struct pipe_context *ctx, if (res->base.is_user_ptr) usage |= PIPE_MAP_PERSISTENT; + /* Promote discarding a range to discarding the entire buffer where + * possible. This may allow us to replace the backing storage entirely + * and let us do an unsynchronized map when we otherwise wouldn't. + */ + if (resource->target == PIPE_BUFFER && + (usage & PIPE_MAP_DISCARD_RANGE) && + box->x == 0 && box->width == resource->width0) { + usage |= PIPE_MAP_DISCARD_WHOLE_RESOURCE; + } + if (usage & PIPE_MAP_DISCARD_WHOLE_RESOURCE) { /* Replace the backing storage with a fresh buffer for non-async maps */ if (!(usage & (PIPE_MAP_UNSYNCHRONIZED |
