vk: Filter out re-bar usage from memory pressure watchdog

This commit is contained in:
kd-11
2025-10-24 13:40:07 +03:00
committed by Ani
parent ae30cb5557
commit 73c984a637
4 changed files with 35 additions and 0 deletions

View File

@@ -1010,6 +1010,8 @@ namespace vk
.heap = memory_properties.memoryHeaps[i],
.types = {}
});
result.heaps.push_back({ i, memory_properties.memoryHeaps[i].flags, memory_properties.memoryHeaps[i].size });
}
for (u32 i = 0; i < memory_properties.memoryTypeCount; i++)

View File

@@ -30,6 +30,8 @@ namespace vk
struct memory_type_mapping
{
std::vector<memory_heap_info> heaps;
memory_type_info host_visible_coherent;
memory_type_info device_local;
memory_type_info device_bar;

View File

@@ -200,6 +200,23 @@ namespace vk
// Allow fastest possible allocation on start
set_fastest_allocation_flags();
// Determine the rebar heap. We will exclude it from stats
const auto& memory_map = dev.get_memory_mapping();
if (memory_map.device_bar_total_bytes !=
memory_map.device_local_total_bytes)
{
for (u32 i = 0; i < ::size32(memory_map.heaps); ++i)
{
const auto& heap = memory_map.heaps[i];
if ((heap.flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) &&
heap.size == memory_map.device_bar_total_bytes)
{
m_rebar_heap_idx = i;
break;
}
}
}
}
void mem_allocator_vma::destroy()
@@ -313,6 +330,12 @@ namespace vk
{
vmaGetHeapBudgets(m_allocator, stats.data());
// Filter out the Re-BAR heap
if (::size32(stats) > m_rebar_heap_idx)
{
stats[m_rebar_heap_idx].budget = 0;
}
float max_usage = 0.f;
for (const auto& info : stats)
{

View File

@@ -59,6 +59,13 @@ namespace vk
void rebalance();
};
struct memory_heap_info
{
u32 index;
u32 flags;
u64 size;
};
class mem_allocator_base
{
public:
@@ -113,6 +120,7 @@ namespace vk
private:
VmaAllocator m_allocator;
std::array<VmaBudget, VK_MAX_MEMORY_HEAPS> stats;
u32 m_rebar_heap_idx = UINT32_MAX;
};