@@ -1669,6 +1669,20 @@ typedef struct VmaVirtualAllocationInfo
16691669@{
16701670*/
16711671
1672+ #ifdef VOLK_HEADER_VERSION
1673+ /** \brief Fully initializes `dst` structure with Vulkan functions needed by this library based on functions imported by
1674+ [volk library](https://github.com/zeux/volk).
1675+
1676+ If you use volk, call this function after `VkInstance` and `VkDevice` is created to fill in structure #VmaVulkanFunctions
1677+ before calling vmaCreateAllocator().
1678+
1679+ Pointers to functions related to the entire Vulkan instance are fetched using global function definitions.
1680+ Pointers to functions related to the Vulkan device are fetched using `volkLoadDeviceTable()` for given `device`.
1681+ */
1682+ VMA_CALL_PRE VkResult VMA_CALL_POST vmaImportVulkanFunctionsFromVolk(
1683+ VkDevice VMA_NOT_NULL device, VmaVulkanFunctions* VMA_NOT_NULL dst);
1684+ #endif
1685+
16721686/// Creates #VmaAllocator object.
16731687VMA_CALL_PRE VkResult VMA_CALL_POST vmaCreateAllocator(
16741688 const VmaAllocatorCreateInfo* VMA_NOT_NULL pCreateInfo,
@@ -15082,6 +15096,78 @@ void VmaAllocator_T::PrintDetailedMap(VmaJsonWriter& json)
1508215096
1508315097
1508415098#ifndef _VMA_PUBLIC_INTERFACE
15099+
15100+ #ifdef VOLK_HEADER_VERSION
15101+
15102+ VMA_CALL_PRE VkResult VMA_CALL_POST vmaImportVulkanFunctionsFromVolk(
15103+ VkDevice VMA_NOT_NULL device, VmaVulkanFunctions* VMA_NOT_NULL dst)
15104+ {
15105+ VolkDeviceTable src = {};
15106+ memset(&dst, 0, sizeof(dst));
15107+ memset(&src, 0, sizeof(src));
15108+
15109+ volkLoadDeviceTable(&src, device);
15110+
15111+ #define COPY_GLOBAL_TO_VMA_FUNC(volkName, vmaName) if(!dst->vmaName) dst->vmaName = volkName;
15112+ #define COPY_DEVICE_TO_VMA_FUNC(volkName, vmaName) if(!dst->vmaName) dst->vmaName = src.volkName;
15113+
15114+ COPY_GLOBAL_TO_VMA_FUNC(vkGetInstanceProcAddr, vkGetInstanceProcAddr)
15115+ COPY_GLOBAL_TO_VMA_FUNC(vkGetDeviceProcAddr, vkGetDeviceProcAddr)
15116+ COPY_GLOBAL_TO_VMA_FUNC(vkGetPhysicalDeviceProperties, vkGetPhysicalDeviceProperties)
15117+ COPY_GLOBAL_TO_VMA_FUNC(vkGetPhysicalDeviceMemoryProperties, vkGetPhysicalDeviceMemoryProperties)
15118+ COPY_DEVICE_TO_VMA_FUNC(vkAllocateMemory, vkAllocateMemory)
15119+ COPY_DEVICE_TO_VMA_FUNC(vkFreeMemory, vkFreeMemory)
15120+ COPY_DEVICE_TO_VMA_FUNC(vkMapMemory, vkMapMemory)
15121+ COPY_DEVICE_TO_VMA_FUNC(vkUnmapMemory, vkUnmapMemory)
15122+ COPY_DEVICE_TO_VMA_FUNC(vkFlushMappedMemoryRanges, vkFlushMappedMemoryRanges)
15123+ COPY_DEVICE_TO_VMA_FUNC(vkInvalidateMappedMemoryRanges, vkInvalidateMappedMemoryRanges)
15124+ COPY_DEVICE_TO_VMA_FUNC(vkBindBufferMemory, vkBindBufferMemory)
15125+ COPY_DEVICE_TO_VMA_FUNC(vkBindImageMemory, vkBindImageMemory)
15126+ COPY_DEVICE_TO_VMA_FUNC(vkGetBufferMemoryRequirements, vkGetBufferMemoryRequirements)
15127+ COPY_DEVICE_TO_VMA_FUNC(vkGetImageMemoryRequirements, vkGetImageMemoryRequirements)
15128+ COPY_DEVICE_TO_VMA_FUNC(vkCreateBuffer, vkCreateBuffer)
15129+ COPY_DEVICE_TO_VMA_FUNC(vkDestroyBuffer, vkDestroyBuffer)
15130+ COPY_DEVICE_TO_VMA_FUNC(vkCreateImage, vkCreateImage)
15131+ COPY_DEVICE_TO_VMA_FUNC(vkDestroyImage, vkDestroyImage)
15132+ COPY_DEVICE_TO_VMA_FUNC(vkCmdCopyBuffer, vkCmdCopyBuffer)
15133+ #if VMA_VULKAN_VERSION >= 1001000
15134+ COPY_GLOBAL_TO_VMA_FUNC(vkGetPhysicalDeviceMemoryProperties2, vkGetPhysicalDeviceMemoryProperties2KHR)
15135+ COPY_DEVICE_TO_VMA_FUNC(vkGetBufferMemoryRequirements2, vkGetBufferMemoryRequirements2KHR)
15136+ COPY_DEVICE_TO_VMA_FUNC(vkGetImageMemoryRequirements2, vkGetImageMemoryRequirements2KHR)
15137+ COPY_DEVICE_TO_VMA_FUNC(vkBindBufferMemory2, vkBindBufferMemory2KHR)
15138+ COPY_DEVICE_TO_VMA_FUNC(vkBindImageMemory2, vkBindImageMemory2KHR)
15139+ #endif
15140+ #if VMA_VULKAN_VERSION >= 1003000
15141+ COPY_DEVICE_TO_VMA_FUNC(vkGetDeviceBufferMemoryRequirements, vkGetDeviceBufferMemoryRequirements)
15142+ COPY_DEVICE_TO_VMA_FUNC(vkGetDeviceImageMemoryRequirements, vkGetDeviceImageMemoryRequirements)
15143+ #endif
15144+ #if VMA_KHR_MAINTENANCE4
15145+ COPY_DEVICE_TO_VMA_FUNC(vkGetDeviceBufferMemoryRequirementsKHR, vkGetDeviceBufferMemoryRequirements)
15146+ COPY_DEVICE_TO_VMA_FUNC(vkGetDeviceImageMemoryRequirementsKHR, vkGetDeviceImageMemoryRequirements)
15147+ #endif
15148+ #if VMA_DEDICATED_ALLOCATION
15149+ COPY_DEVICE_TO_VMA_FUNC(vkGetBufferMemoryRequirements2KHR, vkGetBufferMemoryRequirements2KHR)
15150+ COPY_DEVICE_TO_VMA_FUNC(vkGetImageMemoryRequirements2KHR, vkGetImageMemoryRequirements2KHR)
15151+ #endif
15152+ #if VMA_BIND_MEMORY2
15153+ COPY_DEVICE_TO_VMA_FUNC(vkBindBufferMemory2KHR, vkBindBufferMemory2KHR)
15154+ COPY_DEVICE_TO_VMA_FUNC(vkBindImageMemory2KHR, vkBindImageMemory2KHR)
15155+ #endif
15156+ #if VMA_MEMORY_BUDGET
15157+ COPY_GLOBAL_TO_VMA_FUNC(vkGetPhysicalDeviceMemoryProperties2KHR, vkGetPhysicalDeviceMemoryProperties2KHR)
15158+ #endif
15159+ #if VMA_EXTERNAL_MEMORY_WIN32
15160+ COPY_DEVICE_TO_VMA_FUNC(vkGetMemoryWin32HandleKHR, vkGetMemoryWin32HandleKHR)
15161+ #endif
15162+
15163+ #undef COPY_DEVICE_TO_VMA_FUNC
15164+ #undef COPY_GLOBAL_TO_VMA_FUNC
15165+
15166+ return VK_SUCCESS;
15167+ }
15168+
15169+ #endif // #ifdef VOLK_HEADER_VERSION
15170+
1508515171VMA_CALL_PRE VkResult VMA_CALL_POST vmaCreateAllocator(
1508615172 const VmaAllocatorCreateInfo* pCreateInfo,
1508715173 VmaAllocator* pAllocator)
0 commit comments