1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-02 10:24:12 +01:00

[dxvk] Introduce memory heap budget

Allows more fine-grained control of memory allocations for specific
heaps. For now, target 80% for device-local heaps on UMA devices.
This commit is contained in:
Philip Rebohle 2020-08-22 11:50:37 +02:00
parent 743f309253
commit e435e071e0
2 changed files with 9 additions and 4 deletions

View File

@ -160,6 +160,13 @@ namespace dxvk {
for (uint32_t i = 0; i < m_memProps.memoryHeapCount; i++) { for (uint32_t i = 0; i < m_memProps.memoryHeapCount; i++) {
m_memHeaps[i].properties = m_memProps.memoryHeaps[i]; m_memHeaps[i].properties = m_memProps.memoryHeaps[i];
m_memHeaps[i].stats = DxvkMemoryStats { 0, 0 }; m_memHeaps[i].stats = DxvkMemoryStats { 0, 0 };
m_memHeaps[i].budget = 0;
/* Target 80% of a heap on systems where we want
* to avoid oversubscribing memory heaps */
if ((m_memProps.memoryHeaps[i].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT)
&& (m_device->isUnifiedMemoryArchitecture()))
m_memHeaps[i].budget = (8 * m_memProps.memoryHeaps[i].size) / 10;
} }
for (uint32_t i = 0; i < m_memProps.memoryTypeCount; i++) { for (uint32_t i = 0; i < m_memProps.memoryTypeCount; i++) {
@ -170,7 +177,6 @@ namespace dxvk {
m_memTypes[i].chunkSize = pickChunkSize(i); m_memTypes[i].chunkSize = pickChunkSize(i);
} }
m_restrictAllocations = m_device->isUnifiedMemoryArchitecture();
} }
@ -316,7 +322,7 @@ namespace dxvk {
bool useMemoryPriority = (flags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) bool useMemoryPriority = (flags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)
&& (m_device->features().extMemoryPriority.memoryPriority); && (m_device->features().extMemoryPriority.memoryPriority);
if (m_restrictAllocations && type->heap->stats.memoryAllocated + size > type->heap->properties.size) if (type->heap->budget && type->heap->stats.memoryAllocated + size > type->heap->budget)
return DxvkDeviceMemory(); return DxvkDeviceMemory();
DxvkDeviceMemory result; DxvkDeviceMemory result;

View File

@ -44,6 +44,7 @@ namespace dxvk {
struct DxvkMemoryHeap { struct DxvkMemoryHeap {
VkMemoryHeap properties; VkMemoryHeap properties;
DxvkMemoryStats stats; DxvkMemoryStats stats;
VkDeviceSize budget;
}; };
@ -285,8 +286,6 @@ namespace dxvk {
std::array<DxvkMemoryHeap, VK_MAX_MEMORY_HEAPS> m_memHeaps; std::array<DxvkMemoryHeap, VK_MAX_MEMORY_HEAPS> m_memHeaps;
std::array<DxvkMemoryType, VK_MAX_MEMORY_TYPES> m_memTypes; std::array<DxvkMemoryType, VK_MAX_MEMORY_TYPES> m_memTypes;
bool m_restrictAllocations;
DxvkMemory tryAlloc( DxvkMemory tryAlloc(
const VkMemoryRequirements* req, const VkMemoryRequirements* req,
const VkMemoryDedicatedAllocateInfo* dedAllocInfo, const VkMemoryDedicatedAllocateInfo* dedAllocInfo,