From d7256043b3ac3652a070ed0384db80effc99ed96 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 15 Apr 2022 13:25:00 -0400 Subject: [PATCH] zink: handle device-local unsynchronized maps this is only possible when tc determines the buffer is not in use and decides to return a pointer immediately, so just give back a staging buffer cc: mesa-stable Reviewed-by: Dave Airlie Part-of: --- src/gallium/drivers/zink/zink_resource.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c index d72aa5fa1e5..80c74449130 100644 --- a/src/gallium/drivers/zink/zink_resource.c +++ b/src/gallium/drivers/zink/zink_resource.c @@ -1506,6 +1506,15 @@ zink_buffer_map(struct pipe_context *pctx, ptr = map_resource(screen, res); ptr = ((uint8_t *)ptr) + trans->offset; } + } else if ((usage & PIPE_MAP_UNSYNCHRONIZED) && !res->obj->host_visible) { + trans->offset = box->x % screen->info.props.limits.minMemoryMapAlignment; + trans->staging_res = pipe_buffer_create(&screen->base, PIPE_BIND_LINEAR, PIPE_USAGE_STAGING, box->width + trans->offset); + if (!trans->staging_res) + goto fail; + struct zink_resource *staging_res = zink_resource(trans->staging_res); + res = staging_res; + ptr = map_resource(screen, res); + ptr = ((uint8_t *)ptr) + trans->offset; } if (!(usage & PIPE_MAP_UNSYNCHRONIZED)) {