diff options
| author | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-26 14:31:34 -0500 |
|---|---|---|
| committer | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-26 14:31:34 -0500 |
| commit | aaff77b831a5167b4b255fe92b7cde4add593b98 (patch) | |
| tree | de62c97ea795078ad9e199fdfacb53092d3eff8c /runtime/src/tls_host.cpp | |
| parent | 2d43417d49fdd8f2d8241f75ea8fd0cdd8811137 (diff) | |
mem probe: a breakdown line of the runtime's Vulkan memory by consumer (RT-MEMORY-BREAKDOWN-AND-SPARSE-ARENA)
The `mem-probe t=` line sums our vkAllocateMemory bytes per memory type, but not who holds them: in a late world
run 7.5 GB of device-local memory and up to 1.2 GB of the Resizable BAR type could not be attributed. Every tick
now also prints
[rt] mem-probe breakdown t=<s>: allocated N MiB = arena A (n) [reserved, bound, in use: buffers, descriptor
heaps, shader code, heaps] + geometry copies + title windows and shadows + upload heaps + staging + texture
blocks + sampled textures + render targets and depth + other; imported M MiB; not in the total: bindless
tables, shader modules, pipelines and swapchain images
whose parts add up to the allocated bytes of the t= line. Diagnostic only: nothing changes what is allocated or
where, and with LEONIDA_MEM_PROBE unset nothing is installed.
- src/memory_breakdown.h (new, standard library only): the consumers, an Owner scope (thread-local) that names
the allocations a thread makes while it lives, the tally and the line's text.
- src/mem_probe.h: the vkAllocateMemory wrapper records the thread's owner; vkCreateImage/vkDestroyImage/
vkBindImageMemory are wrapped too, so memory nobody named that a dedicated image is bound to counts as a render
target or depth buffer (attachment usage) or a sampled texture. Named blocks keep their name.
- Owner scopes at the allocation sites: the arena (create_arena), geometry copies (GeometryViews' pool), title
windows outside the arena and slot-133 shadow buffers with their own memory, upload/readback heap buffers,
texture staging and copy scratch, and the texture blocks (ImageMemory, TitleImagePool).
- The device adds the arena's reserved, bound and in-use bytes (by kind) and the bindless table bytes, read under
the arena's and the descriptor locks; BindlessSet allocates through its own function table, so its bytes are
shown beside the total, not in it.
- runtime/README.md: LEONIDA_MEM_PROBE's row names the three lines.
Test: memory_breakdown_test (CPU): the tally sums to the total with imported memory kept apart, owner scopes nest
and stay on their thread, image usage picks the kind, and the text lists every part. It does not build on main
(the header is new).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/src/tls_host.cpp')
0 files changed, 0 insertions, 0 deletions