From 237e2d7b32c84523df48a8539cbc72cc49bcacfa Mon Sep 17 00:00:00 2001 From: Caterina Shablia Date: Mon, 26 Jan 2026 22:29:18 +0000 Subject: [PATCH] panvk: implement sparseResidencyImage3D Reviewed-by: Boris Brezillon Part-of: --- src/panfrost/vulkan/csf/panvk_vX_bind_queue.c | 6 ++---- src/panfrost/vulkan/panvk_image.c | 5 +++-- src/panfrost/vulkan/panvk_vX_physical_device.c | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/panfrost/vulkan/csf/panvk_vX_bind_queue.c b/src/panfrost/vulkan/csf/panvk_vX_bind_queue.c index 3dea3e17e11..a3c92eb8384 100644 --- a/src/panfrost/vulkan/csf/panvk_vX_bind_queue.c +++ b/src/panfrost/vulkan/csf/panvk_vX_bind_queue.c @@ -364,10 +364,6 @@ panvk_bind_queue_submit_sparse_block_memory_bind( uint64_t resource_va = image->sparse.device_address; const struct panvk_image_plane *plane = &image->planes[in->plane_index]; - /* 3D images are not yet supported. See - * https://gitlab.freedesktop.org/panfrost/mesa/-/issues/242 */ - assert(image->vk.image_type == VK_IMAGE_TYPE_2D); - /* Previously, sparse residency was implemented using block U-interleaved * (https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37483). * Interleaved 64k offers better map and unmap performance (at most one bind @@ -396,6 +392,8 @@ panvk_bind_queue_submit_sparse_block_memory_bind( in->extent.depth == 1); uint32_t tile_size_B = 65536; + assert(image->vk.image_type != VK_IMAGE_TYPE_3D || in->layer == 0); + const struct pan_image_slice_layout *slayout = &plane->plane.layout.slices[in->level]; VkSparseMemoryBind bind = { .resourceOffset = diff --git a/src/panfrost/vulkan/panvk_image.c b/src/panfrost/vulkan/panvk_image.c index 9d4ebfb73fb..cee891f6458 100644 --- a/src/panfrost/vulkan/panvk_image.c +++ b/src/panfrost/vulkan/panvk_image.c @@ -1023,7 +1023,8 @@ panvk_get_sparse_block_desc(VkImageType type, VkFormat format) uint32_t texel_block_size_B = fmt_desc->block.bits / 8; switch (type) { - case VK_IMAGE_TYPE_2D: { + case VK_IMAGE_TYPE_2D: + case VK_IMAGE_TYPE_3D: { if (!util_is_power_of_two_nonzero(texel_block_size_B)) break; @@ -1041,7 +1042,7 @@ panvk_get_sparse_block_desc(VkImageType type, VkFormat format) return (struct panvk_sparse_block_desc){ .extent = extent, .size_B = STANDARD_SPARSE_BLOCK_SIZE_B, - .standard = true, + .standard = type == VK_IMAGE_TYPE_2D, }; } diff --git a/src/panfrost/vulkan/panvk_vX_physical_device.c b/src/panfrost/vulkan/panvk_vX_physical_device.c index 7d4b3cc0831..bf18a619fc9 100644 --- a/src/panfrost/vulkan/panvk_vX_physical_device.c +++ b/src/panfrost/vulkan/panvk_vX_physical_device.c @@ -305,7 +305,7 @@ panvk_per_arch(get_physical_device_features)( .sparseBinding = has_sparse, .sparseResidencyBuffer = has_sparse, .sparseResidencyImage2D = has_sparse, - .sparseResidencyImage3D = false, /* https://gitlab.freedesktop.org/panfrost/mesa/-/issues/242 */ + .sparseResidencyImage3D = has_sparse, .sparseResidency2Samples = false, .sparseResidency4Samples = false, .sparseResidency8Samples = false,