<feed xmlns='http://www.w3.org/2005/Atom'>
<title>npub1w4dsu3e6hzjehh7l3c9njhtwwtgk9g209ylqf4tvdn2m07xjq06se9ett9/Leonida/runtime/src/memory_breakdown.h, branch ci/exclude-legacy-cpp-runtime-tests</title>
<subtitle>[no description]</subtitle>
<id>https://upleb.uk/npub1w4dsu3e6hzjehh7l3c9njhtwwtgk9g209ylqf4tvdn2m07xjq06se9ett9/Leonida/atom?h=ci%2Fexclude-legacy-cpp-runtime-tests</id>
<link rel='self' href='https://upleb.uk/npub1w4dsu3e6hzjehh7l3c9njhtwwtgk9g209ylqf4tvdn2m07xjq06se9ett9/Leonida/atom?h=ci%2Fexclude-legacy-cpp-runtime-tests'/>
<link rel='alternate' type='text/html' href='https://upleb.uk/npub1w4dsu3e6hzjehh7l3c9njhtwwtgk9g209ylqf4tvdn2m07xjq06se9ett9/Leonida/'/>
<updated>2026-11-27T15:51:23+00:00</updated>
<entry>
<title>d3d12: eliminate orphan title windows, align mirror chunks, and speed up in-place heap filtering</title>
<updated>2026-11-27T15:51:23+00:00</updated>
<author>
<name>Jan Trencansky</name>
<email>jan.trencansky@protonmail.com</email>
</author>
<published>2026-11-27T15:51:23+00:00</published>
<link rel='alternate' type='text/html' href='https://upleb.uk/npub1w4dsu3e6hzjehh7l3c9njhtwwtgk9g209ylqf4tvdn2m07xjq06se9ett9/Leonida/commit/?id=5543ba9f5f537909156ecee0bc98e51fa476a079'/>
<id>urn:sha1:5543ba9f5f537909156ecee0bc98e51fa476a079</id>
<content type='text'>
Round 1A:
- Use VsharpPath::scratch for in-place console heaps in finish_in_place and fix_console_slot so they never allocate general-purpose title windows.
- Never fall through to make_title_window / ShadowPages in resolve_title_memory for addresses already covered by the page mirror.
- Guard vsharp_address's window-creation fallback with bytes &lt;= kTitleWindowMax so oversized V# spans cannot allocate and reject orphan windows.
- Advance &lt;= 2 GiB reservations in title_mirror_space::take past chunk boundaries so placed buffers stay within a single 2 GiB sparse chunk.
- Track arena-backed title windows and slot-133 shadows under ArenaUse::arena_window and report them in memory_breakdown.

Round 1C:
- Add re-entrancy-safe two-pass filter_heap_page_pieces() ready for TitleMirrorHooks::filter_pieces changed-piece mask.
- Reject guaranteed-unresolvable V# halves (null, unbacked bit-47, out-of-arena spans, non-title addresses without an alias) in O(1) inside filter_slot_locked without inserting into heap.records or deferring.
- Clear deferred slot records before finish_in_place and answer repeated V# halves from heap.records under page_mirror.mutex plus a per-batch dedup cache.

Tests:
- Added Linux unit tests in console_heap_slot_records_test (chunk alignment, arena window breakdown, deferred record clearing/answering).
- Added Wine regression tests in d3d12_heap_in_place_test and d3d12_page_mirror_test.

AI-assisted: Antigravity, Gemini 4 Neon
</content>
</entry>
<entry>
<title>d3d12: slot-133 buffers, title windows and pool extents onto the page mirror; GPU writes into mirrored pages go back; hot/cold tracking; homes by budget (RT-PAGE-MIRROR)</title>
<updated>2026-11-27T10:56:53+00:00</updated>
<author>
<name>Jan Trencansky</name>
<email>jan.trencansky@protonmail.com</email>
</author>
<published>2026-11-27T10:56:53+00:00</published>
<link rel='alternate' type='text/html' href='https://upleb.uk/npub1w4dsu3e6hzjehh7l3c9njhtwwtgk9g209ylqf4tvdn2m07xjq06se9ett9/Leonida/commit/?id=0cdc80d2075a7e22f24c76f4a9cfe6c0ae72f08a'/>
<id>urn:sha1:0cdc80d2075a7e22f24c76f4a9cfe6c0ae72f08a</id>
<content type='text'>
Step C, with the previous WIP commit.
- Resource::create_mirror_buffer: a slot-133 buffer over title memory the mirror holds in one chunk is bound to that
  chunk at heap_base + its title address: no import, no shadow, no per-submission walk or guard of its own. Its GPU VA
  is the title address; V#s and root views naming it keep that address. Title windows and stream-pool extents are not
  made for mirrored memory (resolve_title_memory answers the mirror first, since step B).
