zink: ensure layout is reasonable before copying
authorErik Faye-Lund <erik.faye-lund@collabora.com>
Mon, 15 Jul 2019 10:16:25 +0000 (12:16 +0200)
committerErik Faye-Lund <erik.faye-lund@collabora.com>
Mon, 28 Oct 2019 08:51:46 +0000 (08:51 +0000)
Acked-by: Jordan Justen <jordan.l.justen@intel.com>
src/gallium/drivers/zink/zink_context.c

index 430252441d1ef3885be76b73e1099ba3e3409a2b..15f2de6f52bb1acdec9a55979c1a6a86ed181421 100644 (file)
@@ -1338,6 +1338,20 @@ zink_resource_copy_region(struct pipe_context *pctx,
       zink_batch_reference_resoure(batch, src);
       zink_batch_reference_resoure(batch, dst);
 
+      if (src->layout != VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL &&
+          src->layout != VK_IMAGE_LAYOUT_GENERAL) {
+         zink_resource_barrier(batch->cmdbuf, src, src->aspect,
+                               VK_IMAGE_LAYOUT_GENERAL);
+         src->layout = VK_IMAGE_LAYOUT_GENERAL;
+      }
+
+      if (dst->layout != VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL &&
+          dst->layout != VK_IMAGE_LAYOUT_GENERAL) {
+         zink_resource_barrier(batch->cmdbuf, dst, dst->aspect,
+                               VK_IMAGE_LAYOUT_GENERAL);
+         dst->layout = VK_IMAGE_LAYOUT_GENERAL;
+      }
+
       vkCmdCopyImage(batch->cmdbuf, src->image, src->layout,
                      dst->image, dst->layout,
                      1, &region);