mem probe: a breakdown line of the runtime's Vulkan memory by consumer (RT-MEMORY-BREAKDOWN-AND-SPARSE-ARENA) #2401
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!2401
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2401/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@aslan2142 on GitHub · 2026-11-26 19:39 UTC · original
aslan2142:memory-breakdown-line→main· +376 −7 · 7 files · 1 commits · merged 2026-11-26 19:43 UTCAdds one diagnostic line to the memory probe: our Vulkan allocations broken down by consumer, so the VRAM the game
uses in the world can be attributed before anything is changed. No behaviour changes.
Claimed in the coordination issue as: RT-MEMORY-BREAKDOWN-AND-SPARSE-ARENA
What was measured
vkAllocateMemorybytes in the device-local heap to withinabout 0.1-0.3 GB, so what needs explaining is in our allocations.
to 1.2 GB of the Resizable BAR type cannot be split by today's log lines.
LEONIDA_ARENA_MB=4095) had about 0.76 GB in use (peak about 1 GB); the rest of its4 GiB was allocated and never touched.
What changes
One commit:
[rt] mem-probe breakdown t=<s>:on everyLEONIDA_MEM_PROBEtick. It prints:and heaps);
other.The parts add up to the total. Imported memory is shown apart. Bindless tables, shader modules, pipelines and
swapchain images are shown beside the total, not in it.
src/memory_breakdown.h(new, standard library only): the consumers, anOwnerscope that names theallocations a thread makes while it lives, the tally and the text.
src/mem_probe.h: thevkAllocateMemorywrapper records the thread's owner.vkCreateImage,vkDestroyImageandvkBindImageMemoryare wrapped too, so unnamed memory that a dedicated image is bound tocounts as a render target/depth buffer or a sampled texture.
Ownerscopes at the allocation sites of the arena, geometry copies, title windows, slot-133 shadow buffers,upload/readback heaps, staging and copy scratch, and the texture blocks.
runtime/README.md: aLEONIDA_MEM_PROBErow that names the three probe lines.The second half of the item, a sparse arena (memory bound only where allocations are), is not in this pull
request. Step 0 found what blocks it (below).
Device support
The breakdown line works on any device. Findings for the sparse arena, from a test program (Mesa 26.3.1, natively
and through Wine 11.22):
sparseBinding/sparseResidencyBufferresidencyNonResidentStrictsparseAddressSpaceSizeVK_EXT_map_memory_placednatively / under WineWhat blocks the sparse arena is the CPU side, not the GPU. Today the arena has one contiguous CPU mapping
(
arena.mapped + offset, about 50 uses). A sparse buffer has no mapping of its own: each backing block is mappedby itself. Only
VK_EXT_map_memory_placedcan place those mappings into one contiguous range, and Wine'swinevulkandoes not offer it to Windows programs. The design has to change first. Either the arena's CPUcontract becomes one mapping per backing block, with no allocation crossing a block and the whole-arena users
reworked, or Wine starts offering placed mappings.
Tests
memory_breakdown_test(CPU, new): the tally, owner scopes, image kinds and the text. It does not build onmain.ctest: 114 of 114 pass on llvmpipe and on the integrated GPU (RADV, Mesa 26.3.1).main2d43417d4:memory_breakdownis new and passes.d3d12_queue_handoverfailed on
mainand passed here.memory_breakdownis new and passes. The same 23 tests fail as onmain(presentation tests under xvfb and other known failures).tests/test_docs_*.py,tests/test_ci_registration.py,tests/test_text_write_line_endings.pyandscripts/check_no_game_data.pyon the changed files pass.Not tested
AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2)
@aslan2142 on GitHub · 2026-11-26 19:43 UTC · original
Merging. This is a self-merge.
main2d43417d4+ this PR (aaff77b83), Mesa 26.3.1:memory_breakdown_testpasses; it is new with the header it tests.ctest: 114/114 on llvmpipe and on the integrated RDNA2 GPU (RADV).check_no_game_data.pypass.VK_EXT_map_memory_placed. It follows as its own PR with one mapping per backing block.AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2)
@BadgersMC on GitHub · 2026-11-26 20:48 UTC · original
Native Windows verification at merge commit
fac8b4bb, RTX 3060 Ti 8 GB (10de:2486), NVIDIA 610.88, MSVC 19.44. The upstreammemory_breakdown_testpassed 5/5.I also ran the merged
mem_probe.hwrappers in a standalone Vulkan fixture using generated resources. With Vulkan validation enabled, all three runs reported 18 MiB owned (4 sampled, 8 color/depth, 4 explicitly tagged texture-block memory, 2 staging) and 2 MiB of imported host pages separately. Both totals returned to zero after releasing the resources. No validation errors were reported. No game data or title run was involved.For the sparse-arena design, this driver reports sparse buffer residency, strict nonresident behavior, and a 1 TiB sparse address space. The driver does not advertise
VK_EXT_map_memory_placed. Those are capability queries. The fixture exercised allocation accounting and host import. AI-assisted.