- hook up VMA_ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT

This commit is contained in:
Magnus Norddahl 2019-03-25 21:30:03 +01:00
parent 7256af0b32
commit 1c9bf262e6
2 changed files with 12 additions and 3 deletions

View file

@ -32,6 +32,7 @@
#include <array> #include <array>
#include <set> #include <set>
#include <string> #include <string>
#include <algorithm>
#include "vk_device.h" #include "vk_device.h"
#include "vk_swapchain.h" #include "vk_swapchain.h"
@ -215,10 +216,16 @@ void VulkanDevice::SelectPhysicalDevice()
transferFamily = SupportedDevices[selected].transferFamily; transferFamily = SupportedDevices[selected].transferFamily;
} }
bool VulkanDevice::SupportsDeviceExtension(const char *ext) const
{
return std::find(EnabledDeviceExtensions.begin(), EnabledDeviceExtensions.end(), ext) != EnabledDeviceExtensions.end();
}
void VulkanDevice::CreateAllocator() void VulkanDevice::CreateAllocator()
{ {
VmaAllocatorCreateInfo allocinfo = {}; VmaAllocatorCreateInfo allocinfo = {};
// allocinfo.flags = VMA_ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT; // To do: enable this for better performance if (SupportsDeviceExtension(VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME) && SupportsDeviceExtension(VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME))
allocinfo.flags = VMA_ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT;
allocinfo.physicalDevice = PhysicalDevice.Device; allocinfo.physicalDevice = PhysicalDevice.Device;
allocinfo.device = device; allocinfo.device = device;
allocinfo.preferredLargeHeapBlockSize = 64 * 1024 * 1024; allocinfo.preferredLargeHeapBlockSize = 64 * 1024 * 1024;

View file

@ -62,7 +62,7 @@ public:
// Device setup // Device setup
VkPhysicalDeviceFeatures UsedDeviceFeatures = {}; VkPhysicalDeviceFeatures UsedDeviceFeatures = {};
std::vector<const char *> EnabledDeviceExtensions = { VK_KHR_SWAPCHAIN_EXTENSION_NAME }; std::vector<const char *> EnabledDeviceExtensions = { VK_KHR_SWAPCHAIN_EXTENSION_NAME };
std::vector<const char *> OptionalDeviceExtensions = { VK_EXT_HDR_METADATA_EXTENSION_NAME }; std::vector<const char *> OptionalDeviceExtensions = { VK_EXT_HDR_METADATA_EXTENSION_NAME, VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME, VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME };
VulkanPhysicalDevice PhysicalDevice; VulkanPhysicalDevice PhysicalDevice;
bool DebugLayerActive = false; bool DebugLayerActive = false;
@ -83,11 +83,13 @@ private:
void CreateInstance(); void CreateInstance();
void CreateSurface(); void CreateSurface();
void SelectPhysicalDevice(); void SelectPhysicalDevice();
void SelectFeatures();
void CreateDevice(); void CreateDevice();
void CreateAllocator(); void CreateAllocator();
void ReleaseResources(); void ReleaseResources();
void SelectFeatures(); bool SupportsDeviceExtension(const char *ext) const;
static bool CheckRequiredFeatures(const VkPhysicalDeviceFeatures &f); static bool CheckRequiredFeatures(const VkPhysicalDeviceFeatures &f);
VkDebugUtilsMessengerEXT debugMessenger = VK_NULL_HANDLE; VkDebugUtilsMessengerEXT debugMessenger = VK_NULL_HANDLE;