Mesa (master): anv: Move assert in vkGetImageSubresourceLayout

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Apr 8 14:38:25 UTC 2021


Module: Mesa
Branch: master
Commit: 46f0e5b1e9310dda1a1ef959d34adf0d8c683eaf
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=46f0e5b1e9310dda1a1ef959d34adf0d8c683eaf

Author: Chad Versace <chad at kiwitree.net>
Date:   Wed Apr  7 19:08:54 2021 -0700

anv: Move assert in vkGetImageSubresourceLayout

Assert the value is valid before we use it.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/1466>

---

 src/intel/vulkan/anv_image.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index cbe4fd3cc0d..2024451caca 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -1624,6 +1624,8 @@ void anv_GetImageSubresourceLayout(
 {
    ANV_FROM_HANDLE(anv_image, image, _image);
 
+   assert(__builtin_popcount(subresource->aspectMask) == 1);
+
    const struct anv_surface *surface;
    if (subresource->aspectMask == VK_IMAGE_ASPECT_PLANE_1_BIT &&
        image->drm_format_mod != DRM_FORMAT_MOD_INVALID &&
@@ -1640,8 +1642,6 @@ void anv_GetImageSubresourceLayout(
       surface = &image->planes[plane].primary_surface;
    }
 
-   assert(__builtin_popcount(subresource->aspectMask) == 1);
-
    layout->offset = surface->memory_range.offset;
    layout->rowPitch = surface->isl.row_pitch_B;
    layout->depthPitch = isl_surf_get_array_pitch(&surface->isl);



More information about the mesa-commit mailing list