<feed xmlns='http://www.w3.org/2005/Atom'>
<title>npub1w4dsu3e6hzjehh7l3c9njhtwwtgk9g209ylqf4tvdn2m07xjq06se9ett9/Leonida/runtime/src/memory_breakdown.h, branch docs/pso-cache-scope-note</title>
<subtitle>[no description]</subtitle>
<id>https://upleb.uk/npub1w4dsu3e6hzjehh7l3c9njhtwwtgk9g209ylqf4tvdn2m07xjq06se9ett9/Leonida/atom?h=docs%2Fpso-cache-scope-note</id>
<link rel='self' href='https://upleb.uk/npub1w4dsu3e6hzjehh7l3c9njhtwwtgk9g209ylqf4tvdn2m07xjq06se9ett9/Leonida/atom?h=docs%2Fpso-cache-scope-note'/>
<link rel='alternate' type='text/html' href='https://upleb.uk/npub1w4dsu3e6hzjehh7l3c9njhtwwtgk9g209ylqf4tvdn2m07xjq06se9ett9/Leonida/'/>
<updated>2026-11-26T19:31:34+00:00</updated>
<entry>
<title>mem probe: a breakdown line of the runtime's Vulkan memory by consumer (RT-MEMORY-BREAKDOWN-AND-SPARSE-ARENA)</title>
<updated>2026-11-26T19:31:34+00:00</updated>
<author>
<name>Jan Trencansky</name>
<email>jan.trencansky@protonmail.com</email>
</author>
<published>2026-11-26T19:31:34+00:00</published>
<link rel='alternate' type='text/html' href='https://upleb.uk/npub1w4dsu3e6hzjehh7l3c9njhtwwtgk9g209ylqf4tvdn2m07xjq06se9ett9/Leonida/commit/?id=aaff77b831a5167b4b255fe92b7cde4add593b98'/>
<id>urn:sha1:aaff77b831a5167b4b255fe92b7cde4add593b98</id>
<content type='text'>
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=&lt;s&gt;: 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 &lt;noreply@anthropic.com&gt;
</content>
</entry>
</feed>
