mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:20:53 +01:00
[PR #2401] [MERGED] mem probe: a breakdown line of the runtime's Vulkan memory by consumer (RT-MEMORY-BREAKDOWN-AND-SPARSE-ARENA) #2401
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#2401
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/2401
Author: @aslan2142
Created: 11/26/2026
Status: ✅ Merged
Merged: 11/26/2026
Merged by: @aslan2142
Base:
main← Head:memory-breakdown-line📝 Commits (1)
aaff77bmem probe: a breakdown line of the runtime's Vulkan memory by consumer (RT-MEMORY-BREAKDOWN-AND-SPARSE-ARENA)📊 Changes
7 files changed (+376 additions, -7 deletions)
View changed files
📝
runtime/CMakeLists.txt(+6 -0)📝
runtime/README.md(+1 -0)📝
runtime/shims/d3d12_geometry_views.h(+2 -0)📝
runtime/shims/d3d12_vulkan_device.cpp(+34 -5)📝
runtime/src/mem_probe.h(+63 -2)➕
runtime/src/memory_breakdown.h(+152 -0)➕
runtime/test/memory_breakdown_test.cpp(+118 -0)📄 Description
Adds 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)
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.