zink: stop allocating such massive staging regions for buffer maps

this would allocate a new stream uploader for every map if the offset was
large (e.g., all sparse buffer usage), which almost immediately consumes all vram

cc: mesa-stable

fixes KHR-GL46.CommonBugs.CommonBug_SparseBuffersWithCopyOps

Acked-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14381>
This commit is contained in:
Mike Blumenkrantz 2022-01-07 12:58:06 -05:00 committed by Marge Bot
parent 7753ca2a45
commit d83b52928c

View file

@ -1320,13 +1320,13 @@ zink_buffer_map(struct pipe_context *pctx,
mgr = ctx->tc->base.stream_uploader;
else
mgr = ctx->base.stream_uploader;
u_upload_alloc(mgr, 0, box->width + box->x,
u_upload_alloc(mgr, 0, box->width,
screen->info.props.limits.minMemoryMapAlignment, &offset,
(struct pipe_resource **)&trans->staging_res, (void **)&ptr);
res = zink_resource(trans->staging_res);
trans->offset = offset + box->x;
trans->offset = offset;
usage |= PIPE_MAP_UNSYNCHRONIZED;
ptr = ((uint8_t *)ptr) + box->x;
ptr = ((uint8_t *)ptr);
} else {
/* At this point, the buffer is always idle (we checked it above). */
usage |= PIPE_MAP_UNSYNCHRONIZED;