- Write-back (DeviceState::page_mirror_write_back, from write_back_titles after the reaching submission retired): the
  256-byte pieces whose home differs from the title's page are written back through kernel_writes, on pages nothing
  wrote since they were last armed (TitleMirrorTracking::unwritten); a page written on both sides keeps the title's
  bytes, which are uploaded over the home before the next submission. Ranges are noted (note_title_write, with its
  caps) where a V#, a writable geometry range, a title-memory resolution or a BVH range is answered by the mirror.
- The mirror's tracking is HotColdTracking (src/title_mirror_hot_cold.h); it now answers unwritten() for cold pages
  from the version its guard was armed at (an additive change to that file and to the interface, default false).
- Homes go to device-local memory while VK_EXT_memory_budget keeps 1.5 GiB (or an eighth of the budget) for the
  title's textures and render targets after a unit, to host memory otherwise, decided per 32 MiB unit and logged when
  it switches; the mirror's line and the mem-probe item count units of each kind.
- The mirror's line adds hot and cold pages, write faults, hot and cold copies, and KiB uploaded a submission and a
  frame.

Not moved: the XMemAlloc heap (HeapCreate places it). RtlCreateHeap over a reservation in the mirror's range faults
under Wine (it writes the reserved base), so it stays outside the mirror; slot-133 buffers there keep their shadows.

Tests: d3d12_page_mirror_test (Wine, iGPU): a slot-133 buffer over mirrored memory has the title's address as its GPU
VA and is no shadow; a GPU write into its home goes back to the title's page (one 256-byte piece), a page written on
both sides keeps the title's write. Linux ctest (llvmpipe) 122/122; xmem_test OK.

Co-Authored-By: Claude Opus 5.5 &lt;noreply@anthropic.com&gt;
</content>
</entry>
<entry>
<title>d3d12: geometry onto the page mirror: V#s, root views, stream-pool ranges, BVH ranges and draw bindings of mirrored title memory name heap_base + the title address, no copy (RT-PAGE-MIRROR)</title>
<updated>2026-11-27T10:25:43+00:00</updated>
<author>
<name>Jan Trencansky</name>
<email>jan.trencansky@protonmail.com</email>
</author>
<published>2026-11-27T10:25:43+00:00</published>
<link rel='alternate' type='text/html' href='https://upleb.uk/npub1w4dsu3e6hzjehh7l3c9njhtwwtgk9g209ylqf4tvdn2m07xjq06se9ett9/Leonida/commit/?id=edb0f8502f0c0fbaaa1b2f8969877203d9005735'/>
<id>urn:sha1:edb0f8502f0c0fbaaa1b2f8969877203d9005735</id>
<content type='text'>
Step B. Where the page mirror holds a title range, every reader takes the title's address as its shader VA (heap_base +
address is the mirror's chunk), so no geometry copy, pool extent or title buffer is made for it:
- vsharp_address (title memory, after the alias table: slot-133 buffers keep their shadows until step C),
  geometry_va, resolve_title_memory (before pool extents and windows), copy_title_range, make_title_buffer (vertex and
  index views), device_reachable;
- VulkanContext::buffer_at falls back to the mirror (set_mirror_buffer): a vertex, index, copy or indirect binding of a
  mirrored title address is its chunk and offset, cut at the chunk's end (counted).
Ordinary memory is mirrored when a reader first names it (page_mirror_resolve: each page its own home, watched, then
filled; at most 256 MiB not yet mirrored at once, else the old backing), and leaves on release or decommit
(geometry_writes::note_released). xmem also places the title's own VirtualAlloc reservations in the mirror's range, and
records which reservations are ordinary memory. The binds go in one batch at the end of the before-execute hook
(flush_page_mirror), after every reader of the submission has named what it reads.

The geometry copies remain only for title memory outside the mirror (the XMemAlloc heap) and on devices without the
mirror (llvmpipe). The mem-probe breakdown line has a "page mirror" item: units allocated, homes bound, pages
mirrored, chunks; the mirror's line counts ranges resolved, refused, ordinary pages mirrored and released, and
bindings cut; the console heap line counts V#s resolved into the mirror.

Not here: write-back of GPU writes into mirrored pages to the title's pages. The geometry copies these readers used
had none either (only slot-133 shadows do, and they stay until step C), so nothing is lost; the per-page rule for
pages dirty on both sides comes with step C.

Tests: d3d12_page_mirror_test (Wine, iGPU): committed XMemVirtualAlloc memory named by a constant-buffer view keeps the
title address as its V# base, the GPU reads it and a later title write there; a binding of it, and of a GPU-only pool
page, is served by the mirror's chunk; a page named on its own is mirrored. memory_breakdown_test: the new item.

Co-Authored-By: Claude Opus 5.5 &lt;noreply@anthropic.com&gt;
</content>
</entry>
<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>
