Mesa (main): zink: fix buffer transfer flushes with offsets

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jun 17 01:13:22 UTC 2022


Module: Mesa
Branch: main
Commit: ce5aa07db1091a83321229c802f256a44f37aded
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=ce5aa07db1091a83321229c802f256a44f37aded

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Thu Jun 16 14:33:46 2022 -0400

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 at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17095>

---

 src/gallium/drivers/zink/zink_resource.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c
index 8a59a529fcf..569b625d3f7 100644
--- a/src/gallium/drivers/zink/zink_resource.c
+++ b/src/gallium/drivers/zink/zink_resource.c
@@ -1972,10 +1972,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 +
@@ -1994,7 +1995,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);
       }



More information about the mesa-commit mailing list