Mesa (main): anv: Stop assuming planes are in aspect-bit-order

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Aug 9 16:19:12 UTC 2021


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

Author: Jason Ekstrand <jason at jlekstrand.net>
Date:   Fri Jul 30 16:58:22 2021 -0500

anv: Stop assuming planes are in aspect-bit-order

Previously, we initialized vplane in anv_CreateImageView to 0 and
incremented it every iteration of the aspect loop.  This only works
because planes are guaranteed to be in aspect-bit-order which wasn't
documented anywhere.  Instead, drop this assumption and burn a couple
CPU cycles properly calculating vplane.

While we're here, make iplane const as well.

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 | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index ffb618dd146..5c2c682d02c 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -2812,10 +2812,11 @@ anv_CreateImageView(VkDevice _device,
    /* Now go through the underlying image selected planes (computed in
     * expanded_aspects) and map them to planes in the image view.
     */
-   uint32_t vplane = 0;
    anv_foreach_image_aspect_bit(iaspect_bit, image, expanded_aspects) {
-      uint32_t iplane =
+      const uint32_t iplane =
          anv_image_aspect_to_plane(image->aspects, 1UL << iaspect_bit);
+      const uint32_t vplane =
+         anv_image_aspect_to_plane(expanded_aspects, 1UL << iaspect_bit);
       struct anv_format_plane format;
       if (image->aspects & (VK_IMAGE_ASPECT_DEPTH_BIT |
                             VK_IMAGE_ASPECT_STENCIL_BIT)) {
@@ -2946,8 +2947,6 @@ anv_CreateImageView(VkDevice _device,
                                       &iview->planes[vplane].writeonly_storage_surface_state,
                                       NULL);
       }
-
-      vplane++;
    }
 
    *pView = anv_image_view_to_handle(iview);



More information about the mesa-commit mailing list