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>
(cherry picked from commit d83b52928c)
This commit is contained in:
Mike Blumenkrantz 2022-01-07 12:58:06 -05:00 committed by Eric Engestrom
parent 089a957bef
commit 107c8232e0
2 changed files with 4 additions and 4 deletions

View file

@ -2110,7 +2110,7 @@
"description": "zink: stop allocating such massive staging regions for buffer maps",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null
},

View file

@ -1231,13 +1231,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;