d3d12, xmem: remap release and console heap mirror only on request (RT-GEOMETRY-REMAP-AND-HEAP-MIRROR-OPT-IN) #2356
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!2356
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2356"
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?
@aslan2142 on GitHub · 2026-11-26 15:06 UTC · original
aslan2142:geometry-remap-release-opt-in→main· +74 −23 · 9 files · 3 commits · merged 2026-11-26 15:30 UTCFixes two regressions that #2350 brought in. Since then, a world run loses the device within about a minute. Both features responsible are now off unless asked for:
LEONIDA_GEOMETRY_REMAP_RELEASE=1turns on retiring geometry copies when pages are remapped.LEONIDA_HEAP_MIRROR=1turns on the host-RAM mirror of a console heap's copy.Claimed in the coordination issue as: RT-GEOMETRY-REMAP-AND-HEAP-MIRROR-OPT-IN
What regressed
World runs on merged
main(RX 7900 XTX, RADV, Wine, the same settings otherwise):evicted 0and no fault.Why: remap release
36771ec53) made a remap of physical pages (XMemMapPhysicalPageswith pages, the scatter call,CopyPageMappingsBatchX) retire the geometry copies over every page that gets another frame.d3d12_com.cpp,GraphicsCommandList::address). A list recorded before the retirement but executed in anExecuteCommandListsthat starts after it is not one of the replayskAfterExecuteswaits for, so it reads the freed copy.Why: heap mirror
746059011) is what the filtered release sweep (LEONIDA_CONSOLE_RELEASE_FILTER=1) reads to decide which V# slots still name a released buffer.write()andzero(). I found no write that bypasses them.LEONIDA_HEAP_MIRROR=1 LEONIDA_HEAP_MIRROR_CHECK=1, which logs every slot where the mirror and the copy differ.The fix
remap_releases_enabled()inxmem.cppreturns true only whenLEONIDA_GEOMETRY_REMAP_RELEASEis1. The value is read once, and a test seam,rt::xmem::reload_remap_release_setting(), reads it again. With it off, copies follow the new pages through the refresh, as they did before #2350. Freeing, decommitting and unmapping pages still retire copies.heap_mirror_enabled()ind3d12_vulkan_device.cppreturns true only whenLEONIDA_HEAP_MIRRORis1. With it off, the sweep reads the copy itself, as it did before the mirror.runtime/README.md,docs/d3d12_vulkan.mdandsrc/console_heap_copy.hgive both defaults and why.Tests
xmem_test(test_remap_releases): a remap releases nothing when the variable is unset or0; the existing checks run with1.d3d12_console_heap_mirror_testexpects a mirror only withLEONIDA_HEAP_MIRROR=1:d3d12_console_heap_mirrorsets1, withLEONIDA_HEAP_MIRROR_CHECK=1.d3d12_console_heap_mirror_offsets0.d3d12_console_heap_mirror_default, with the variable unset.main's runtime, the new default checks in both tests fail.cteston llvmpipe: 112/112 pass.main:d3d12_console_heap_mirror_default, which passes.xmem_test, whichmainpassed twice. Reading the value once fixed that: two full runs since with no change.tests/test_docs_env_vars.py,tests/test_ci_registration.pyandscripts/check_no_game_data.pyon the changed files: pass.Not tested
main, which is equivalent.AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2)
GetEnvironmentVariableA at every remap ran under g_phys_mutex in every scatter call; with it, xmem_test's split race ("the reader of the views' last pages never faults or misreads") failed in two full Wine runs in a row, where main passed it twice. The value is cached as before #2350's default changed; rt::xmem::reload_remap_release_setting lets test_remap_releases switch it. Two full runs since: no change against main. Co-Authored-By: Claude Opus 5.5 <[email protected]>xmem: a remap retires geometry copies only with LEONIDA_GEOMETRY_REMAP_RELEASE=1 (RT-GEOMETRY-REMAP-RELEASE-OPT-IN)to d3d12, xmem: remap release and console heap mirror only on request (RT-GEOMETRY-REMAP-AND-HEAP-MIRROR-OPT-IN)@HasiKe on GitHub · 2026-11-26 18:51 UTC · original
Measured on NVIDIA after this merged: with both switches unset (the new defaults), the title crashes on the CPU at 80-160 s on an RTX 2070 SUPER (616.56), in 4 of 5 boots. With
LEONIDA_GEOMETRY_REMAP_RELEASE=1it crashes in 1 of 3, and with both set to1in 0 of 3. The bisect and the tables are in #1608: #1608 (my latest finding there). AI-assisted (Claude Code).