mirror of
https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git
synced 2024-11-22 23:04:35 +00:00
Vulkan 1.1 suport - prototype
This commit is contained in:
parent
4d700c5e4e
commit
10f68cb139
@ -58,6 +58,10 @@ include all public interface declarations. Example:
|
|||||||
//#define VMA_USE_STL_SHARED_MUTEX 0
|
//#define VMA_USE_STL_SHARED_MUTEX 0
|
||||||
//#define VMA_DEBUG_GLOBAL_MUTEX 1
|
//#define VMA_DEBUG_GLOBAL_MUTEX 1
|
||||||
//#define VMA_MEMORY_BUDGET 0
|
//#define VMA_MEMORY_BUDGET 0
|
||||||
|
|
||||||
|
//#define VMA_VULKAN_VERSION 1001000 // Vulkan 1.1
|
||||||
|
#define VMA_VULKAN_VERSION 1000000 // Vulkan 1.0
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#define VMA_DEBUG_LOG(format, ...) do { \
|
#define VMA_DEBUG_LOG(format, ...) do { \
|
||||||
printf(format, __VA_ARGS__); \
|
printf(format, __VA_ARGS__); \
|
||||||
|
@ -1172,7 +1172,7 @@ static void InitializeApplication()
|
|||||||
appInfo.applicationVersion = VK_MAKE_VERSION(1, 0, 0);
|
appInfo.applicationVersion = VK_MAKE_VERSION(1, 0, 0);
|
||||||
appInfo.pEngineName = "Adam Sawicki Engine";
|
appInfo.pEngineName = "Adam Sawicki Engine";
|
||||||
appInfo.engineVersion = VK_MAKE_VERSION(1, 0, 0);
|
appInfo.engineVersion = VK_MAKE_VERSION(1, 0, 0);
|
||||||
appInfo.apiVersion = VK_API_VERSION_1_0;
|
appInfo.apiVersion = VMA_VULKAN_VERSION == 1001000 ? VK_API_VERSION_1_1 : VK_API_VERSION_1_0;
|
||||||
|
|
||||||
VkInstanceCreateInfo instInfo = { VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO };
|
VkInstanceCreateInfo instInfo = { VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO };
|
||||||
instInfo.pApplicationInfo = &appInfo;
|
instInfo.pApplicationInfo = &appInfo;
|
||||||
@ -1349,6 +1349,7 @@ static void InitializeApplication()
|
|||||||
allocatorInfo.physicalDevice = g_hPhysicalDevice;
|
allocatorInfo.physicalDevice = g_hPhysicalDevice;
|
||||||
allocatorInfo.device = g_hDevice;
|
allocatorInfo.device = g_hDevice;
|
||||||
allocatorInfo.instance = g_hVulkanInstance;
|
allocatorInfo.instance = g_hVulkanInstance;
|
||||||
|
allocatorInfo.vulkanApiVersion = appInfo.apiVersion;
|
||||||
|
|
||||||
if(VK_KHR_dedicated_allocation_enabled)
|
if(VK_KHR_dedicated_allocation_enabled)
|
||||||
{
|
{
|
||||||
|
@ -1777,6 +1777,17 @@ available through VmaAllocatorCreateInfo::pRecordSettings.
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Define this macro to declare maximum supported Vulkan version in format AAABBBCCC,
|
||||||
|
// where AAA = major, BBB = minor, CCC = patch.
|
||||||
|
// If you want to use version > 1.0, it still needs to be enabled via VmaAllocatorCreateInfo::vulkanApiVersion.
|
||||||
|
#if !defined(VMA_VULKAN_VERSION)
|
||||||
|
#if defined(VK_VERSION_1_1)
|
||||||
|
#define VMA_VULKAN_VERSION 1001000
|
||||||
|
#else
|
||||||
|
#define VMA_VULKAN_VERSION 1000000
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(VMA_DEDICATED_ALLOCATION)
|
#if !defined(VMA_DEDICATED_ALLOCATION)
|
||||||
#if VK_KHR_get_memory_requirements2 && VK_KHR_dedicated_allocation
|
#if VK_KHR_get_memory_requirements2 && VK_KHR_dedicated_allocation
|
||||||
#define VMA_DEDICATED_ALLOCATION 1
|
#define VMA_DEDICATED_ALLOCATION 1
|
||||||
@ -1794,7 +1805,7 @@ available through VmaAllocatorCreateInfo::pRecordSettings.
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(VMA_MEMORY_BUDGET)
|
#if !defined(VMA_MEMORY_BUDGET)
|
||||||
#if VK_EXT_memory_budget && VK_KHR_get_physical_device_properties2
|
#if VK_EXT_memory_budget && (VK_KHR_get_physical_device_properties2 || VMA_VULKAN_VERSION >= 1001000)
|
||||||
#define VMA_MEMORY_BUDGET 1
|
#define VMA_MEMORY_BUDGET 1
|
||||||
#else
|
#else
|
||||||
#define VMA_MEMORY_BUDGET 0
|
#define VMA_MEMORY_BUDGET 0
|
||||||
@ -1860,6 +1871,9 @@ typedef enum VmaAllocatorCreateFlagBits {
|
|||||||
VMA_ALLOCATOR_CREATE_EXTERNALLY_SYNCHRONIZED_BIT = 0x00000001,
|
VMA_ALLOCATOR_CREATE_EXTERNALLY_SYNCHRONIZED_BIT = 0x00000001,
|
||||||
/** \brief Enables usage of VK_KHR_dedicated_allocation extension.
|
/** \brief Enables usage of VK_KHR_dedicated_allocation extension.
|
||||||
|
|
||||||
|
The flag works only if VmaAllocatorCreateInfo::vulkanApiVersion `== VK_API_VERSION_1_0`.
|
||||||
|
When it's `VK_API_VERSION_1_1`, the flag is ignored because the extension has been promoted to Vulkan 1.1.
|
||||||
|
|
||||||
Using this extenion will automatically allocate dedicated blocks of memory for
|
Using this extenion will automatically allocate dedicated blocks of memory for
|
||||||
some buffers and images instead of suballocating place for them out of bigger
|
some buffers and images instead of suballocating place for them out of bigger
|
||||||
memory blocks (as if you explicitly used #VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT
|
memory blocks (as if you explicitly used #VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT
|
||||||
@ -1883,6 +1897,9 @@ typedef enum VmaAllocatorCreateFlagBits {
|
|||||||
/**
|
/**
|
||||||
Enables usage of VK_KHR_bind_memory2 extension.
|
Enables usage of VK_KHR_bind_memory2 extension.
|
||||||
|
|
||||||
|
The flag works only if VmaAllocatorCreateInfo::vulkanApiVersion `== VK_API_VERSION_1_0`.
|
||||||
|
When it's `VK_API_VERSION_1_1`, the flag is ignored because the extension has been promoted to Vulkan 1.1.
|
||||||
|
|
||||||
You may set this flag only if you found out that this device extension is supported,
|
You may set this flag only if you found out that this device extension is supported,
|
||||||
you enabled it while creating Vulkan device passed as VmaAllocatorCreateInfo::device,
|
you enabled it while creating Vulkan device passed as VmaAllocatorCreateInfo::device,
|
||||||
and you want it to be used internally by this library.
|
and you want it to be used internally by this library.
|
||||||
@ -1898,7 +1915,7 @@ typedef enum VmaAllocatorCreateFlagBits {
|
|||||||
You may set this flag only if you found out that this device extension is supported,
|
You may set this flag only if you found out that this device extension is supported,
|
||||||
you enabled it while creating Vulkan device passed as VmaAllocatorCreateInfo::device,
|
you enabled it while creating Vulkan device passed as VmaAllocatorCreateInfo::device,
|
||||||
and you want it to be used internally by this library, along with another instance extension
|
and you want it to be used internally by this library, along with another instance extension
|
||||||
VK_KHR_get_physical_device_properties2, which is required by it.
|
VK_KHR_get_physical_device_properties2, which is required by it (or Vulkan 1.1, where this extension is promoted).
|
||||||
|
|
||||||
The extension provides query for current memory usage and budget, which will probably
|
The extension provides query for current memory usage and budget, which will probably
|
||||||
be more accurate than an estimation used by the library otherwise.
|
be more accurate than an estimation used by the library otherwise.
|
||||||
@ -1931,15 +1948,15 @@ typedef struct VmaVulkanFunctions {
|
|||||||
PFN_vkCreateImage vkCreateImage;
|
PFN_vkCreateImage vkCreateImage;
|
||||||
PFN_vkDestroyImage vkDestroyImage;
|
PFN_vkDestroyImage vkDestroyImage;
|
||||||
PFN_vkCmdCopyBuffer vkCmdCopyBuffer;
|
PFN_vkCmdCopyBuffer vkCmdCopyBuffer;
|
||||||
#if VMA_DEDICATED_ALLOCATION
|
#if VMA_DEDICATED_ALLOCATION || VMA_VULKAN_VERSION >= 1001000
|
||||||
PFN_vkGetBufferMemoryRequirements2KHR vkGetBufferMemoryRequirements2KHR;
|
PFN_vkGetBufferMemoryRequirements2KHR vkGetBufferMemoryRequirements2KHR;
|
||||||
PFN_vkGetImageMemoryRequirements2KHR vkGetImageMemoryRequirements2KHR;
|
PFN_vkGetImageMemoryRequirements2KHR vkGetImageMemoryRequirements2KHR;
|
||||||
#endif
|
#endif
|
||||||
#if VMA_BIND_MEMORY2
|
#if VMA_BIND_MEMORY2 || VMA_VULKAN_VERSION >= 1001000
|
||||||
PFN_vkBindBufferMemory2KHR vkBindBufferMemory2KHR;
|
PFN_vkBindBufferMemory2KHR vkBindBufferMemory2KHR;
|
||||||
PFN_vkBindImageMemory2KHR vkBindImageMemory2KHR;
|
PFN_vkBindImageMemory2KHR vkBindImageMemory2KHR;
|
||||||
#endif
|
#endif
|
||||||
#if VMA_MEMORY_BUDGET
|
#if VMA_MEMORY_BUDGET || VMA_VULKAN_VERSION >= 1001000
|
||||||
PFN_vkGetPhysicalDeviceMemoryProperties2KHR vkGetPhysicalDeviceMemoryProperties2KHR;
|
PFN_vkGetPhysicalDeviceMemoryProperties2KHR vkGetPhysicalDeviceMemoryProperties2KHR;
|
||||||
#endif
|
#endif
|
||||||
} VmaVulkanFunctions;
|
} VmaVulkanFunctions;
|
||||||
@ -2052,9 +2069,19 @@ typedef struct VmaAllocatorCreateInfo
|
|||||||
const VmaRecordSettings* pRecordSettings;
|
const VmaRecordSettings* pRecordSettings;
|
||||||
/** \brief Optional handle to Vulkan instance object.
|
/** \brief Optional handle to Vulkan instance object.
|
||||||
|
|
||||||
Optional, can be null. Must be set if #VMA_ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT flas is used.
|
Optional, can be null. Must be set if #VMA_ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT flas is used
|
||||||
|
or if `vulkanApiVersion >= VK_MAKE_VERSION(1, 1, 0)`.
|
||||||
*/
|
*/
|
||||||
VkInstance instance;
|
VkInstance instance;
|
||||||
|
/** \brief Optional. The highest version of Vulkan that the application is designed to use.
|
||||||
|
|
||||||
|
It must be a value in the format as created by macro `VK_MAKE_VERSION` or a constant like: `VK_API_VERSION_1_1`, `VK_API_VERSION_1_0`.
|
||||||
|
The patch version number specified is ignored. Only the major and minor versions are considered.
|
||||||
|
It must be less or euqal (preferably equal) to value as passed to `vkCreateInstance` as `VkApplicationInfo::apiVersion`.
|
||||||
|
Only versions 1.0 and 1.1 are supported by the current implementation.
|
||||||
|
Leaving it initialized to zero is equivalent to `VK_API_VERSION_1_0`.
|
||||||
|
*/
|
||||||
|
uint32_t vulkanApiVersion;
|
||||||
} VmaAllocatorCreateInfo;
|
} VmaAllocatorCreateInfo;
|
||||||
|
|
||||||
/// Creates Allocator object.
|
/// Creates Allocator object.
|
||||||
@ -3293,8 +3320,8 @@ VMA_CALL_PRE VkResult VMA_CALL_POST vmaBindBufferMemory(
|
|||||||
|
|
||||||
This function is similar to vmaBindBufferMemory(), but it provides additional parameters.
|
This function is similar to vmaBindBufferMemory(), but it provides additional parameters.
|
||||||
|
|
||||||
If `pNext` is not null, #VmaAllocator object must have been created with #VMA_ALLOCATOR_CREATE_KHR_BIND_MEMORY2_BIT flag.
|
If `pNext` is not null, #VmaAllocator object must have been created with #VMA_ALLOCATOR_CREATE_KHR_BIND_MEMORY2_BIT flag
|
||||||
Otherwise the call fails.
|
or with VmaAllocatorCreateInfo::vulkanApiVersion `== VK_API_VERSION_1_1`. Otherwise the call fails.
|
||||||
*/
|
*/
|
||||||
VMA_CALL_PRE VkResult VMA_CALL_POST vmaBindBufferMemory2(
|
VMA_CALL_PRE VkResult VMA_CALL_POST vmaBindBufferMemory2(
|
||||||
VmaAllocator allocator,
|
VmaAllocator allocator,
|
||||||
@ -3327,8 +3354,8 @@ VMA_CALL_PRE VkResult VMA_CALL_POST vmaBindImageMemory(
|
|||||||
|
|
||||||
This function is similar to vmaBindImageMemory(), but it provides additional parameters.
|
This function is similar to vmaBindImageMemory(), but it provides additional parameters.
|
||||||
|
|
||||||
If `pNext` is not null, #VmaAllocator object must have been created with #VMA_ALLOCATOR_CREATE_KHR_BIND_MEMORY2_BIT flag.
|
If `pNext` is not null, #VmaAllocator object must have been created with #VMA_ALLOCATOR_CREATE_KHR_BIND_MEMORY2_BIT flag
|
||||||
Otherwise the call fails.
|
or with VmaAllocatorCreateInfo::vulkanApiVersion `== VK_API_VERSION_1_1`. Otherwise the call fails.
|
||||||
*/
|
*/
|
||||||
VMA_CALL_PRE VkResult VMA_CALL_POST vmaBindImageMemory2(
|
VMA_CALL_PRE VkResult VMA_CALL_POST vmaBindImageMemory2(
|
||||||
VmaAllocator allocator,
|
VmaAllocator allocator,
|
||||||
@ -7015,8 +7042,9 @@ struct VmaAllocator_T
|
|||||||
VMA_CLASS_NO_COPY(VmaAllocator_T)
|
VMA_CLASS_NO_COPY(VmaAllocator_T)
|
||||||
public:
|
public:
|
||||||
bool m_UseMutex;
|
bool m_UseMutex;
|
||||||
bool m_UseKhrDedicatedAllocation;
|
uint32_t m_VulkanApiVersion;
|
||||||
bool m_UseKhrBindMemory2;
|
bool m_UseKhrDedicatedAllocation; // Can be set only if m_VulkanApiVersion < VK_MAKE_VERSION(1, 1, 0).
|
||||||
|
bool m_UseKhrBindMemory2; // Can be set only if m_VulkanApiVersion < VK_MAKE_VERSION(1, 1, 0).
|
||||||
bool m_UseExtMemoryBudget;
|
bool m_UseExtMemoryBudget;
|
||||||
VkDevice m_hDevice;
|
VkDevice m_hDevice;
|
||||||
VkInstance m_hInstance;
|
VkInstance m_hInstance;
|
||||||
@ -14495,6 +14523,7 @@ void VmaAllocationObjectAllocator::Free(VmaAllocation hAlloc)
|
|||||||
|
|
||||||
VmaAllocator_T::VmaAllocator_T(const VmaAllocatorCreateInfo* pCreateInfo) :
|
VmaAllocator_T::VmaAllocator_T(const VmaAllocatorCreateInfo* pCreateInfo) :
|
||||||
m_UseMutex((pCreateInfo->flags & VMA_ALLOCATOR_CREATE_EXTERNALLY_SYNCHRONIZED_BIT) == 0),
|
m_UseMutex((pCreateInfo->flags & VMA_ALLOCATOR_CREATE_EXTERNALLY_SYNCHRONIZED_BIT) == 0),
|
||||||
|
m_VulkanApiVersion(pCreateInfo->vulkanApiVersion != 0 ? pCreateInfo->vulkanApiVersion : VK_API_VERSION_1_0),
|
||||||
m_UseKhrDedicatedAllocation((pCreateInfo->flags & VMA_ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT) != 0),
|
m_UseKhrDedicatedAllocation((pCreateInfo->flags & VMA_ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT) != 0),
|
||||||
m_UseKhrBindMemory2((pCreateInfo->flags & VMA_ALLOCATOR_CREATE_KHR_BIND_MEMORY2_BIT) != 0),
|
m_UseKhrBindMemory2((pCreateInfo->flags & VMA_ALLOCATOR_CREATE_KHR_BIND_MEMORY2_BIT) != 0),
|
||||||
m_UseExtMemoryBudget((pCreateInfo->flags & VMA_ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT) != 0),
|
m_UseExtMemoryBudget((pCreateInfo->flags & VMA_ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT) != 0),
|
||||||
@ -14515,6 +14544,12 @@ VmaAllocator_T::VmaAllocator_T(const VmaAllocatorCreateInfo* pCreateInfo) :
|
|||||||
,m_pRecorder(VMA_NULL)
|
,m_pRecorder(VMA_NULL)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
if(m_VulkanApiVersion >= VK_MAKE_VERSION(1, 1, 0))
|
||||||
|
{
|
||||||
|
m_UseKhrDedicatedAllocation = false;
|
||||||
|
m_UseKhrBindMemory2 = false;
|
||||||
|
}
|
||||||
|
|
||||||
if(VMA_DEBUG_DETECT_CORRUPTION)
|
if(VMA_DEBUG_DETECT_CORRUPTION)
|
||||||
{
|
{
|
||||||
// Needs to be multiply of uint32_t size because we are going to write VMA_CORRUPTION_DETECTION_MAGIC_VALUE to it.
|
// Needs to be multiply of uint32_t size because we are going to write VMA_CORRUPTION_DETECTION_MAGIC_VALUE to it.
|
||||||
@ -14523,24 +14558,33 @@ VmaAllocator_T::VmaAllocator_T(const VmaAllocatorCreateInfo* pCreateInfo) :
|
|||||||
|
|
||||||
VMA_ASSERT(pCreateInfo->physicalDevice && pCreateInfo->device);
|
VMA_ASSERT(pCreateInfo->physicalDevice && pCreateInfo->device);
|
||||||
|
|
||||||
#if !(VMA_DEDICATED_ALLOCATION)
|
if(m_VulkanApiVersion < VK_MAKE_VERSION(1, 1, 0))
|
||||||
if((pCreateInfo->flags & VMA_ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT) != 0)
|
|
||||||
{
|
{
|
||||||
VMA_ASSERT(0 && "VMA_ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT set but required extensions are disabled by preprocessor macros.");
|
#if !(VMA_DEDICATED_ALLOCATION)
|
||||||
}
|
if((pCreateInfo->flags & VMA_ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT) != 0)
|
||||||
|
{
|
||||||
|
VMA_ASSERT(0 && "VMA_ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT set but required extensions are disabled by preprocessor macros.");
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#if !(VMA_BIND_MEMORY2)
|
#if !(VMA_BIND_MEMORY2)
|
||||||
if((pCreateInfo->flags & VMA_ALLOCATOR_CREATE_KHR_BIND_MEMORY2_BIT) != 0)
|
if((pCreateInfo->flags & VMA_ALLOCATOR_CREATE_KHR_BIND_MEMORY2_BIT) != 0)
|
||||||
{
|
{
|
||||||
VMA_ASSERT(0 && "VMA_ALLOCATOR_CREATE_KHR_BIND_MEMORY2_BIT set but required extension is disabled by preprocessor macros.");
|
VMA_ASSERT(0 && "VMA_ALLOCATOR_CREATE_KHR_BIND_MEMORY2_BIT set but required extension is disabled by preprocessor macros.");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
#if !(VMA_MEMORY_BUDGET)
|
#if !(VMA_MEMORY_BUDGET)
|
||||||
if((pCreateInfo->flags & VMA_ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT) != 0)
|
if((pCreateInfo->flags & VMA_ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT) != 0)
|
||||||
{
|
{
|
||||||
VMA_ASSERT(0 && "VMA_ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT set but required extension is disabled by preprocessor macros.");
|
VMA_ASSERT(0 && "VMA_ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT set but required extension is disabled by preprocessor macros.");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#if VMA_VULKAN_VERSION < 1001000
|
||||||
|
if(m_VulkanApiVersion >= VK_MAKE_VERSION(1, 1, 0))
|
||||||
|
{
|
||||||
|
VMA_ASSERT(0 && "vulkanApiVersion >= VK_API_VERSION_1_1 but required Vulkan version is disabled by preprocessor macros.");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
memset(&m_DeviceMemoryCallbacks, 0 ,sizeof(m_DeviceMemoryCallbacks));
|
memset(&m_DeviceMemoryCallbacks, 0 ,sizeof(m_DeviceMemoryCallbacks));
|
||||||
memset(&m_PhysicalDeviceProperties, 0, sizeof(m_PhysicalDeviceProperties));
|
memset(&m_PhysicalDeviceProperties, 0, sizeof(m_PhysicalDeviceProperties));
|
||||||
@ -14688,6 +14732,22 @@ void VmaAllocator_T::ImportVulkanFunctions(const VmaVulkanFunctions* pVulkanFunc
|
|||||||
m_VulkanFunctions.vkCreateImage = (PFN_vkCreateImage)vkCreateImage;
|
m_VulkanFunctions.vkCreateImage = (PFN_vkCreateImage)vkCreateImage;
|
||||||
m_VulkanFunctions.vkDestroyImage = (PFN_vkDestroyImage)vkDestroyImage;
|
m_VulkanFunctions.vkDestroyImage = (PFN_vkDestroyImage)vkDestroyImage;
|
||||||
m_VulkanFunctions.vkCmdCopyBuffer = (PFN_vkCmdCopyBuffer)vkCmdCopyBuffer;
|
m_VulkanFunctions.vkCmdCopyBuffer = (PFN_vkCmdCopyBuffer)vkCmdCopyBuffer;
|
||||||
|
#if VMA_VULKAN_VERSION >= 1001000
|
||||||
|
if(m_VulkanApiVersion >= VK_MAKE_VERSION(1, 1, 0))
|
||||||
|
{
|
||||||
|
VMA_ASSERT(m_hInstance != VK_NULL_HANDLE);
|
||||||
|
m_VulkanFunctions.vkGetBufferMemoryRequirements2KHR =
|
||||||
|
(PFN_vkGetBufferMemoryRequirements2KHR)vkGetDeviceProcAddr(m_hDevice, "vkGetBufferMemoryRequirements2");
|
||||||
|
m_VulkanFunctions.vkGetImageMemoryRequirements2KHR =
|
||||||
|
(PFN_vkGetImageMemoryRequirements2KHR)vkGetDeviceProcAddr(m_hDevice, "vkGetImageMemoryRequirements2");
|
||||||
|
m_VulkanFunctions.vkBindBufferMemory2KHR =
|
||||||
|
(PFN_vkBindBufferMemory2KHR)vkGetDeviceProcAddr(m_hDevice, "vkBindBufferMemory2");
|
||||||
|
m_VulkanFunctions.vkBindImageMemory2KHR =
|
||||||
|
(PFN_vkBindImageMemory2KHR)vkGetDeviceProcAddr(m_hDevice, "vkBindImageMemory2");
|
||||||
|
m_VulkanFunctions.vkGetPhysicalDeviceMemoryProperties2KHR =
|
||||||
|
(PFN_vkGetPhysicalDeviceMemoryProperties2KHR)vkGetInstanceProcAddr(m_hInstance, "vkGetPhysicalDeviceMemoryProperties2");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#if VMA_DEDICATED_ALLOCATION
|
#if VMA_DEDICATED_ALLOCATION
|
||||||
if(m_UseKhrDedicatedAllocation)
|
if(m_UseKhrDedicatedAllocation)
|
||||||
{
|
{
|
||||||
@ -14696,7 +14756,7 @@ void VmaAllocator_T::ImportVulkanFunctions(const VmaVulkanFunctions* pVulkanFunc
|
|||||||
m_VulkanFunctions.vkGetImageMemoryRequirements2KHR =
|
m_VulkanFunctions.vkGetImageMemoryRequirements2KHR =
|
||||||
(PFN_vkGetImageMemoryRequirements2KHR)vkGetDeviceProcAddr(m_hDevice, "vkGetImageMemoryRequirements2KHR");
|
(PFN_vkGetImageMemoryRequirements2KHR)vkGetDeviceProcAddr(m_hDevice, "vkGetImageMemoryRequirements2KHR");
|
||||||
}
|
}
|
||||||
#endif // #if VMA_DEDICATED_ALLOCATION
|
#endif
|
||||||
#if VMA_BIND_MEMORY2
|
#if VMA_BIND_MEMORY2
|
||||||
if(m_UseKhrBindMemory2)
|
if(m_UseKhrBindMemory2)
|
||||||
{
|
{
|
||||||
@ -14707,7 +14767,7 @@ void VmaAllocator_T::ImportVulkanFunctions(const VmaVulkanFunctions* pVulkanFunc
|
|||||||
}
|
}
|
||||||
#endif // #if VMA_BIND_MEMORY2
|
#endif // #if VMA_BIND_MEMORY2
|
||||||
#if VMA_MEMORY_BUDGET
|
#if VMA_MEMORY_BUDGET
|
||||||
if(m_UseExtMemoryBudget)
|
if(m_UseExtMemoryBudget && m_VulkanApiVersion < VK_MAKE_VERSION(1, 1, 0))
|
||||||
{
|
{
|
||||||
VMA_ASSERT(m_hInstance != VK_NULL_HANDLE);
|
VMA_ASSERT(m_hInstance != VK_NULL_HANDLE);
|
||||||
m_VulkanFunctions.vkGetPhysicalDeviceMemoryProperties2KHR =
|
m_VulkanFunctions.vkGetPhysicalDeviceMemoryProperties2KHR =
|
||||||
@ -14738,11 +14798,11 @@ void VmaAllocator_T::ImportVulkanFunctions(const VmaVulkanFunctions* pVulkanFunc
|
|||||||
VMA_COPY_IF_NOT_NULL(vkCreateImage);
|
VMA_COPY_IF_NOT_NULL(vkCreateImage);
|
||||||
VMA_COPY_IF_NOT_NULL(vkDestroyImage);
|
VMA_COPY_IF_NOT_NULL(vkDestroyImage);
|
||||||
VMA_COPY_IF_NOT_NULL(vkCmdCopyBuffer);
|
VMA_COPY_IF_NOT_NULL(vkCmdCopyBuffer);
|
||||||
#if VMA_DEDICATED_ALLOCATION
|
#if VMA_DEDICATED_ALLOCATION || VMA_VULKAN_VERSION >= 1001000
|
||||||
VMA_COPY_IF_NOT_NULL(vkGetBufferMemoryRequirements2KHR);
|
VMA_COPY_IF_NOT_NULL(vkGetBufferMemoryRequirements2KHR);
|
||||||
VMA_COPY_IF_NOT_NULL(vkGetImageMemoryRequirements2KHR);
|
VMA_COPY_IF_NOT_NULL(vkGetImageMemoryRequirements2KHR);
|
||||||
#endif
|
#endif
|
||||||
#if VMA_BIND_MEMORY2
|
#if VMA_BIND_MEMORY2 || VMA_VULKAN_VERSION >= 1001000
|
||||||
VMA_COPY_IF_NOT_NULL(vkBindBufferMemory2KHR);
|
VMA_COPY_IF_NOT_NULL(vkBindBufferMemory2KHR);
|
||||||
VMA_COPY_IF_NOT_NULL(vkBindImageMemory2KHR);
|
VMA_COPY_IF_NOT_NULL(vkBindImageMemory2KHR);
|
||||||
#endif
|
#endif
|
||||||
@ -14772,22 +14832,22 @@ void VmaAllocator_T::ImportVulkanFunctions(const VmaVulkanFunctions* pVulkanFunc
|
|||||||
VMA_ASSERT(m_VulkanFunctions.vkCreateImage != VMA_NULL);
|
VMA_ASSERT(m_VulkanFunctions.vkCreateImage != VMA_NULL);
|
||||||
VMA_ASSERT(m_VulkanFunctions.vkDestroyImage != VMA_NULL);
|
VMA_ASSERT(m_VulkanFunctions.vkDestroyImage != VMA_NULL);
|
||||||
VMA_ASSERT(m_VulkanFunctions.vkCmdCopyBuffer != VMA_NULL);
|
VMA_ASSERT(m_VulkanFunctions.vkCmdCopyBuffer != VMA_NULL);
|
||||||
#if VMA_DEDICATED_ALLOCATION
|
#if VMA_DEDICATED_ALLOCATION || VMA_VULKAN_VERSION >= 1001000
|
||||||
if(m_UseKhrDedicatedAllocation)
|
if(m_VulkanApiVersion >= VK_MAKE_VERSION(1, 1, 0) || m_UseKhrDedicatedAllocation)
|
||||||
{
|
{
|
||||||
VMA_ASSERT(m_VulkanFunctions.vkGetBufferMemoryRequirements2KHR != VMA_NULL);
|
VMA_ASSERT(m_VulkanFunctions.vkGetBufferMemoryRequirements2KHR != VMA_NULL);
|
||||||
VMA_ASSERT(m_VulkanFunctions.vkGetImageMemoryRequirements2KHR != VMA_NULL);
|
VMA_ASSERT(m_VulkanFunctions.vkGetImageMemoryRequirements2KHR != VMA_NULL);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if VMA_BIND_MEMORY2
|
#if VMA_BIND_MEMORY2 || VMA_VULKAN_VERSION >= 1001000
|
||||||
if(m_UseKhrBindMemory2)
|
if(m_VulkanApiVersion >= VK_MAKE_VERSION(1, 1, 0) || m_UseKhrBindMemory2)
|
||||||
{
|
{
|
||||||
VMA_ASSERT(m_VulkanFunctions.vkBindBufferMemory2KHR != VMA_NULL);
|
VMA_ASSERT(m_VulkanFunctions.vkBindBufferMemory2KHR != VMA_NULL);
|
||||||
VMA_ASSERT(m_VulkanFunctions.vkBindImageMemory2KHR != VMA_NULL);
|
VMA_ASSERT(m_VulkanFunctions.vkBindImageMemory2KHR != VMA_NULL);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if VMA_MEMORY_BUDGET
|
#if VMA_MEMORY_BUDGET || VMA_VULKAN_VERSION >= 1001000
|
||||||
if(m_UseExtMemoryBudget)
|
if(m_UseExtMemoryBudget || m_VulkanApiVersion >= VK_MAKE_VERSION(1, 1, 0))
|
||||||
{
|
{
|
||||||
VMA_ASSERT(m_VulkanFunctions.vkGetPhysicalDeviceMemoryProperties2KHR != VMA_NULL);
|
VMA_ASSERT(m_VulkanFunctions.vkGetPhysicalDeviceMemoryProperties2KHR != VMA_NULL);
|
||||||
}
|
}
|
||||||
@ -14950,9 +15010,9 @@ VkResult VmaAllocator_T::AllocateDedicatedMemory(
|
|||||||
allocInfo.memoryTypeIndex = memTypeIndex;
|
allocInfo.memoryTypeIndex = memTypeIndex;
|
||||||
allocInfo.allocationSize = size;
|
allocInfo.allocationSize = size;
|
||||||
|
|
||||||
#if VMA_DEDICATED_ALLOCATION
|
#if VMA_DEDICATED_ALLOCATION || VMA_VULKAN_VERSION >= 1001000
|
||||||
VkMemoryDedicatedAllocateInfoKHR dedicatedAllocInfo = { VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO_KHR };
|
VkMemoryDedicatedAllocateInfoKHR dedicatedAllocInfo = { VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO_KHR };
|
||||||
if(m_UseKhrDedicatedAllocation)
|
if(m_UseKhrDedicatedAllocation || m_VulkanApiVersion >= VK_MAKE_VERSION(1, 1, 0))
|
||||||
{
|
{
|
||||||
if(dedicatedBuffer != VK_NULL_HANDLE)
|
if(dedicatedBuffer != VK_NULL_HANDLE)
|
||||||
{
|
{
|
||||||
@ -14966,7 +15026,7 @@ VkResult VmaAllocator_T::AllocateDedicatedMemory(
|
|||||||
allocInfo.pNext = &dedicatedAllocInfo;
|
allocInfo.pNext = &dedicatedAllocInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // #if VMA_DEDICATED_ALLOCATION
|
#endif // #if VMA_DEDICATED_ALLOCATION || VMA_VULKAN_VERSION >= 1001000
|
||||||
|
|
||||||
size_t allocIndex;
|
size_t allocIndex;
|
||||||
VkResult res = VK_SUCCESS;
|
VkResult res = VK_SUCCESS;
|
||||||
@ -15088,8 +15148,8 @@ void VmaAllocator_T::GetBufferMemoryRequirements(
|
|||||||
bool& requiresDedicatedAllocation,
|
bool& requiresDedicatedAllocation,
|
||||||
bool& prefersDedicatedAllocation) const
|
bool& prefersDedicatedAllocation) const
|
||||||
{
|
{
|
||||||
#if VMA_DEDICATED_ALLOCATION
|
#if VMA_DEDICATED_ALLOCATION || VMA_VULKAN_VERSION >= 1001000
|
||||||
if(m_UseKhrDedicatedAllocation)
|
if(m_UseKhrDedicatedAllocation || m_VulkanApiVersion >= VK_MAKE_VERSION(1, 1, 0))
|
||||||
{
|
{
|
||||||
VkBufferMemoryRequirementsInfo2KHR memReqInfo = { VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2_KHR };
|
VkBufferMemoryRequirementsInfo2KHR memReqInfo = { VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2_KHR };
|
||||||
memReqInfo.buffer = hBuffer;
|
memReqInfo.buffer = hBuffer;
|
||||||
@ -15106,7 +15166,7 @@ void VmaAllocator_T::GetBufferMemoryRequirements(
|
|||||||
prefersDedicatedAllocation = (memDedicatedReq.prefersDedicatedAllocation != VK_FALSE);
|
prefersDedicatedAllocation = (memDedicatedReq.prefersDedicatedAllocation != VK_FALSE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif // #if VMA_DEDICATED_ALLOCATION
|
#endif // #if VMA_DEDICATED_ALLOCATION || VMA_VULKAN_VERSION >= 1001000
|
||||||
{
|
{
|
||||||
(*m_VulkanFunctions.vkGetBufferMemoryRequirements)(m_hDevice, hBuffer, &memReq);
|
(*m_VulkanFunctions.vkGetBufferMemoryRequirements)(m_hDevice, hBuffer, &memReq);
|
||||||
requiresDedicatedAllocation = false;
|
requiresDedicatedAllocation = false;
|
||||||
@ -15120,8 +15180,8 @@ void VmaAllocator_T::GetImageMemoryRequirements(
|
|||||||
bool& requiresDedicatedAllocation,
|
bool& requiresDedicatedAllocation,
|
||||||
bool& prefersDedicatedAllocation) const
|
bool& prefersDedicatedAllocation) const
|
||||||
{
|
{
|
||||||
#if VMA_DEDICATED_ALLOCATION
|
#if VMA_DEDICATED_ALLOCATION || VMA_VULKAN_VERSION >= 1001000
|
||||||
if(m_UseKhrDedicatedAllocation)
|
if(m_UseKhrDedicatedAllocation || m_VulkanApiVersion >= VK_MAKE_VERSION(1, 1, 0))
|
||||||
{
|
{
|
||||||
VkImageMemoryRequirementsInfo2KHR memReqInfo = { VK_STRUCTURE_TYPE_IMAGE_MEMORY_REQUIREMENTS_INFO_2_KHR };
|
VkImageMemoryRequirementsInfo2KHR memReqInfo = { VK_STRUCTURE_TYPE_IMAGE_MEMORY_REQUIREMENTS_INFO_2_KHR };
|
||||||
memReqInfo.image = hImage;
|
memReqInfo.image = hImage;
|
||||||
@ -15138,7 +15198,7 @@ void VmaAllocator_T::GetImageMemoryRequirements(
|
|||||||
prefersDedicatedAllocation = (memDedicatedReq.prefersDedicatedAllocation != VK_FALSE);
|
prefersDedicatedAllocation = (memDedicatedReq.prefersDedicatedAllocation != VK_FALSE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif // #if VMA_DEDICATED_ALLOCATION
|
#endif // #if VMA_DEDICATED_ALLOCATION || VMA_VULKAN_VERSION >= 1001000
|
||||||
{
|
{
|
||||||
(*m_VulkanFunctions.vkGetImageMemoryRequirements)(m_hDevice, hImage, &memReq);
|
(*m_VulkanFunctions.vkGetImageMemoryRequirements)(m_hDevice, hImage, &memReq);
|
||||||
requiresDedicatedAllocation = false;
|
requiresDedicatedAllocation = false;
|
||||||
@ -15842,8 +15902,9 @@ VkResult VmaAllocator_T::BindVulkanBuffer(
|
|||||||
{
|
{
|
||||||
if(pNext != VMA_NULL)
|
if(pNext != VMA_NULL)
|
||||||
{
|
{
|
||||||
#if VMA_BIND_MEMORY2
|
#if VMA_VULKAN_VERSION >= 1001000 || VMA_BIND_MEMORY2
|
||||||
if(m_UseKhrBindMemory2 && m_VulkanFunctions.vkBindBufferMemory2KHR != VMA_NULL)
|
if((m_UseKhrBindMemory2 || m_VulkanApiVersion >= VK_MAKE_VERSION(1, 1, 0)) &&
|
||||||
|
m_VulkanFunctions.vkBindBufferMemory2KHR != VMA_NULL)
|
||||||
{
|
{
|
||||||
VkBindBufferMemoryInfoKHR bindBufferMemoryInfo = { VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_INFO_KHR };
|
VkBindBufferMemoryInfoKHR bindBufferMemoryInfo = { VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_INFO_KHR };
|
||||||
bindBufferMemoryInfo.pNext = pNext;
|
bindBufferMemoryInfo.pNext = pNext;
|
||||||
@ -15853,7 +15914,7 @@ VkResult VmaAllocator_T::BindVulkanBuffer(
|
|||||||
return (*m_VulkanFunctions.vkBindBufferMemory2KHR)(m_hDevice, 1, &bindBufferMemoryInfo);
|
return (*m_VulkanFunctions.vkBindBufferMemory2KHR)(m_hDevice, 1, &bindBufferMemoryInfo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif // #if VMA_BIND_MEMORY2
|
#endif // #if VMA_VULKAN_VERSION >= 1001000 || VMA_BIND_MEMORY2
|
||||||
{
|
{
|
||||||
return VK_ERROR_EXTENSION_NOT_PRESENT;
|
return VK_ERROR_EXTENSION_NOT_PRESENT;
|
||||||
}
|
}
|
||||||
@ -15872,8 +15933,9 @@ VkResult VmaAllocator_T::BindVulkanImage(
|
|||||||
{
|
{
|
||||||
if(pNext != VMA_NULL)
|
if(pNext != VMA_NULL)
|
||||||
{
|
{
|
||||||
#if VMA_BIND_MEMORY2
|
#if VMA_VULKAN_VERSION >= 1001000 || VMA_BIND_MEMORY2
|
||||||
if(m_UseKhrBindMemory2 && m_VulkanFunctions.vkBindImageMemory2KHR != VMA_NULL)
|
if((m_UseKhrBindMemory2 || m_VulkanApiVersion >= VK_MAKE_VERSION(1, 1, 0)) &&
|
||||||
|
m_VulkanFunctions.vkBindImageMemory2KHR != VMA_NULL)
|
||||||
{
|
{
|
||||||
VkBindImageMemoryInfoKHR bindBufferMemoryInfo = { VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO_KHR };
|
VkBindImageMemoryInfoKHR bindBufferMemoryInfo = { VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO_KHR };
|
||||||
bindBufferMemoryInfo.pNext = pNext;
|
bindBufferMemoryInfo.pNext = pNext;
|
||||||
@ -16281,6 +16343,8 @@ VMA_CALL_PRE VkResult VMA_CALL_POST vmaCreateAllocator(
|
|||||||
VmaAllocator* pAllocator)
|
VmaAllocator* pAllocator)
|
||||||
{
|
{
|
||||||
VMA_ASSERT(pCreateInfo && pAllocator);
|
VMA_ASSERT(pCreateInfo && pAllocator);
|
||||||
|
VMA_ASSERT(pCreateInfo->vulkanApiVersion == 0 ||
|
||||||
|
(VK_VERSION_MAJOR(pCreateInfo->vulkanApiVersion) == 1 && VK_VERSION_MINOR(pCreateInfo->vulkanApiVersion) <= 1));
|
||||||
VMA_DEBUG_LOG("vmaCreateAllocator");
|
VMA_DEBUG_LOG("vmaCreateAllocator");
|
||||||
*pAllocator = vma_new(pCreateInfo->pAllocationCallbacks, VmaAllocator_T)(pCreateInfo);
|
*pAllocator = vma_new(pCreateInfo->pAllocationCallbacks, VmaAllocator_T)(pCreateInfo);
|
||||||
return (*pAllocator)->Init(pCreateInfo);
|
return (*pAllocator)->Init(pCreateInfo);
|
||||||
|
Loading…
Reference in New Issue
Block a user