1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-12 13:08:50 +01:00

[dxvk] Use VK_EXT_memory_budget to report memory usage

This commit is contained in:
Philip Rebohle 2019-01-30 13:59:35 +01:00
parent b76f470c5f
commit 412fb9ac57
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 27 additions and 7 deletions

View File

@ -17,6 +17,8 @@ namespace dxvk {
this->queryDeviceInfo();
this->queryDeviceFeatures();
this->queryDeviceQueues();
m_hasMemoryBudget = m_deviceExtensions.supports(VK_EXT_MEMORY_BUDGET_EXTENSION_NAME);
}
@ -31,15 +33,29 @@ namespace dxvk {
DxvkAdapterMemoryInfo DxvkAdapter::getMemoryHeapInfo() const {
VkPhysicalDeviceMemoryProperties props = memoryProperties();
VkPhysicalDeviceMemoryBudgetPropertiesEXT memBudget = { };
memBudget.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_BUDGET_PROPERTIES_EXT;
memBudget.pNext = nullptr;
VkPhysicalDeviceMemoryProperties2KHR memProps = { };
memProps.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2_KHR;
memProps.pNext = m_hasMemoryBudget ? &memBudget : nullptr;
m_vki->vkGetPhysicalDeviceMemoryProperties2KHR(m_handle, &memProps);
DxvkAdapterMemoryInfo info = { };
info.heapCount = props.memoryHeapCount;
info.heapCount = memProps.memoryProperties.memoryHeapCount;
for (uint32_t i = 0; i < info.heapCount; i++) {
info.heaps[i].heapFlags = props.memoryHeaps[i].flags;
info.heaps[i].memoryAvailable = props.memoryHeaps[i].size;
info.heaps[i].memoryAllocated = m_heapAlloc[i].load();
info.heaps[i].heapFlags = memProps.memoryProperties.memoryHeaps[i].flags;
if (m_hasMemoryBudget) {
info.heaps[i].memoryAvailable = memBudget.heapBudget[i];
info.heaps[i].memoryAllocated = memBudget.heapUsage[i];
} else {
info.heaps[i].memoryAvailable = memProps.memoryProperties.memoryHeaps[i].size;
info.heaps[i].memoryAllocated = m_heapAlloc[i].load();
}
}
return info;
@ -328,14 +344,16 @@ namespace dxvk {
void DxvkAdapter::notifyHeapMemoryAlloc(
uint32_t heap,
VkDeviceSize bytes) {
m_heapAlloc[heap] += bytes;
if (!m_hasMemoryBudget)
m_heapAlloc[heap] += bytes;
}
void DxvkAdapter::notifyHeapMemoryFree(
uint32_t heap,
VkDeviceSize bytes) {
m_heapAlloc[heap] -= bytes;
if (!m_hasMemoryBudget)
m_heapAlloc[heap] -= bytes;
}

View File

@ -259,6 +259,8 @@ namespace dxvk {
DxvkNameSet m_deviceExtensions;
DxvkDeviceInfo m_deviceInfo;
DxvkDeviceFeatures m_deviceFeatures;
bool m_hasMemoryBudget;
std::vector<VkQueueFamilyProperties> m_queueFamilies;