diff --git a/src/panfrost/vulkan/panvk_host_copy.c b/src/panfrost/vulkan/panvk_host_copy.c index 9fe93bd4e7e..b95aa407324 100644 --- a/src/panfrost/vulkan/panvk_host_copy.c +++ b/src/panfrost/vulkan/panvk_host_copy.c @@ -83,7 +83,7 @@ panvk_copy_image_to_from_memory(struct image_params img, */ assert(util_bitcount(img.subres.aspectMask) == 1); unsigned plane_idx = - panvk_plane_index(img.img->vk.format, img.subres.aspectMask); + panvk_plane_index(img.img, img.subres.aspectMask); assert(plane_idx < PANVK_MAX_PLANES); struct panvk_image_plane *plane = &img.img->planes[plane_idx]; const struct pan_image_layout *plane_layout = &plane->plane.layout; @@ -260,8 +260,8 @@ panvk_CopyMemoryToImage(VkDevice device, const VkCopyMemoryToImageInfo *info) VkResult result = VK_SUCCESS; for (unsigned i = 0; i < info->regionCount; i++) { - uint8_t p = panvk_plane_index( - dst->vk.format, info->pRegions[i].imageSubresource.aspectMask); + uint8_t p = + panvk_plane_index(dst, info->pRegions[i].imageSubresource.aspectMask); result = mmap_plane(dst, p, PROT_WRITE, dst_cpu); if (result != VK_SUCCESS) @@ -304,8 +304,8 @@ panvk_CopyImageToMemory(VkDevice device, const VkCopyImageToMemoryInfo *info) VkResult result = VK_SUCCESS; for (unsigned i = 0; i < info->regionCount; i++) { - uint8_t p = panvk_plane_index( - src->vk.format, info->pRegions[i].imageSubresource.aspectMask); + uint8_t p = + panvk_plane_index(src, info->pRegions[i].imageSubresource.aspectMask); result = mmap_plane(src, p, PROT_READ, src_cpu); if (result != VK_SUCCESS) @@ -337,10 +337,8 @@ panvk_copy_image_to_image(struct panvk_image *dst, void *dst_cpu, VkImageSubresourceLayers src_subres = region->srcSubresource; VkImageSubresourceLayers dst_subres = region->dstSubresource; - unsigned src_plane_idx = - panvk_plane_index(src->vk.format, src_subres.aspectMask); - unsigned dst_plane_idx = - panvk_plane_index(dst->vk.format, dst_subres.aspectMask); + unsigned src_plane_idx = panvk_plane_index(src, src_subres.aspectMask); + unsigned dst_plane_idx = panvk_plane_index(dst, dst_subres.aspectMask); assert(src_plane_idx < PANVK_MAX_PLANES); assert(dst_plane_idx < PANVK_MAX_PLANES); struct panvk_image_plane *src_plane = &src->planes[src_plane_idx]; @@ -482,10 +480,10 @@ panvk_CopyImageToImage(VkDevice device, const VkCopyImageToImageInfo *info) void *dst_cpu[PANVK_MAX_PLANES] = {NULL}; for (unsigned i = 0; i < info->regionCount; i++) { - uint8_t src_p = panvk_plane_index( - src->vk.format, info->pRegions[i].srcSubresource.aspectMask); - uint8_t dst_p = panvk_plane_index( - dst->vk.format, info->pRegions[i].dstSubresource.aspectMask); + uint8_t src_p = + panvk_plane_index(src, info->pRegions[i].srcSubresource.aspectMask); + uint8_t dst_p = + panvk_plane_index(dst, info->pRegions[i].dstSubresource.aspectMask); result = mmap_plane(dst, dst_p, PROT_WRITE, dst_cpu); if (result != VK_SUCCESS) diff --git a/src/panfrost/vulkan/panvk_image.c b/src/panfrost/vulkan/panvk_image.c index 294545fe2fc..f689c2a92e5 100644 --- a/src/panfrost/vulkan/panvk_image.c +++ b/src/panfrost/vulkan/panvk_image.c @@ -574,7 +574,7 @@ get_image_subresource_layout(const struct panvk_image *image, { const VkImageSubresource *subres = &subres2->imageSubresource; VkSubresourceLayout *layout = &layout2->subresourceLayout; - unsigned plane = panvk_plane_index(image->vk.format, subres->aspectMask); + unsigned plane = panvk_plane_index(image, subres->aspectMask); assert(plane < PANVK_MAX_PLANES); const struct pan_image_slice_layout *slice_layout = @@ -658,7 +658,7 @@ panvk_GetImageMemoryRequirements2(VkDevice device, const bool disjoint = is_disjoint(image); const VkImageAspectFlags aspects = plane_info ? plane_info->planeAspect : image->vk.aspects; - uint8_t plane = panvk_plane_index(image->vk.format, aspects); + uint8_t plane = panvk_plane_index(image, aspects); const uint64_t size = disjoint ? image->planes[plane].plane.layout.data_size_B : panvk_image_get_total_size(image); @@ -754,7 +754,7 @@ panvk_image_bind(struct panvk_device *dev, const VkBindImagePlaneMemoryInfo *plane_info = vk_find_struct_const(bind_info->pNext, BIND_IMAGE_PLANE_MEMORY_INFO); const uint8_t plane = - panvk_plane_index(image->vk.format, plane_info->planeAspect); + panvk_plane_index(image, plane_info->planeAspect); panvk_image_plane_bind(dev, &image->planes[plane], mem, offset); } else { for (unsigned plane = 0; plane < image->plane_count; plane++) diff --git a/src/panfrost/vulkan/panvk_image.h b/src/panfrost/vulkan/panvk_image.h index 021c5d086e1..39f284539ef 100644 --- a/src/panfrost/vulkan/panvk_image.h +++ b/src/panfrost/vulkan/panvk_image.h @@ -48,7 +48,8 @@ bool panvk_image_can_use_afbc( VkImageCreateFlags flags); static inline unsigned -panvk_plane_index(VkFormat format, VkImageAspectFlags aspect_mask) +panvk_plane_index(const struct panvk_image *image, + VkImageAspectFlags aspect_mask) { switch (aspect_mask) { default: @@ -58,7 +59,8 @@ panvk_plane_index(VkFormat format, VkImageAspectFlags aspect_mask) case VK_IMAGE_ASPECT_PLANE_2_BIT: return 2; case VK_IMAGE_ASPECT_STENCIL_BIT: - return format == VK_FORMAT_D32_SFLOAT_S8_UINT; + assert(image->plane_count > 0); + return image->plane_count - 1; } } diff --git a/src/panfrost/vulkan/panvk_vX_cmd_meta.c b/src/panfrost/vulkan/panvk_vX_cmd_meta.c index 4c34f6544bd..5393b06a74f 100644 --- a/src/panfrost/vulkan/panvk_vX_cmd_meta.c +++ b/src/panfrost/vulkan/panvk_vX_cmd_meta.c @@ -586,7 +586,7 @@ panvk_image_has_afbc(struct panvk_image *img, VkImageSubresourceRange range) VkImageAspectFlags aspect_mask = vk_image_expand_aspect_mask(&img->vk, range.aspectMask); u_foreach_bit(aspect, aspect_mask) { - unsigned plane_index = panvk_plane_index(img->vk.format, 1u << aspect); + unsigned plane_index = panvk_plane_index(img, 1u << aspect); struct panvk_image_plane *plane = &img->planes[plane_index]; if (drm_is_afbc(plane->image.props.modifier)) @@ -613,7 +613,7 @@ cmd_clear_afbc_metadata(VkCommandBuffer _cmdbuf, panvk_per_arch(cmd_meta_compute_start)(cmdbuf, &save); u_foreach_bit(aspect, aspect_mask) { - unsigned plane_index = panvk_plane_index(img->vk.format, 1u << aspect); + unsigned plane_index = panvk_plane_index(img, 1u << aspect); struct panvk_image_plane *plane = &img->planes[plane_index]; if (!drm_is_afbc(plane->image.props.modifier)) diff --git a/src/panfrost/vulkan/panvk_vX_image_view.c b/src/panfrost/vulkan/panvk_vX_image_view.c index d2f396481a3..b8d7d7bbecc 100644 --- a/src/panfrost/vulkan/panvk_vX_image_view.c +++ b/src/panfrost/vulkan/panvk_vX_image_view.c @@ -329,8 +329,7 @@ panvk_per_arch(CreateImageView)(VkDevice _device, panvk_convert_swizzle(&view->vk.swizzle, view->pview.swizzle); u_foreach_bit(aspect_bit, view->vk.aspects) { - uint8_t image_plane = - panvk_plane_index(image->vk.format, 1u << aspect_bit); + uint8_t image_plane = panvk_plane_index(image, 1u << aspect_bit); /* Place the view plane at index 0 for single-plane views of multiplane * formats. Does not apply to YCbCr views of multiplane images since