lavapipe: handle planes in get image sub resource
authorDave Airlie <airlied@redhat.com>
Fri, 6 Oct 2023 06:07:38 +0000 (16:07 +1000)
committerMarge Bot <emma+marge@anholt.net>
Tue, 10 Oct 2023 04:37:07 +0000 (04:37 +0000)
image sub resources need to take planes into account in the calculations.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25609>

src/gallium/frontends/lavapipe/lvp_image.c

index 4d94ca8..0b9a58f 100644 (file)
@@ -379,9 +379,12 @@ VKAPI_ATTR void VKAPI_CALL lvp_GetImageSubresourceLayout(
    LVP_FROM_HANDLE(lvp_image, image, _image);
    uint64_t value;
 
+   const uint8_t p = lvp_image_aspects_to_plane(image, pSubresource->aspectMask);
+   const struct lvp_image_plane *plane = &image->planes[p];
+
    device->pscreen->resource_get_param(device->pscreen,
                                        NULL,
-                                       image->planes[0].bo,
+                                       plane->bo,
                                        0,
                                        pSubresource->arrayLayer,
                                        pSubresource->mipLevel,
@@ -392,7 +395,7 @@ VKAPI_ATTR void VKAPI_CALL lvp_GetImageSubresourceLayout(
 
    device->pscreen->resource_get_param(device->pscreen,
                                        NULL,
-                                       image->planes[0].bo,
+                                       plane->bo,
                                        0,
                                        pSubresource->arrayLayer,
                                        pSubresource->mipLevel,
@@ -403,32 +406,22 @@ VKAPI_ATTR void VKAPI_CALL lvp_GetImageSubresourceLayout(
 
    device->pscreen->resource_get_param(device->pscreen,
                                        NULL,
-                                       image->planes[0].bo,
+                                       plane->bo,
                                        0,
                                        pSubresource->arrayLayer,
                                        pSubresource->mipLevel,
                                        PIPE_RESOURCE_PARAM_LAYER_STRIDE,
                                        0, &value);
 
-   if (image->planes[0].bo->target == PIPE_TEXTURE_3D) {
+   if (plane->bo->target == PIPE_TEXTURE_3D) {
       pLayout->depthPitch = value;
       pLayout->arrayPitch = 0;
    } else {
       pLayout->depthPitch = 0;
       pLayout->arrayPitch = value;
    }
-   pLayout->size = image->size;
-
-   switch (pSubresource->aspectMask) {
-   case VK_IMAGE_ASPECT_COLOR_BIT:
-      break;
-   case VK_IMAGE_ASPECT_DEPTH_BIT:
-      break;
-   case VK_IMAGE_ASPECT_STENCIL_BIT:
-      break;
-   default:
-      assert(!"Invalid image aspect");
-   }
+   pLayout->offset += plane->plane_offset;
+   pLayout->size = plane->size;
 }
 
 VKAPI_ATTR void VKAPI_CALL lvp_GetImageSubresourceLayout2EXT(