mirror of
https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git
synced 2025-05-14 16:58:34 +00:00
Added VmaAllocatorCreateInfo::pTypeExternalMemoryHandleTypes
This commit is contained in:
parent
96ec5ce4e7
commit
e92f989423
56 changed files with 16542 additions and 16403 deletions
|
@ -2121,6 +2121,15 @@ available through VmaAllocatorCreateInfo::pRecordSettings.
|
|||
#endif
|
||||
#endif
|
||||
|
||||
// Defined to 1 when VK_KHR_external_memory device extension is defined in Vulkan headers.
|
||||
#if !defined(VMA_EXTERNAL_MEMORY)
|
||||
#if VK_KHR_external_memory
|
||||
#define VMA_EXTERNAL_MEMORY 1
|
||||
#else
|
||||
#define VMA_EXTERNAL_MEMORY 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Define these macros to decorate all public functions with additional code,
|
||||
// before and after returned type, appropriately. This may be useful for
|
||||
// exporting the functions when compiling VMA as a separate library. Example:
|
||||
|
@ -2494,6 +2503,18 @@ typedef struct VmaAllocatorCreateInfo
|
|||
Leaving it initialized to zero is equivalent to `VK_API_VERSION_1_0`.
|
||||
*/
|
||||
uint32_t vulkanApiVersion;
|
||||
#if VMA_EXTERNAL_MEMORY
|
||||
/** \brief Either null or a pointer to an array of external memory handle types for each Vulkan memory type.
|
||||
|
||||
If not NULL, it must be a pointer to an array of `VkPhysicalDeviceMemoryProperties::memoryTypeCount`
|
||||
elements, defining external memory handle types of particular Vulkan memory type,
|
||||
to be passed using `VkExportMemoryAllocateInfoKHR`.
|
||||
|
||||
Any of the elements may be equal to 0, which means not to use `VkExportMemoryAllocateInfoKHR` on this memory type.
|
||||
This is also the default in case of `pTypeExternalMemoryHandleTypes` = NULL.
|
||||
*/
|
||||
const VkExternalMemoryHandleTypeFlagsKHR* VMA_NULLABLE VMA_LEN_IF_NOT_NULL("VkPhysicalDeviceMemoryProperties::memoryTypeCount") pTypeExternalMemoryHandleTypes;
|
||||
#endif // #if VMA_EXTERNAL_MEMORY
|
||||
} VmaAllocatorCreateInfo;
|
||||
|
||||
/// Creates Allocator object.
|
||||
|
@ -8395,6 +8416,12 @@ public:
|
|||
*/
|
||||
uint32_t GetGpuDefragmentationMemoryTypeBits();
|
||||
|
||||
#if VMA_EXTERNAL_MEMORY
|
||||
VkExternalMemoryHandleTypeFlagsKHR GetExternalMemoryHandleTypeFlags(uint32_t memTypeIndex) const
|
||||
{
|
||||
return m_TypeExternalMemoryHandleTypes[memTypeIndex];
|
||||
}
|
||||
#endif // #if VMA_EXTERNAL_MEMORY
|
||||
|
||||
private:
|
||||
VkDeviceSize m_PreferredLargeHeapBlockSize;
|
||||
|
@ -8402,6 +8429,9 @@ private:
|
|||
VkPhysicalDevice m_PhysicalDevice;
|
||||
VMA_ATOMIC_UINT32 m_CurrentFrameIndex;
|
||||
VMA_ATOMIC_UINT32 m_GpuDefragmentationMemoryTypeBits; // UINT32_MAX means uninitialized.
|
||||
#if VMA_EXTERNAL_MEMORY
|
||||
VkExternalMemoryHandleTypeFlagsKHR m_TypeExternalMemoryHandleTypes[VK_MAX_MEMORY_TYPES];
|
||||
#endif // #if VMA_EXTERNAL_MEMORY
|
||||
|
||||
VMA_RW_MUTEX m_PoolsMutex;
|
||||
typedef VmaIntrusiveLinkedList<VmaPoolListItemTraits> PoolList;
|
||||
|
@ -13664,6 +13694,16 @@ VkResult VmaBlockVector::CreateBlock(VkDeviceSize blockSize, size_t* pNewBlockIn
|
|||
}
|
||||
#endif // #if VMA_MEMORY_PRIORITY
|
||||
|
||||
#if VMA_EXTERNAL_MEMORY
|
||||
// Attach VkExportMemoryAllocateInfoKHR if necessary.
|
||||
VkExportMemoryAllocateInfoKHR exportMemoryAllocInfo = { VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO_KHR };
|
||||
exportMemoryAllocInfo.handleTypes = m_hAllocator->GetExternalMemoryHandleTypeFlags(m_MemoryTypeIndex);
|
||||
if(exportMemoryAllocInfo.handleTypes != 0)
|
||||
{
|
||||
VmaPnextChainPushFront(&allocInfo, &exportMemoryAllocInfo);
|
||||
}
|
||||
#endif // #if VMA_EXTERNAL_MEMORY
|
||||
|
||||
VkDeviceMemory mem = VK_NULL_HANDLE;
|
||||
VkResult res = m_hAllocator->AllocateVulkanMemory(&allocInfo, &mem);
|
||||
if(res < 0)
|
||||
|
@ -16108,6 +16148,9 @@ VmaAllocator_T::VmaAllocator_T(const VmaAllocatorCreateInfo* pCreateInfo) :
|
|||
memset(&m_pBlockVectors, 0, sizeof(m_pBlockVectors));
|
||||
memset(&m_VulkanFunctions, 0, sizeof(m_VulkanFunctions));
|
||||
|
||||
#if VMA_EXTERNAL_MEMORY
|
||||
memset(&m_TypeExternalMemoryHandleTypes, 0, sizeof(m_TypeExternalMemoryHandleTypes));
|
||||
#endif // #if VMA_EXTERNAL_MEMORY
|
||||
|
||||
if(pCreateInfo->pDeviceMemoryCallbacks != VMA_NULL)
|
||||
{
|
||||
|
@ -16131,6 +16174,13 @@ VmaAllocator_T::VmaAllocator_T(const VmaAllocatorCreateInfo* pCreateInfo) :
|
|||
|
||||
m_GlobalMemoryTypeBits = CalculateGlobalMemoryTypeBits();
|
||||
|
||||
#if VMA_EXTERNAL_MEMORY
|
||||
if(pCreateInfo->pTypeExternalMemoryHandleTypes != VMA_NULL)
|
||||
{
|
||||
memcpy(m_TypeExternalMemoryHandleTypes, pCreateInfo->pTypeExternalMemoryHandleTypes,
|
||||
sizeof(VkExternalMemoryHandleTypeFlagsKHR) * GetMemoryTypeCount());
|
||||
}
|
||||
#endif // #if VMA_EXTERNAL_MEMORY
|
||||
|
||||
if(pCreateInfo->pHeapSizeLimit != VMA_NULL)
|
||||
{
|
||||
|
@ -16664,6 +16714,16 @@ VkResult VmaAllocator_T::AllocateDedicatedMemory(
|
|||
}
|
||||
#endif // #if VMA_MEMORY_PRIORITY
|
||||
|
||||
#if VMA_EXTERNAL_MEMORY
|
||||
// Attach VkExportMemoryAllocateInfoKHR if necessary.
|
||||
VkExportMemoryAllocateInfoKHR exportMemoryAllocInfo = { VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO_KHR };
|
||||
exportMemoryAllocInfo.handleTypes = GetExternalMemoryHandleTypeFlags(memTypeIndex);
|
||||
if(exportMemoryAllocInfo.handleTypes != 0)
|
||||
{
|
||||
VmaPnextChainPushFront(&allocInfo, &exportMemoryAllocInfo);
|
||||
}
|
||||
#endif // #if VMA_EXTERNAL_MEMORY
|
||||
|
||||
size_t allocIndex;
|
||||
VkResult res = VK_SUCCESS;
|
||||
for(allocIndex = 0; allocIndex < allocationCount; ++allocIndex)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue