Enable more extensions desired by vk_mem_alloc and add vk_membudget cvar
This commit is contained in:
parent
30cc548d92
commit
a9a5ee8a96
3 changed files with 60 additions and 0 deletions
|
|
@ -1762,10 +1762,20 @@ std::shared_ptr<VulkanSurface> VulkanSurfaceBuilder::Create(std::shared_ptr<Vulk
|
|||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef VK_KHR_MAINTENANCE4_EXTENSION_NAME
|
||||
#define VK_KHR_MAINTENANCE4_EXTENSION_NAME "VK_KHR_maintenance4"
|
||||
#endif
|
||||
|
||||
VulkanDeviceBuilder::VulkanDeviceBuilder()
|
||||
{
|
||||
// Extensions desired by vk_mem_alloc
|
||||
OptionalExtension(VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME);
|
||||
OptionalExtension(VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME);
|
||||
OptionalExtension(VK_KHR_BIND_MEMORY_2_EXTENSION_NAME);
|
||||
//OptionalExtension(VK_KHR_MAINTENANCE4_EXTENSION_NAME);
|
||||
OptionalExtension(VK_EXT_MEMORY_BUDGET_EXTENSION_NAME);
|
||||
OptionalExtension(VK_EXT_MEMORY_PRIORITY_EXTENSION_NAME);
|
||||
OptionalExtension(VK_AMD_DEVICE_COHERENT_MEMORY_EXTENSION_NAME);
|
||||
}
|
||||
|
||||
VulkanDeviceBuilder& VulkanDeviceBuilder::RequireExtension(const std::string& extensionName)
|
||||
|
|
|
|||
|
|
@ -40,6 +40,10 @@ bool VulkanDevice::SupportsExtension(const char* ext) const
|
|||
Instance->EnabledExtensions.find(ext) != Instance->EnabledExtensions.end();
|
||||
}
|
||||
|
||||
#ifndef VK_KHR_MAINTENANCE4_EXTENSION_NAME
|
||||
#define VK_KHR_MAINTENANCE4_EXTENSION_NAME "VK_KHR_maintenance4"
|
||||
#endif
|
||||
|
||||
void VulkanDevice::CreateAllocator()
|
||||
{
|
||||
VmaAllocatorCreateInfo allocinfo = {};
|
||||
|
|
@ -48,6 +52,16 @@ void VulkanDevice::CreateAllocator()
|
|||
allocinfo.flags |= VMA_ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT;
|
||||
if (SupportsExtension(VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME))
|
||||
allocinfo.flags |= VMA_ALLOCATOR_CREATE_BUFFER_DEVICE_ADDRESS_BIT;
|
||||
if (SupportsExtension(VK_KHR_BIND_MEMORY_2_EXTENSION_NAME))
|
||||
allocinfo.flags |= VMA_ALLOCATOR_CREATE_KHR_BIND_MEMORY2_BIT;
|
||||
//if (SupportsExtension(VK_KHR_MAINTENANCE4_EXTENSION_NAME))
|
||||
// allocinfo.flags |= MA_ALLOCATOR_CREATE_KHR_MAINTENANCE4_BIT;
|
||||
if (SupportsExtension(VK_EXT_MEMORY_BUDGET_EXTENSION_NAME))
|
||||
allocinfo.flags |= VMA_ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT;
|
||||
if (SupportsExtension(VK_EXT_MEMORY_PRIORITY_EXTENSION_NAME))
|
||||
allocinfo.flags |= VMA_ALLOCATOR_CREATE_EXT_MEMORY_PRIORITY_BIT;
|
||||
if (SupportsExtension(VK_AMD_DEVICE_COHERENT_MEMORY_EXTENSION_NAME))
|
||||
allocinfo.flags |= VMA_ALLOCATOR_CREATE_AMD_DEVICE_COHERENT_MEMORY_BIT;
|
||||
allocinfo.physicalDevice = PhysicalDevice.Device;
|
||||
allocinfo.device = device;
|
||||
allocinfo.instance = Instance->Instance;
|
||||
|
|
|
|||
|
|
@ -76,6 +76,8 @@ EXTERN_CVAR(Bool, r_skipmats)
|
|||
// Physical device info
|
||||
static std::vector<VulkanCompatibleDevice> SupportedDevices;
|
||||
int vkversion;
|
||||
static TArray<FString> memheapnames;
|
||||
static TArray<VmaBudget> membudgets;
|
||||
|
||||
CUSTOM_CVAR(Bool, vk_debug, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
|
||||
{
|
||||
|
|
@ -102,6 +104,27 @@ CCMD(vk_listdevices)
|
|||
}
|
||||
}
|
||||
|
||||
CCMD(vk_membudget)
|
||||
{
|
||||
for (size_t i = 0; i < membudgets.size(); i++)
|
||||
{
|
||||
if (membudgets[i].budget != 0)
|
||||
{
|
||||
Printf("#%d %s - %d MB used out of %d MB estimated budget (%d%%)\n",
|
||||
i, memheapnames[i].GetChars(),
|
||||
(int)(membudgets[i].usage / (1024 * 1024)),
|
||||
(int)(membudgets[i].budget / (1024 * 1024)),
|
||||
(int)(membudgets[i].usage * 100 / membudgets[i].budget));
|
||||
}
|
||||
else
|
||||
{
|
||||
Printf("#%d %s - %d MB used\n",
|
||||
i, memheapnames[i].GetChars(),
|
||||
(int)(membudgets[i].usage / (1024 * 1024)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void I_BuildVKDeviceList(FOptionValues* opt)
|
||||
{
|
||||
for (size_t i = 0; i < SupportedDevices.size(); i++)
|
||||
|
|
@ -478,6 +501,19 @@ TArray<uint8_t> VulkanRenderDevice::GetScreenshotBuffer(int &pitch, ESSType &col
|
|||
|
||||
void VulkanRenderDevice::BeginFrame()
|
||||
{
|
||||
vmaSetCurrentFrameIndex(mDevice->allocator, 0);
|
||||
membudgets.Resize(mDevice->PhysicalDevice.Properties.Memory.memoryHeapCount);
|
||||
vmaGetHeapBudgets(mDevice->allocator, membudgets.data());
|
||||
if (memheapnames.size() == 0)
|
||||
{
|
||||
memheapnames.Resize(mDevice->PhysicalDevice.Properties.Memory.memoryHeapCount);
|
||||
for (unsigned int i = 0; i < memheapnames.Size(); i++)
|
||||
{
|
||||
bool deviceLocal = !!(mDevice->PhysicalDevice.Properties.Memory.memoryHeaps[i].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT);
|
||||
memheapnames[i] = deviceLocal ? "device local" : "system";
|
||||
}
|
||||
}
|
||||
|
||||
if (levelMeshChanged)
|
||||
{
|
||||
levelMeshChanged = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue