diff --git a/docs/features.txt b/docs/features.txt index fcd46e55645..a6f1793aa99 100644 --- a/docs/features.txt +++ b/docs/features.txt @@ -681,6 +681,7 @@ Khronos extensions that are not part of any Vulkan version: VK_GOOGLE_user_type DONE (anv, hasvk, hk, nvk, panvk, radv, tu, vn) VK_IMG_filter_cubic DONE (tu/a650+, vn) VK_NV_compute_shader_derivatives DONE (anv, hasvk, nvk, radv, tu/a7xx+, vn) + VK_NVX_image_view_handle DONE (nvk) VK_EXT_acquire_drm_display DONE (anv, hk, nvk, radv, tu, v3dv, vn) VK_VALVE_mutable_descriptor_type DONE (anv, hasvk, hk, nvk, radv, tu, vn) VK_AMD_buffer_marker DONE (anv, nvk, radv, tu) diff --git a/docs/relnotes/new_features.txt b/docs/relnotes/new_features.txt index d7384bceae5..1e04bc3b847 100644 --- a/docs/relnotes/new_features.txt +++ b/docs/relnotes/new_features.txt @@ -86,3 +86,4 @@ VK_KHR_device_group on pvr VK_KHR_buffer_device_address on pvr GL_EXT_mesh_shader on zink VK_KHR_wayland_surface on pvr +VK_NVX_image_view_handle on NVK diff --git a/src/nouveau/vulkan/nvk_image.h b/src/nouveau/vulkan/nvk_image.h index 1f576e66e29..3190138313c 100644 --- a/src/nouveau/vulkan/nvk_image.h +++ b/src/nouveau/vulkan/nvk_image.h @@ -119,6 +119,12 @@ nvk_image_base_address(const struct nvk_image *image, uint8_t plane) return nvk_image_plane_base_address(&image->planes[plane]); } +static inline uint64_t +nvk_image_size_B(const struct nvk_image *image, uint8_t plane) +{ + return image->planes[plane].nil.size_B; +} + static inline uint8_t nvk_image_aspects_to_plane(const struct nvk_image *image, VkImageAspectFlags aspectMask) diff --git a/src/nouveau/vulkan/nvk_image_view.c b/src/nouveau/vulkan/nvk_image_view.c index 9e7e81f9b1a..90f7e4d9bd3 100644 --- a/src/nouveau/vulkan/nvk_image_view.c +++ b/src/nouveau/vulkan/nvk_image_view.c @@ -8,6 +8,7 @@ #include "nvk_entrypoints.h" #include "nvk_format.h" #include "nvk_image.h" +#include "nvk_sampler.h" #include "nvk_physical_device.h" #include "vk_format.h" @@ -359,3 +360,58 @@ nvk_GetImageViewOpaqueCaptureDescriptorDataEXT( return VK_SUCCESS; } + + +VKAPI_ATTR uint32_t VKAPI_CALL +nvk_GetImageViewHandleNVX(VkDevice _device, + const VkImageViewHandleInfoNVX *pInfo) +{ + VK_FROM_HANDLE(nvk_image_view, view, pInfo->imageView); + VK_FROM_HANDLE(nvk_sampler, sampler, pInfo->sampler); + assert(view->plane_count == 1); + + uint32_t handle = 0; + if (pInfo->descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) { + struct nvk_storage_image_descriptor desc; + STATIC_ASSERT(sizeof(desc) == sizeof(handle)); + + desc.image_index = view->planes[0].storage_desc_index; + memcpy(&handle, &desc, sizeof(uint32_t)); + } else { + struct nvk_sampled_image_descriptor desc; + STATIC_ASSERT(sizeof(desc) == sizeof(handle)); + + desc.image_index = view->planes[0].sampled_desc_index; + if (pInfo->descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) { + assert(sampler->plane_count == 1); + desc.sampler_index = sampler->planes[0].desc_index; + } + memcpy(&handle, &desc, sizeof(uint32_t)); + } + + return handle; +} + +VKAPI_ATTR uint64_t VKAPI_CALL +nvk_GetImageViewHandle64NVX(VkDevice _device, + const VkImageViewHandleInfoNVX *pInfo) +{ + /* NVK does not currently support 64-bit texture addressing, + * so this is the same as vkGetImageViewHandleNVX. */ + + return nvk_GetImageViewHandleNVX(_device, pInfo); +} + +VKAPI_ATTR VkResult VKAPI_CALL +nvk_GetImageViewAddressNVX(VkDevice _device, VkImageView _imageView, + VkImageViewAddressPropertiesNVX *pProperties) +{ + VK_FROM_HANDLE(nvk_image_view, image_view, _imageView); + const struct nvk_image *image = (struct nvk_image *)image_view->vk.image; + + const uint8_t plane = image_view->planes[0].image_plane; + pProperties->deviceAddress = nvk_image_base_address(image, plane); + pProperties->size = nvk_image_size_B(image, plane); + + return VK_SUCCESS; +} diff --git a/src/nouveau/vulkan/nvk_physical_device.c b/src/nouveau/vulkan/nvk_physical_device.c index 1dd25ce05c9..3c13ddb51f6 100644 --- a/src/nouveau/vulkan/nvk_physical_device.c +++ b/src/nouveau/vulkan/nvk_physical_device.c @@ -290,6 +290,7 @@ nvk_get_device_extensions(const struct nvk_instance *instance, .MESA_image_alignment_control = true, .NV_compute_shader_derivatives = info->cls_eng3d >= TURING_A, .NV_shader_sm_builtins = true, + .NVX_image_view_handle = info->cls_eng3d >= MAXWELL_A, /* needs true bindless descriptors */ .VALVE_mutable_descriptor_type = true, }; }