zink: fix buffer transfer flushes with offsets

the src and dst ofsets need to be adjusted by the base map offset
in order to flush the correct region

cc: mesa-stable

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17095>
(cherry picked from commit ce5aa07db1)
This commit is contained in:
Mike Blumenkrantz 2022-06-16 14:33:46 -04:00 committed by Dylan Baker
parent c549cb7aa1
commit d7b5c1f998
2 changed files with 5 additions and 4 deletions

View file

@ -94,7 +94,7 @@
"description": "zink: fix buffer transfer flushes with offsets",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null
},

View file

@ -1823,10 +1823,11 @@ zink_transfer_flush_region(struct pipe_context *pctx,
struct zink_screen *screen = zink_screen(pctx->screen);
struct zink_resource *m = trans->staging_res ? zink_resource(trans->staging_res) :
res;
ASSERTED VkDeviceSize size, src_offset;
ASSERTED VkDeviceSize size, src_offset, dst_offset = 0;
if (m->obj->is_buffer) {
size = box->width;
src_offset = trans->offset;
src_offset = box->x + (trans->staging_res ? trans->offset : ptrans->box.x);
dst_offset = box->x + ptrans->box.x;
} else {
size = (VkDeviceSize)box->width * box->height * util_format_get_blocksize(m->base.b.format);
src_offset = trans->offset +
@ -1845,7 +1846,7 @@ zink_transfer_flush_region(struct pipe_context *pctx,
struct zink_resource *staging_res = zink_resource(trans->staging_res);
if (ptrans->resource->target == PIPE_BUFFER)
zink_copy_buffer(ctx, res, staging_res, box->x, src_offset, box->width);
zink_copy_buffer(ctx, res, staging_res, dst_offset, src_offset, size);
else
zink_transfer_copy_bufimage(ctx, res, staging_res, trans);
}