mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:45:54 +01:00
[PR #2094] [MERGED] d3d12: evict geometry views on range release and retry refused ranges #2100
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#2100
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/2094
Author: @qhukz13
Created: 11/25/2026
Status: ✅ Merged
Merged: 11/26/2026
Merged by: @aslan2142
Base:
main← Head:cont/geometry-view-eviction📝 Commits (9)
e54c691d3d12: evict geometry views on range release and retry refused rangesc09ee75d3d12: geometry views drain on the submit thread, bound the release queue, keep one empty block6fd430ed3d12: deliver a released title range to every device's geometry views7d38eeeMerge main into RT-GEOMETRY-VIEW-EVICTION861bb05d3d12: reap a retired geometry view only after the replays that may name it266f335d3d12: a retired geometry view invalidates the answers it made without an aliasb21b47bd3d12: no table keeps naming a destroyed title-window block702fbaatest: keep geometry_views_test's GeometryViews off the stackbbc8ef1test: geometry views across a submission's replays, invalidation and block removal📊 Changes
8 files changed (+1083 additions, -107 deletions)
View changed files
📝
runtime/shims/d3d12_geometry_views.h(+397 -66)📝
runtime/shims/d3d12_title_buffer_windows.h(+147 -31)📝
runtime/shims/d3d12_vulkan_device.cpp(+58 -4)📝
runtime/shims/xmem.cpp(+26 -3)📝
runtime/src/title_geometry_watch.h(+80 -0)📝
runtime/src/title_va_alias.h(+13 -0)📝
runtime/src/vulkan_backend.h(+10 -0)📝
runtime/test/geometry_views_test.cpp(+352 -3)📄 Description
Item:
RT-GEOMETRY-VIEW-EVICTIONProblem
runtime/shims/d3d12_geometry_views.h: onceLEONIDA_GEOMETRY_MBis used up,resolve()marks a range refused for good, and no view is freed before teardown, even after the title releases the memory it copies.Change
xmemreports title ranges that go away:XMemFree/XMemFreeDefault,VirtualFreeMEM_RELEASE/MEM_DECOMMIT, theXMemMapPhysicalPagesunmap and theCopyPageMappingsBatchXunmap range. They go to a small queue intitle_geometry_watch.h(note_released/take_released). Ranges outside every watched tile are not queued; a GPU-only range counts through its CPU view, where the views are keyed. When the queue is full it collapses into one covering range: retiring a few views too many is harmless (they are made again on the next resolve), dropping a release is not.before_execute_, before the geometry refresh) a released range retires every view over it at once: it leaveskeys_, the address map, the fast lookup, the tile watches and the title VA aliases. Its storage is freed only oncecompleted_retire_ticket()passes thesubmitted_retire_ticket()taken at retirement, so in-flight work keeps reading valid memory. The recording threads never drain, so they do not wait onGeometryViews::mutex_while a refresh holds it (speed-26).resolve()answers it from the fast map without a lock while nothing was freed, and tries again once a reap has returned budget.TitleBufferWindowskeeps coalesced free ranges per block, destroys a block when its last range comes back, and keeps one empty 4 MiB block as a spare (dropped when a larger request needs the cap), so a title that frees and reallocates each frame does not allocate Vulkan memory each frame. The 2 s backoff after a driver refusal is kept.refresh()walks the tiles by key (lower_bound) instead of holding astd::mapiterator and rawTile*across its periodic unlock, because a retirement can now erase a tile in that window.Nothing changes while under the cap, and with
LEONIDA_GEOMETRY_MB=0(default)note_releasedreturns on one atomic load.Testing
Windows 10 Pro 19045, GeForce GTX 1050 Ti (Pascal, 4 GB, no Resizable BAR), NVIDIA 582.66, MSVC (VS 18 Build Tools), RelWithDebInfo, base
9f9a7c5f3.geometry_views_test(extended: small cap, refusal and retry, deferred reap before/at the ticket, block reclamation, watched-bounds filter, GPU-only twin, queue overflow, spare block): 51 checks, 3/3 passes.9f9a7c5f3(16 failures there); the other three ared3d12_computeandd3d12_geometry_views, which #2059 fixes, andxmem, which is flaky on this host (5/5 on rerun, also without this branch). No test that passes on main fails here.LEONIDA_VK_VALIDATION=1:geometry_views,xmem*,d3d12_title_va*,d3d12_geometry_views,d3d12_title_window_cap,d3d12_api_descriptor_copy*,d3d12_rebound*,d3d12_compute,d3d12_xmem_placed: 17/17 pass, no validation messages.d3d12_geometry_viewsonly reaches the geometry code with #2059 (root signature serialization); the integration numbers above were taken with #2059 applied locally.AI-assisted (Claude Code, Opus 5.5, with Antigravity / Gemini 4 Neon for the first draft of the code; every change reviewed and the GPU-only filter case fixed by hand).
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.