mirror of
https://github.com/EduApps-CDG/OpenDX
synced 2024-12-30 09:45:37 +01:00
[dxvk] Use VK_EXT_memory_budget to report memory usage
This commit is contained in:
parent
b76f470c5f
commit
412fb9ac57
@ -17,6 +17,8 @@ namespace dxvk {
|
|||||||
this->queryDeviceInfo();
|
this->queryDeviceInfo();
|
||||||
this->queryDeviceFeatures();
|
this->queryDeviceFeatures();
|
||||||
this->queryDeviceQueues();
|
this->queryDeviceQueues();
|
||||||
|
|
||||||
|
m_hasMemoryBudget = m_deviceExtensions.supports(VK_EXT_MEMORY_BUDGET_EXTENSION_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -31,16 +33,30 @@ namespace dxvk {
|
|||||||
|
|
||||||
|
|
||||||
DxvkAdapterMemoryInfo DxvkAdapter::getMemoryHeapInfo() const {
|
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 = { };
|
DxvkAdapterMemoryInfo info = { };
|
||||||
info.heapCount = props.memoryHeapCount;
|
info.heapCount = memProps.memoryProperties.memoryHeapCount;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < info.heapCount; i++) {
|
for (uint32_t i = 0; i < info.heapCount; i++) {
|
||||||
info.heaps[i].heapFlags = props.memoryHeaps[i].flags;
|
info.heaps[i].heapFlags = memProps.memoryProperties.memoryHeaps[i].flags;
|
||||||
info.heaps[i].memoryAvailable = props.memoryHeaps[i].size;
|
|
||||||
|
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();
|
info.heaps[i].memoryAllocated = m_heapAlloc[i].load();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
@ -328,6 +344,7 @@ namespace dxvk {
|
|||||||
void DxvkAdapter::notifyHeapMemoryAlloc(
|
void DxvkAdapter::notifyHeapMemoryAlloc(
|
||||||
uint32_t heap,
|
uint32_t heap,
|
||||||
VkDeviceSize bytes) {
|
VkDeviceSize bytes) {
|
||||||
|
if (!m_hasMemoryBudget)
|
||||||
m_heapAlloc[heap] += bytes;
|
m_heapAlloc[heap] += bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -335,6 +352,7 @@ namespace dxvk {
|
|||||||
void DxvkAdapter::notifyHeapMemoryFree(
|
void DxvkAdapter::notifyHeapMemoryFree(
|
||||||
uint32_t heap,
|
uint32_t heap,
|
||||||
VkDeviceSize bytes) {
|
VkDeviceSize bytes) {
|
||||||
|
if (!m_hasMemoryBudget)
|
||||||
m_heapAlloc[heap] -= bytes;
|
m_heapAlloc[heap] -= bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,6 +260,8 @@ namespace dxvk {
|
|||||||
DxvkDeviceInfo m_deviceInfo;
|
DxvkDeviceInfo m_deviceInfo;
|
||||||
DxvkDeviceFeatures m_deviceFeatures;
|
DxvkDeviceFeatures m_deviceFeatures;
|
||||||
|
|
||||||
|
bool m_hasMemoryBudget;
|
||||||
|
|
||||||
std::vector<VkQueueFamilyProperties> m_queueFamilies;
|
std::vector<VkQueueFamilyProperties> m_queueFamilies;
|
||||||
|
|
||||||
std::array<std::atomic<VkDeviceSize>, VK_MAX_MEMORY_HEAPS> m_heapAlloc;
|
std::array<std::atomic<VkDeviceSize>, VK_MAX_MEMORY_HEAPS> m_heapAlloc;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user