@@ -2074,6 +2074,21 @@ VMA_CALL_PRE void VMA_CALL_POST vmaGetAllocationMemoryProperties(
20742074 VmaAllocation VMA_NOT_NULL allocation,
20752075 VkMemoryPropertyFlags* VMA_NOT_NULL pFlags);
20762076
2077+
2078+ #if VMA_EXTERNAL_MEMORY_WIN32
2079+ /**
2080+ \brief Given an allocation, returns Win32 Handle, that may be imported by other processes or APIs.
2081+
2082+ `hTargetProcess` must be a valid handle to target process or NULL. If it's `NULL`, the function returns
2083+ handle for the current process.
2084+
2085+ If the allocation was created with `VMA_ALLOCATION_CREATE_EXPORT_WIN32_HANDLE_BIT` flag,
2086+ the function fills `pHandle` with handle that can be used in target process.
2087+ */
2088+ VMA_CALL_PRE VkResult VMA_CALL_POST vmaGetMemoryWin32HandleKHR(VmaAllocator VMA_NOT_NULL allocator,
2089+ VmaAllocation VMA_NOT_NULL allocation, HANDLE hTargetProcess, HANDLE* VMA_NOT_NULL pHandle);
2090+ #endif // VMA_EXTERNAL_MEMORY_WIN32
2091+
20772092/** \brief Maps memory represented by given allocation and returns pointer to it.
20782093
20792094Maps memory represented by given allocation to make it accessible to CPU code.
@@ -6345,7 +6360,7 @@ struct VmaAllocation_T
63456360#endif
63466361
63476362#if VMA_EXTERNAL_MEMORY_WIN32
6348- VkResult GetWin32Handle(VmaAllocator hAllocator, HANDLE hTargetProcess, HANDLE* hHandle) const noexcept;
6363+ VkResult GetWin32Handle(VmaAllocator hAllocator, HANDLE hTargetProcess, HANDLE* hHandle) noexcept;
63496364#endif // VMA_EXTERNAL_MEMORY_WIN32
63506365
63516366private:
@@ -6363,7 +6378,7 @@ struct VmaAllocation_T
63636378 void* m_pMappedData; // Not null means memory is mapped.
63646379 VmaAllocation_T* m_Prev;
63656380 VmaAllocation_T* m_Next;
6366- mutable VmaWin32Handle m_Handle; // Win32 handle
6381+ VmaWin32Handle m_Handle; // Win32 handle
63676382 };
63686383 union
63696384 {
@@ -11101,7 +11116,7 @@ void VmaAllocation_T::PrintParameters(class VmaJsonWriter& json) const
1110111116 }
1110211117}
1110311118#if VMA_EXTERNAL_MEMORY_WIN32
11104- VkResult VmaAllocation_T::GetWin32Handle(VmaAllocator hAllocator, HANDLE hTargetProcess, HANDLE* pHandle) const noexcept
11119+ VkResult VmaAllocation_T::GetWin32Handle(VmaAllocator hAllocator, HANDLE hTargetProcess, HANDLE* pHandle) noexcept
1110511120{
1110611121 // Where do we get this function from?
1110711122 auto pvkGetMemoryWin32HandleKHR = hAllocator->GetVulkanFunctions().vkGetMemoryWin32HandleKHR;
@@ -13127,12 +13142,6 @@ void VmaAllocator_T::ImportVulkanFunctions_Static()
1312713142 m_VulkanFunctions.vkGetDeviceImageMemoryRequirements = (PFN_vkGetDeviceImageMemoryRequirements)vkGetDeviceImageMemoryRequirements;
1312813143 }
1312913144#endif
13130- #if VMA_EXTERNAL_MEMORY_WIN32
13131- // Can only be fetched dynamically
13132- m_VulkanFunctions.vkGetMemoryWin32HandleKHR = (PFN_vkGetMemoryWin32HandleKHR)m_VulkanFunctions.vkGetDeviceProcAddr(m_hDevice, "vkGetMemoryWin32HandleKHR");
13133- #else
13134- m_VulkanFunctions.vkGetMemoryWin32HandleKHR = VMA_NULL;
13135- #endif
1313613145}
1313713146
1313813147#endif // VMA_STATIC_VULKAN_FUNCTIONS == 1
@@ -16604,7 +16613,7 @@ VMA_CALL_PRE void VMA_CALL_POST vmaFreeVirtualBlockStatsString(VmaVirtualBlock V
1660416613}
1660516614#if VMA_EXTERNAL_MEMORY_WIN32
1660616615VMA_CALL_PRE VkResult VMA_CALL_POST vmaGetMemoryWin32HandleKHR(VmaAllocator VMA_NOT_NULL allocator,
16607- VmaAllocation VMA_NOT_NULL allocation, HANDLE hTargetProcess, HANDLE* pHandle)
16616+ VmaAllocation VMA_NOT_NULL allocation, HANDLE hTargetProcess, HANDLE* VMA_NOT_NULL pHandle)
1660816617{
1660916618 VMA_ASSERT(allocator && allocation);
1661016619 VMA_DEBUG_GLOBAL_MUTEX_LOCK;
0 commit comments