Geometry copies held 4.4-6 GB of VRAM in world runs and were never evicted: a view retired only when its range was
freed, decommitted or unmapped, and the title streams by remapping the frames of its pools.
- LEONIDA_GEOMETRY_HOST (unset by default): 1 puts the copies in system memory outside VRAM, write-back where the
device offers a cached host type; 2 write-combined. The memory type is picked among the host-visible types that are
not device-local (memory_type_order alone would give the BAR first); a device with none keeps its types. Logged once
and in the geometry buffers line.
- LEONIDA_GEOMETRY_REMAP_RELEASE (on by default, 0 off): XMemMapPhysicalPages with pages, the scatter call and
CopyPageMappingsBatchX report the pages whose frame changed (or went) as released (xmem's RemapReleases, collected
under the fault lock, reported after it), so GeometryViews retires the copies over them through #2094's
drain_released and kAfterExecutes reaping. A page mapped again to its own frame is no change.
- A retired view is copied once more from its pages when they are readable: a list recorded before a remap that took
the view's address reads the new bytes, as the refresh this replaces would have given it.
- A stream-pool extent backed by a retired copy leaves pool_spans (it was kept for the device's life).
- A full release queue joins touching ranges before it collapses into one covering range.
Tests: geometry_views_test cases 14-16, xmem_test test_remap_releases.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
geometry_views_test case 13 runs DeviceState's order for one submission with
an idle GPU (completed == submitted): execute_begin, the drain at
kAfterExecutes in before_execute_, the replay records its ticket, execute_end.
Another queue's replay began before the release and one more begins after
the retirement. It checks that
- the drain retires the view but does not reap it (a ticket read in the drain
reaped it in the same call),
- the view waits until every replay begun before the retirement recorded its
submission, then for the last of their tickets, and not for the later replay,
- the retirement invalidates answers made without an alias (forget_copy:
changed_ranges, invalidations, take_removed),
- the destroyed block leaves for_each_block, changes layout_generation and is
reported to the device (title_block_gone).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Since #2098 every TitleBufferWindows carries a 128 KiB published_ array, so the
eight GeometryViews this test puts on the stack pass the 1 MiB Windows default
and the test died at startup with a stack overflow. They are heap-allocated now.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
leonida::geometry_writes previously kept one process-wide release queue, so when two devices held GeometryViews over the same title range, the first device to call drain_released() emptied the queue and the second kept its view and charged bytes forever.
Give each GeometryViews its own ReleaseQueue subscribed to leonida::geometry_writes on construction and unsubscribed on destruction. note_released() delivers each released range to every subscriber's queue under subscribers_mutex -> queue.mutex (keeping the 65536-entry collapse per queue), and take_released() drains only the caller's queue under queue.mutex.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Drain released geometry ranges only in the submit-thread before_execute callback, removing recording-thread drain calls and GeometryViews::should_reclaim().
- Filter geometry_writes::note_released() against monotonic watched_lo/watched_hi bounds and collapse the queue on 65536-entry overflow instead of dropping ranges.
- Bound GeometryViews::retire_range() walks using max_view_bytes_ and an ordered refused_ map with max_refused_bytes_.
- Keep one empty 4 MiB spare block in TitleBufferWindows (dropping it when needed under a cap), remove failed_ reset in free(), and cover all four points in geometry_views_test.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RT-GEOMETRY-VIEW-EVICTION: free GeometryViews entries when their backing
title range is released or unmapped, deferring Vulkan storage reclamation
until in-flight GPU work completes, and retry cap-refused ranges once
budget is freed.
- Queue released title ranges from xmem (XMemFree/Default, VirtualFree
MEM_RELEASE/MEM_DECOMMIT, XMemMapPhysicalPages unmap, CopyPageMappingsBatchX
unmap range) via leonida::geometry_writes::note_released.
- Add coalesced sub-range freeing and empty-block Vulkan destruction to
TitleBufferWindows.
- Retire overlapping views immediately from lookup/find/refresh/watch and
title_va_aliases, and reap their backing storage once
completed_retire_ticket() reaches the view's retire ticket.
- Track free_generation_ per refused key so resolve() short-circuits while
nothing changed and retries once budget is reclaimed.
- Extend geometry_views_test.cpp with small-cap eviction, deferred GPU
retirement, retry, and full block reclamation checks.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Preserve physical window aliases across remaps, order console list values,
and replay bounded indirect graphics with captured draw state. Coordinate
pipeline lifetime, texture refresh and queue teardown. Add synthetic CPU
and GPU coverage for the integrated paths.
Co-authored-by: Plaaasma <47513553+Plaaasma@users.noreply.github.com>
Co-authored-by: ivanepsilondelta <264061546+ivanepsilondelta@users.noreply.github.com>