Mesa (main): anv: Use anv_get_format_plane for color image view setup
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Aug 9 16:19:12 UTC 2021
Module: Mesa
Branch: main
Commit: 7e8fe42816e855ef55f2b432d4d371737c04d355
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7e8fe42816e855ef55f2b432d4d371737c04d355
Author: Jason Ekstrand <jason at jlekstrand.net>
Date: Fri Jul 30 06:59:53 2021 -0500
anv: Use anv_get_format_plane for color image view setup
When creating a single-plane view of a multi-plane image, we were
relying on vplane_aspect to be VK_IMAGE_ASPECT_COLOR_BIT so that
anv_get_format_plane of the single-plane view format would work.
Instead of relying on this quirk, we can drop vplane_aspect and rely
entirely on vplane to only be 0 in this case. In the case of depth or
stencil images, we still need to grab the format aspect but we can use
the actual aspect and don't need the vplane_aspect trickery.
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12141>
---
src/intel/vulkan/anv_image.c | 36 +++++++++++++++++++++++++++++++-----
src/intel/vulkan/anv_private.h | 15 ---------------
2 files changed, 31 insertions(+), 20 deletions(-)
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index bd8e674c1f9..ffb618dd146 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -2816,11 +2816,37 @@ anv_CreateImageView(VkDevice _device,
anv_foreach_image_aspect_bit(iaspect_bit, image, expanded_aspects) {
uint32_t iplane =
anv_image_aspect_to_plane(image->aspects, 1UL << iaspect_bit);
- VkImageAspectFlags vplane_aspect =
- anv_plane_to_aspect(iview->aspect_mask, vplane);
- struct anv_format_plane format =
- anv_get_format_aspect(&device->info, iview->vk_format,
- vplane_aspect, image->tiling);
+ struct anv_format_plane format;
+ if (image->aspects & (VK_IMAGE_ASPECT_DEPTH_BIT |
+ VK_IMAGE_ASPECT_STENCIL_BIT)) {
+ /* With depth/stencil images, we're always given the full
+ * depth/stencil format even if we're only taking one aspect.
+ */
+ assert(iview->vk_format == image->vk_format);
+ format = anv_get_format_aspect(&device->info, iview->vk_format,
+ 1u << iaspect_bit, image->tiling);
+ } else {
+ /* With color images, we have three cases:
+ *
+ * 1. It's a single-plane image in which case vplane=0.
+ *
+ * 2. It's a YCbCr view of a multi-plane image in which case the
+ * client will have asked for VK_IMAGE_ASPECT_COLOR_BIT and the
+ * format provided will be the full planar format. In this case,
+ * we want all the planes.
+ *
+ * 3. It's a single-plane view of a multi-plane image in which case
+ * the client will have asked for VK_IMAGE_ASPECT_PLANE_N_BIT and
+ * will have provided a format compatible with that specific
+ * plane of the multi-planar format.
+ *
+ * In all three cases, the format provided by the client corresponds
+ * to exactly the planes we have in the view so we can just grab the
+ * format plane based on vplane.
+ */
+ format = anv_get_format_plane(&device->info, iview->vk_format,
+ vplane, image->tiling);
+ }
iview->planes[vplane].image_plane = iplane;
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 8e7909c7356..e89bdd55b52 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -3809,21 +3809,6 @@ anv_image_aspect_to_plane(VkImageAspectFlags image_aspects,
}
}
-static inline VkImageAspectFlags
-anv_plane_to_aspect(VkImageAspectFlags image_aspects,
- uint32_t plane)
-{
- if (image_aspects & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV) {
- if (util_bitcount(image_aspects) > 1)
- return VK_IMAGE_ASPECT_PLANE_0_BIT << plane;
- return VK_IMAGE_ASPECT_COLOR_BIT;
- }
- if (image_aspects & VK_IMAGE_ASPECT_DEPTH_BIT)
- return VK_IMAGE_ASPECT_DEPTH_BIT << plane;
- assert(image_aspects == VK_IMAGE_ASPECT_STENCIL_BIT);
- return VK_IMAGE_ASPECT_STENCIL_BIT;
-}
-
#define anv_foreach_image_aspect_bit(b, image, aspects) \
u_foreach_bit(b, anv_image_expand_aspects(image, aspects))
More information about the mesa-commit
mailing list