From 17667177a76233faa787f165e0a3e5f5c3e0d05b Mon Sep 17 00:00:00 2001 From: fiestorra Date: Mon, 30 Nov 2026 22:30:04 +0100 Subject: [PATCH] mem-probe: the line says VRAM used of the budget, not just the card's size The probe prints the runtime's own allocations and the driver's numbers for the card, but not the two that decide whether an allocation survives: VK_EXT_memory_budget's heapUsage and heapBudget over the device-local heaps. read_vram_budget already reads them and memory_figures already has the struct, so this is the print. On the RTX 4090 here it reads 'VRAM 1.4/22.8 GB' at start and 'VRAM 6.8/22.8 GB' once the title is up; when the extension or the device does not report it the part is empty rather than 0/0, measured by forcing the guard off. The gap matters because the budget is 23370 MiB on a 24138 MiB heap, and it is the budget a title that settles at 7.7 GB already exceeds on an 8 GB card. --- runtime/shims/d3d12_vulkan_device.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/runtime/shims/d3d12_vulkan_device.cpp b/runtime/shims/d3d12_vulkan_device.cpp index 1c97dad489..1b14948900 100644 --- a/runtime/shims/d3d12_vulkan_device.cpp +++ b/runtime/shims/d3d12_vulkan_device.cpp @@ -22463,19 +22463,30 @@ class Device final peak = d.arena.peak_end; for (int i = 0; i < DeviceState::arena_use_count; ++i) use[i] = d.arena.use_in_use[i]; } - char text[512]; + // VK_EXT_memory_budget: what the driver says the device-local heaps can hold, and what this process + // holds of them. It is not the card's size: on the 24 GB card here the heap is 24138 MiB and the + // budget 23370, and the smaller the card the wider that gap matters, since the budget is what a + // failure is measured against (a title that settles at 7.7 GB is over an 8 GB card's budget + // before it allocates anything more). Empty when the extension or the device does not report it. + char vram[96] = ""; + const leonida::VramBudget budget = read_vram_budget(d.info); + if (budget.available) + std::snprintf(vram, sizeof vram, "; VRAM %.1f/%.1f GB", + double(budget.local_usage) / double(1ull << 30), + double(budget.local_budget) / double(1ull << 30)); + char text[768]; std::snprintf(text, sizeof text, "pipeline cache %.0f MiB; arena %.0f MiB (type %u), in use %.0f MiB (buffer %.0f, " "descriptor heap %.0f, shader %.0f, heap %.0f, windows/shadows %.0f), peak end %.0f MiB; " "title memory %llu ranges %.0f MiB reserved/committed VA; shadows %llu; fsdraw pipeline " - "notes %zu", + "notes %zu%s", leonida::mem_probe::mib(cache), leonida::mem_probe::mib(d.arena.size), d.arena.memory_type, leonida::mem_probe::mib(in_use), leonida::mem_probe::mib(use[0]), leonida::mem_probe::mib(use[1]), leonida::mem_probe::mib(use[2]), leonida::mem_probe::mib(use[3]), leonida::mem_probe::mib(use[DeviceState::arena_window]), leonida::mem_probe::mib(peak), (unsigned long long)title_ranges, leonida::mem_probe::mib(title), - (unsigned long long)shadows, leonida::fsdraw::pipeline_count()); + (unsigned long long)shadows, leonida::fsdraw::pipeline_count(), vram); return std::string(text); }; facts.share = [this] {