Mesa (main): vulkan: Only be clever about vk_image_view::view_format for normal views
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue May 17 18:42:29 UTC 2022
Module: Mesa
Branch: main
Commit: 36e0f9507dc7a75f769a3f7f6fa6ccfaf7478adf
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=36e0f9507dc7a75f769a3f7f6fa6ccfaf7478adf
Author: Jason Ekstrand <jason.ekstrand at collabora.com>
Date: Fri Mar 25 19:44:17 2022 -0500
vulkan: Only be clever about vk_image_view::view_format for normal views
For color view of depth views, just set whatever format they asked for.
Reviewed-by: Iago Toral Quiroga <itoral at igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16376>
---
src/vulkan/runtime/vk_image.c | 55 ++++++++++++++++++++++---------------------
1 file changed, 28 insertions(+), 27 deletions(-)
diff --git a/src/vulkan/runtime/vk_image.c b/src/vulkan/runtime/vk_image.c
index 87beafdcaa8..65a4eaa636d 100644
--- a/src/vulkan/runtime/vk_image.c
+++ b/src/vulkan/runtime/vk_image.c
@@ -309,6 +309,7 @@ vk_image_view_init(struct vk_device *device,
assert(util_format_get_blocksize(vk_format_to_pipe_format(image->format)) ==
util_format_get_blocksize(vk_format_to_pipe_format(pCreateInfo->format)));
image_view->aspects = range->aspectMask;
+ image_view->view_format = pCreateInfo->format;
} else {
image_view->aspects =
vk_image_expand_aspect_mask(image, range->aspectMask);
@@ -344,34 +345,34 @@ vk_image_view_init(struct vk_device *device,
if (!(image->create_flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT))
assert(pCreateInfo->format == image->format);
- }
- /* Restrict the format to only the planes chosen.
- *
- * For combined depth and stencil images, this means the depth-only or
- * stencil-only format if only one aspect is chosen and the full combined
- * format if both aspects are chosen.
- *
- * For single-plane color images, we just take the format as-is. For
- * multi-plane views of multi-plane images, this means we want the full
- * multi-plane format. For single-plane views of multi-plane images, we
- * want a format compatible with the one plane. Fortunately, this is
- * already what the client gives us. The Vulkan 1.2.184 spec says:
- *
- * "If image was created with the VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT and
- * the image has a multi-planar format, and if
- * subresourceRange.aspectMask is VK_IMAGE_ASPECT_PLANE_0_BIT,
- * VK_IMAGE_ASPECT_PLANE_1_BIT, or VK_IMAGE_ASPECT_PLANE_2_BIT, format
- * must be compatible with the corresponding plane of the image, and the
- * sampler to be used with the image view must not enable sampler Y′CBCR
- * conversion."
- */
- if (image_view->aspects == VK_IMAGE_ASPECT_STENCIL_BIT) {
- image_view->view_format = vk_format_stencil_only(pCreateInfo->format);
- } else if (image_view->aspects == VK_IMAGE_ASPECT_DEPTH_BIT) {
- image_view->view_format = vk_format_depth_only(pCreateInfo->format);
- } else {
- image_view->view_format = pCreateInfo->format;
+ /* Restrict the format to only the planes chosen.
+ *
+ * For combined depth and stencil images, this means the depth-only or
+ * stencil-only format if only one aspect is chosen and the full
+ * combined format if both aspects are chosen.
+ *
+ * For single-plane color images, we just take the format as-is. For
+ * multi-plane views of multi-plane images, this means we want the full
+ * multi-plane format. For single-plane views of multi-plane images, we
+ * want a format compatible with the one plane. Fortunately, this is
+ * already what the client gives us. The Vulkan 1.2.184 spec says:
+ *
+ * "If image was created with the VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT
+ * and the image has a multi-planar format, and if
+ * subresourceRange.aspectMask is VK_IMAGE_ASPECT_PLANE_0_BIT,
+ * VK_IMAGE_ASPECT_PLANE_1_BIT, or VK_IMAGE_ASPECT_PLANE_2_BIT,
+ * format must be compatible with the corresponding plane of the
+ * image, and the sampler to be used with the image view must not
+ * enable sampler Y′CBCR conversion."
+ */
+ if (image_view->aspects == VK_IMAGE_ASPECT_STENCIL_BIT) {
+ image_view->view_format = vk_format_stencil_only(pCreateInfo->format);
+ } else if (image_view->aspects == VK_IMAGE_ASPECT_DEPTH_BIT) {
+ image_view->view_format = vk_format_depth_only(pCreateInfo->format);
+ } else {
+ image_view->view_format = pCreateInfo->format;
+ }
}
image_view->swizzle = (VkComponentMapping) {
More information about the mesa-commit
mailing list