anv: Move assert in vkGetImageSubresourceLayout
authorChad Versace <chad@kiwitree.net>
Thu, 8 Apr 2021 02:08:54 +0000 (19:08 -0700)
committerMarge Bot <eric+marge@anholt.net>
Thu, 8 Apr 2021 14:15:55 +0000 (14:15 +0000)
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

index cbe4fd3..2024451 100644 (file)
@@ -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);