From d5367cee09fa58fe93dfe9879cdf34be346c5915 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 27 Oct 2020 14:31:29 -0400 Subject: [PATCH] zink: invalidate resources on map when discarding range we can dump the whole vulkan object here for this case, which ends up being much neater Reviewed-by: Dave Airlie Part-of: --- src/gallium/drivers/zink/zink_resource.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c index 5484cd77cc9..4f3b379018e 100644 --- a/src/gallium/drivers/zink/zink_resource.c +++ b/src/gallium/drivers/zink/zink_resource.c @@ -666,6 +666,14 @@ zink_transfer_map(struct pipe_context *pctx, void *ptr; if (pres->target == PIPE_BUFFER) { if (!(usage & PIPE_MAP_UNSYNCHRONIZED)) { + if (usage & PIPE_MAP_DISCARD_WHOLE_RESOURCE) { + /* Replace the backing storage with a fresh buffer for non-async maps */ + //if (!(usage & TC_TRANSFER_MAP_NO_INVALIDATE)) + zink_resource_invalidate(pctx, pres); + + /* If we can discard the whole resource, we can discard the range. */ + usage |= PIPE_MAP_DISCARD_RANGE; + } if (util_ranges_intersect(&res->valid_buffer_range, box->x, box->x + box->width)) { /* special case compute reads since they aren't handled by zink_fence_wait() */ if (usage & PIPE_MAP_WRITE && (batch_uses & (ZINK_RESOURCE_ACCESS_READ << ZINK_COMPUTE_BATCH_ID))) @@ -683,8 +691,6 @@ zink_transfer_map(struct pipe_context *pctx, res = zink_resource(trans->staging_res); } } - if (usage & PIPE_MAP_DISCARD_WHOLE_RESOURCE) - util_range_set_empty(&res->valid_buffer_range); }