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 <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9546>
This commit is contained in:
Mike Blumenkrantz 2020-10-27 14:31:29 -04:00 committed by Marge Bot
parent cfa361e6cd
commit d5367cee09

View file

@ -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);
}