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

[dxgi] Use heap size to determine reservable memory

Budgets can change dynamically, so this should be more robust.
This commit is contained in:
Philip Rebohle 2023-03-12 13:16:57 +01:00
parent d14dcf5d47
commit 6783123654
3 changed files with 7 additions and 4 deletions

View File

@ -354,6 +354,7 @@ namespace dxvk {
pVideoMemoryInfo->Budget = 0; pVideoMemoryInfo->Budget = 0;
pVideoMemoryInfo->CurrentUsage = 0; pVideoMemoryInfo->CurrentUsage = 0;
pVideoMemoryInfo->AvailableForReservation = 0;
for (uint32_t i = 0; i < memInfo.heapCount; i++) { for (uint32_t i = 0; i < memInfo.heapCount; i++) {
if ((memInfo.heaps[i].heapFlags & heapFlagMask) != heapFlags) if ((memInfo.heaps[i].heapFlags & heapFlagMask) != heapFlags)
@ -361,13 +362,13 @@ namespace dxvk {
pVideoMemoryInfo->Budget += memInfo.heaps[i].memoryBudget; pVideoMemoryInfo->Budget += memInfo.heaps[i].memoryBudget;
pVideoMemoryInfo->CurrentUsage += memInfo.heaps[i].memoryAllocated; pVideoMemoryInfo->CurrentUsage += memInfo.heaps[i].memoryAllocated;
pVideoMemoryInfo->AvailableForReservation += memInfo.heaps[i].heapSize / 2;
} }
// We don't implement reservation, but the observable // We don't implement reservation, but the observable
// behaviour should match that of Windows drivers // behaviour should match that of Windows drivers
uint32_t segmentId = uint32_t(MemorySegmentGroup); uint32_t segmentId = uint32_t(MemorySegmentGroup);
pVideoMemoryInfo->AvailableForReservation = pVideoMemoryInfo->Budget / 2;
pVideoMemoryInfo->CurrentReservation = m_memReservation[segmentId]; pVideoMemoryInfo->CurrentReservation = m_memReservation[segmentId];
return S_OK; return S_OK;
} }

View File

@ -39,6 +39,7 @@ namespace dxvk {
for (uint32_t i = 0; i < info.heapCount; i++) { for (uint32_t i = 0; i < info.heapCount; i++) {
info.heaps[i].heapFlags = memProps.memoryProperties.memoryHeaps[i].flags; info.heaps[i].heapFlags = memProps.memoryProperties.memoryHeaps[i].flags;
info.heaps[i].heapSize = memProps.memoryProperties.memoryHeaps[i].size;
if (m_hasMemoryBudget) { if (m_hasMemoryBudget) {
info.heaps[i].memoryBudget = memBudget.heapBudget[i]; info.heaps[i].memoryBudget = memBudget.heapBudget[i];

View File

@ -30,6 +30,7 @@ namespace dxvk {
*/ */
struct DxvkAdapterMemoryHeapInfo { struct DxvkAdapterMemoryHeapInfo {
VkMemoryHeapFlags heapFlags; VkMemoryHeapFlags heapFlags;
VkDeviceSize heapSize;
VkDeviceSize memoryBudget; VkDeviceSize memoryBudget;
VkDeviceSize memoryAllocated; VkDeviceSize memoryAllocated;
}; };