Mesa (staging/20.0): zink: use general-layout when blitting to/from same resource
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu May 28 18:58:05 UTC 2020
Module: Mesa
Branch: staging/20.0
Commit: 8cd4f57381cefe69019a3282d457d5bda3644030
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8cd4f57381cefe69019a3282d457d5bda3644030
Author: Erik Faye-Lund <erik.faye-lund at collabora.com>
Date: Mon May 25 12:06:04 2020 +0200
zink: use general-layout when blitting to/from same resource
This avoids a validator warning when for instance generating mipmaps.
Fixes: d2bb63c8d4c ("zink: Use optimal layout instead of general. Reduces valid layer warnings. Fixes RADV image noise.")
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5199>
(cherry picked from commit dd2bd68fa69124c86cd008b256d06f44fab8e6cd)
---
.pick_status.json | 2 +-
src/gallium/drivers/zink/zink_blit.c | 34 ++++++++++++++++++++++++++++------
2 files changed, 29 insertions(+), 7 deletions(-)
diff --git a/.pick_status.json b/.pick_status.json
index fc2c91a4c93..3ac21777d80 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -508,7 +508,7 @@
"description": "zink: use general-layout when blitting to/from same resource",
"nominated": true,
"nomination_type": 1,
- "resolution": 0,
+ "resolution": 1,
"master_sha": null,
"because_sha": "d2bb63c8d4cdc02b1c33afadea5becd58fb7286c"
},
diff --git a/src/gallium/drivers/zink/zink_blit.c b/src/gallium/drivers/zink/zink_blit.c
index bc788556bb8..76d040780f5 100644
--- a/src/gallium/drivers/zink/zink_blit.c
+++ b/src/gallium/drivers/zink/zink_blit.c
@@ -83,13 +83,35 @@ blit_native(struct zink_context *ctx, const struct pipe_blit_info *info)
zink_batch_reference_resoure(batch, src);
zink_batch_reference_resoure(batch, dst);
- if (src->layout != VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL)
- zink_resource_barrier(batch->cmdbuf, src, src->aspect,
- VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
+ if (src == dst) {
+ /* The Vulkan 1.1 specification says the following about valid usage
+ * of vkCmdBlitImage:
+ *
+ * "srcImageLayout must be VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR,
+ * VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL or VK_IMAGE_LAYOUT_GENERAL"
+ *
+ * and:
+ *
+ * "dstImageLayout must be VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR,
+ * VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL or VK_IMAGE_LAYOUT_GENERAL"
+ *
+ * Since we cant have the same image in two states at the same time,
+ * we're effectively left with VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR or
+ * VK_IMAGE_LAYOUT_GENERAL. And since this isn't a present-related
+ * operation, VK_IMAGE_LAYOUT_GENERAL seems most appropriate.
+ */
+ if (src->layout != VK_IMAGE_LAYOUT_GENERAL)
+ zink_resource_barrier(batch->cmdbuf, src, src->aspect,
+ VK_IMAGE_LAYOUT_GENERAL);
+ } else {
+ if (src->layout != VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL)
+ zink_resource_barrier(batch->cmdbuf, src, src->aspect,
+ VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
- if (dst->layout != VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL)
- zink_resource_barrier(batch->cmdbuf, dst, dst->aspect,
- VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
+ if (dst->layout != VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL)
+ zink_resource_barrier(batch->cmdbuf, dst, dst->aspect,
+ VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
+ }
VkImageBlit region = {};
region.srcSubresource.aspectMask = src->aspect;
More information about the mesa-commit
mailing list