From f0b038cb7fa83aff5a7fd663675f83dcfd2612fe Mon Sep 17 00:00:00 2001 From: Aitor Camacho Date: Thu, 5 Feb 2026 06:26:05 +0900 Subject: [PATCH] kk: Expose VK_EXT_image_2d_view_of_3d Add missing flag for the 2d_view_of_3d, no further changes needed. Signed-off-by: Aitor Camacho Part-of: --- docs/features.txt | 2 +- src/kosmickrisp/vulkan/kk_image.c | 10 ++++----- src/kosmickrisp/vulkan/kk_image.h | 23 --------------------- src/kosmickrisp/vulkan/kk_physical_device.c | 5 +++++ 4 files changed, 11 insertions(+), 29 deletions(-) diff --git a/docs/features.txt b/docs/features.txt index a005f45132c..c9e9accb490 100644 --- a/docs/features.txt +++ b/docs/features.txt @@ -638,7 +638,7 @@ Khronos extensions that are not part of any Vulkan version: VK_EXT_graphics_pipeline_library DONE (anv, hk, lvp, nvk, panvk, radv, tu, vn) VK_EXT_hdr_metadata DONE (anv, hk, lvp, nvk, panvk, radv, tu, vn) VK_EXT_headless_surface DONE (anv, dzn, hasvk, hk, lvp, nvk, panvk, pvr, radv, tu, v3dv, vn) - VK_EXT_image_2d_view_of_3d DONE (anv, hasvk, hk, lvp, nvk, panvk, pvr, radv, tu, vn) + VK_EXT_image_2d_view_of_3d DONE (anv, hasvk, hk, kk, lvp, nvk, panvk, pvr, radv, tu, vn) VK_EXT_image_compression_control DONE (anv/gfx12-, radv) VK_EXT_image_drm_format_modifier DONE (anv, hasvk, hk, lvp, nvk, panvk, pvr, radv/gfx9+, tu, v3dv, vn) VK_EXT_image_sliced_view_of_3d DONE (anv, hk, lvp, nvk, radv/gfx10+, vn) diff --git a/src/kosmickrisp/vulkan/kk_image.c b/src/kosmickrisp/vulkan/kk_image.c index f3cd1efa47b..8583fc329fc 100644 --- a/src/kosmickrisp/vulkan/kk_image.c +++ b/src/kosmickrisp/vulkan/kk_image.c @@ -605,7 +605,8 @@ kk_CreateImage(VkDevice _device, const VkImageCreateInfo *pCreateInfo, VkResult result; if (wsi_common_is_swapchain_image(pCreateInfo)) - return wsi_common_create_swapchain_image(&pdev->wsi_device, pCreateInfo, pImage); + return wsi_common_create_swapchain_image(&pdev->wsi_device, pCreateInfo, + pImage); image = vk_zalloc2(&dev->vk.alloc, pAllocator, sizeof(*image), 8, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); @@ -844,12 +845,11 @@ kk_image_plane_bind(struct kk_device *dev, struct kk_image *image, /* Create auxiliary 2D array texture for 3D images so we can use 2D views of * it */ if (plane->layout.type == MTL_TEXTURE_TYPE_3D && - (image->vk.create_flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT)) { + (image->vk.create_flags & + (VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT | + VK_IMAGE_CREATE_2D_VIEW_COMPATIBLE_BIT_EXT))) { struct kk_image_layout array_layout = plane->layout; array_layout.type = MTL_TEXTURE_TYPE_2D_ARRAY; - // TODO_KOSMICKRISP We need to make sure that this doesn't go over Metal's - // layer maximum which is 2048. Probably by limiting the dimensions and - // layers for 3D images array_layout.layers = array_layout.layers * array_layout.depth_px; array_layout.depth_px = 1u; plane->mtl_handle_array = mtl_new_texture_with_descriptor( diff --git a/src/kosmickrisp/vulkan/kk_image.h b/src/kosmickrisp/vulkan/kk_image.h index 7ef11db3133..8c9c0bb20c6 100644 --- a/src/kosmickrisp/vulkan/kk_image.h +++ b/src/kosmickrisp/vulkan/kk_image.h @@ -17,29 +17,6 @@ #include "vk_image.h" -/* Because small images can end up with an array_stride_B that is less than - * the sparse block size (in bytes), we have to set SINGLE_MIPTAIL_BIT when - * advertising sparse properties to the client. This means that we get one - * single memory range for the miptail of the image. For large images with - * mipTailStartLod > 0, we have to deal with the array stride ourselves. - * - * We do this by returning NVK_MIP_TAIL_START_OFFSET as the image's - * imageMipTailOffset. We can then detect anything with that address as - * being part of the miptail and re-map it accordingly. The Vulkan spec - * explicitly allows for this. - * - * From the Vulkan 1.3.279 spec: - * - * "When VK_SPARSE_MEMORY_BIND_METADATA_BIT is present, the resourceOffset - * must have been derived explicitly from the imageMipTailOffset in the - * sparse resource properties returned for the metadata aspect. By - * manipulating the value returned for imageMipTailOffset, the - * resourceOffset does not have to correlate directly to a device virtual - * address offset, and may instead be whatever value makes it easiest for - * the implementation to derive the correct device virtual address." - */ -#define NVK_MIP_TAIL_START_OFFSET 0x6d74000000000000UL - struct kk_device_memory; struct kk_physical_device; struct kk_queue; diff --git a/src/kosmickrisp/vulkan/kk_physical_device.c b/src/kosmickrisp/vulkan/kk_physical_device.c index d1d4afc4b1c..7aa05ba6da9 100644 --- a/src/kosmickrisp/vulkan/kk_physical_device.c +++ b/src/kosmickrisp/vulkan/kk_physical_device.c @@ -136,6 +136,7 @@ kk_get_device_extensions(const struct kk_instance *instance, .EXT_calibrated_timestamps = true, .EXT_external_memory_metal = true, + .EXT_image_2d_view_of_3d = true, .EXT_load_store_op_none = true, .EXT_mutable_descriptor_type = true, .EXT_shader_atomic_float = true, @@ -296,6 +297,10 @@ kk_get_device_features( .formatA4R4G4B4 = true, .formatA4B4G4R4 = true, + /* EXT_image_2d_view_of_3d */ + .image2DViewOf3D = true, + .sampler2DViewOf3D = true, + /* VK_EXT_shader_replicated_composites */ .shaderReplicatedComposites = true,