mirror of
https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git
synced 2024-11-12 19:41:47 +00:00
extension enabled
This commit is contained in:
parent
c9b2a6a465
commit
2683cfedc5
@ -8258,15 +8258,50 @@ static void TestWin32Handles()
|
|||||||
{
|
{
|
||||||
#if VMA_EXTERNAL_MEMORY_WIN32
|
#if VMA_EXTERNAL_MEMORY_WIN32
|
||||||
wprintf(L"Test Win32 handles\n");
|
wprintf(L"Test Win32 handles\n");
|
||||||
VkBufferCreateInfo bufCreateInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO };
|
constexpr static VkExportMemoryAllocateInfoKHR exportInfo{
|
||||||
bufCreateInfo.size = 1024;
|
VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO_KHR,
|
||||||
bufCreateInfo.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
|
nullptr,
|
||||||
VmaAllocationCreateInfo allocCreateInfo = {};
|
VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT
|
||||||
allocCreateInfo.usage = VMA_MEMORY_USAGE_AUTO;
|
};
|
||||||
|
constexpr static VkExternalMemoryBufferCreateInfoKHR externalInfo{
|
||||||
|
VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_BUFFER_CREATE_INFO_KHR,
|
||||||
|
nullptr,
|
||||||
|
VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT
|
||||||
|
};
|
||||||
|
|
||||||
|
VkBufferCreateInfo sampleBufCreateInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO };
|
||||||
|
sampleBufCreateInfo.size = 0x1000; // Doesn't matter.
|
||||||
|
sampleBufCreateInfo.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
|
||||||
|
sampleBufCreateInfo.pNext = &externalInfo;
|
||||||
|
|
||||||
|
VmaAllocationCreateInfo sampleAllocCreateInfo = {};
|
||||||
|
sampleAllocCreateInfo.usage = VMA_MEMORY_USAGE_AUTO;
|
||||||
|
sampleAllocCreateInfo.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT;
|
||||||
|
|
||||||
|
uint32_t memTypeIndex;
|
||||||
|
TEST(vmaFindMemoryTypeIndexForBufferInfo(g_hAllocator,
|
||||||
|
&sampleBufCreateInfo, &sampleAllocCreateInfo, &memTypeIndex) == VK_SUCCESS);
|
||||||
|
// Check res...
|
||||||
|
|
||||||
|
|
||||||
|
// Create a pool that can have at most 2 blocks, 128 MiB each.
|
||||||
|
VmaPoolCreateInfo poolCreateInfo = {};
|
||||||
|
poolCreateInfo.memoryTypeIndex = memTypeIndex;
|
||||||
|
poolCreateInfo.blockSize = 128ull * 1024 * 1024;
|
||||||
|
poolCreateInfo.maxBlockCount = 2;
|
||||||
|
poolCreateInfo.pMemoryAllocateNext = (void*)&exportInfo;
|
||||||
|
|
||||||
|
|
||||||
|
VmaPool pool;
|
||||||
|
TEST(vmaCreatePool(g_hAllocator, &poolCreateInfo, &pool) == VK_SUCCESS);
|
||||||
|
|
||||||
|
|
||||||
|
sampleAllocCreateInfo.pool = pool;
|
||||||
|
|
||||||
VkBuffer buf;
|
VkBuffer buf;
|
||||||
VmaAllocation alloc;
|
VmaAllocation alloc;
|
||||||
VmaAllocationInfo allocInfo;
|
VmaAllocationInfo allocInfo;
|
||||||
TEST(vmaCreateBuffer(g_hAllocator, &bufCreateInfo, &allocCreateInfo, &buf, &alloc, &allocInfo) == VK_SUCCESS);
|
TEST(vmaCreateBuffer(g_hAllocator, &sampleBufCreateInfo, &sampleAllocCreateInfo, &buf, &alloc, &allocInfo) == VK_SUCCESS);
|
||||||
HANDLE handle;
|
HANDLE handle;
|
||||||
HANDLE handle2;
|
HANDLE handle2;
|
||||||
TEST(vmaGetMemoryWin32HandleKHR(g_hAllocator, alloc, nullptr, &handle) == VK_SUCCESS);
|
TEST(vmaGetMemoryWin32HandleKHR(g_hAllocator, alloc, nullptr, &handle) == VK_SUCCESS);
|
||||||
|
@ -69,6 +69,7 @@ bool VK_KHR_buffer_device_address_enabled = false;
|
|||||||
bool VK_EXT_memory_priority_enabled = false;
|
bool VK_EXT_memory_priority_enabled = false;
|
||||||
bool VK_EXT_debug_utils_enabled = false;
|
bool VK_EXT_debug_utils_enabled = false;
|
||||||
bool VK_KHR_maintenance5_enabled = false;
|
bool VK_KHR_maintenance5_enabled = false;
|
||||||
|
bool VK_KHR_external_memory_win32_enabled = false;
|
||||||
bool g_SparseBindingEnabled = false;
|
bool g_SparseBindingEnabled = false;
|
||||||
|
|
||||||
// # Pointers to functions from extensions
|
// # Pointers to functions from extensions
|
||||||
@ -1449,6 +1450,7 @@ static void PrintEnabledFeatures()
|
|||||||
}
|
}
|
||||||
wprintf(L"VK_EXT_memory_priority: %d\n", VK_EXT_memory_priority_enabled ? 1 : 0);
|
wprintf(L"VK_EXT_memory_priority: %d\n", VK_EXT_memory_priority_enabled ? 1 : 0);
|
||||||
wprintf(L"VK_KHR_maintenance5: %d\n", VK_KHR_maintenance5_enabled? 1 : 0);
|
wprintf(L"VK_KHR_maintenance5: %d\n", VK_KHR_maintenance5_enabled? 1 : 0);
|
||||||
|
wprintf(L"VK_KHR_external_memory_win32: %d\n", VK_KHR_external_memory_win32_enabled ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetAllocatorCreateInfo(VmaAllocatorCreateInfo& outInfo)
|
void SetAllocatorCreateInfo(VmaAllocatorCreateInfo& outInfo)
|
||||||
@ -1494,6 +1496,11 @@ void SetAllocatorCreateInfo(VmaAllocatorCreateInfo& outInfo)
|
|||||||
outInfo.flags |= VMA_ALLOCATOR_CREATE_KHR_MAINTENANCE5_BIT;
|
outInfo.flags |= VMA_ALLOCATOR_CREATE_KHR_MAINTENANCE5_BIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(VK_KHR_external_memory_win32_enabled)
|
||||||
|
{
|
||||||
|
outInfo.flags |= VMA_ALLOCATOR_CREATE_KHR_EXTERNAL_MEMORY_WIN32_BIT;
|
||||||
|
}
|
||||||
|
|
||||||
if(USE_CUSTOM_CPU_ALLOCATION_CALLBACKS)
|
if(USE_CUSTOM_CPU_ALLOCATION_CALLBACKS)
|
||||||
{
|
{
|
||||||
outInfo.pAllocationCallbacks = &g_CpuAllocationCallbacks;
|
outInfo.pAllocationCallbacks = &g_CpuAllocationCallbacks;
|
||||||
@ -1876,6 +1883,8 @@ static void InitializeApplication()
|
|||||||
VK_EXT_memory_priority_enabled = true;
|
VK_EXT_memory_priority_enabled = true;
|
||||||
else if(strcmp(physicalDeviceExtensionProperties[i].extensionName, VK_KHR_MAINTENANCE_5_EXTENSION_NAME) == 0)
|
else if(strcmp(physicalDeviceExtensionProperties[i].extensionName, VK_KHR_MAINTENANCE_5_EXTENSION_NAME) == 0)
|
||||||
VK_KHR_maintenance5_enabled = true;
|
VK_KHR_maintenance5_enabled = true;
|
||||||
|
else if (strcmp(physicalDeviceExtensionProperties[i].extensionName, VK_KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME) == 0)
|
||||||
|
VK_KHR_external_memory_win32_enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(GetVulkanApiVersion() >= VK_API_VERSION_1_2)
|
if(GetVulkanApiVersion() >= VK_API_VERSION_1_2)
|
||||||
@ -2036,6 +2045,8 @@ static void InitializeApplication()
|
|||||||
enabledDeviceExtensions.push_back(VK_EXT_MEMORY_PRIORITY_EXTENSION_NAME);
|
enabledDeviceExtensions.push_back(VK_EXT_MEMORY_PRIORITY_EXTENSION_NAME);
|
||||||
if(VK_KHR_maintenance5_enabled)
|
if(VK_KHR_maintenance5_enabled)
|
||||||
enabledDeviceExtensions.push_back(VK_KHR_MAINTENANCE_5_EXTENSION_NAME);
|
enabledDeviceExtensions.push_back(VK_KHR_MAINTENANCE_5_EXTENSION_NAME);
|
||||||
|
if (VK_KHR_external_memory_win32_enabled)
|
||||||
|
enabledDeviceExtensions.push_back(VK_KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME);
|
||||||
|
|
||||||
VkPhysicalDeviceFeatures2 deviceFeatures = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2 };
|
VkPhysicalDeviceFeatures2 deviceFeatures = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2 };
|
||||||
deviceFeatures.features.samplerAnisotropy = VK_TRUE;
|
deviceFeatures.features.samplerAnisotropy = VK_TRUE;
|
||||||
|
Loading…
Reference in New Issue
Block a user