Skip to content

d3d12, xmem: remove remap release and the console heap mirror (RT-REMOVE-REMAP-RELEASE-AND-HEAP-MIRROR) - #2370

Merged
aslan2142 merged 1 commit into
ProjectLeonida:mainfrom
aslan2142:remove-remap-release-and-heap-mirror
Nov 26, 2026
Merged

aslan2142 merged 1 commit into
ProjectLeonida:mainfrom
aslan2142:remove-remap-release-and-heap-mirror

Conversation

@aslan2142

Copy link
Copy Markdown
Collaborator

Removes two features that came in with #2350 and were made opt-in by #2356 after they broke world runs.

Claimed in the coordination issue as: RT-REMOVE-REMAP-RELEASE-AND-HEAP-MIRROR

Both were additions on top of stopgap mechanisms, not fixes of the mechanisms themselves:

With both variables unset, main behaves as it did before this change.

Removed

Kept

  • LEONIDA_GEOMETRY_HOST (geometry copies in system memory, opt-in) and its memory-type assert.
  • The final copy of a retired geometry view (retire_range's final_copy, copied at retirement in the geometry buffers line). An XMemFree of a title heap block reports a release while its memory stays readable, so this copy is still made without remap release. Its comments no longer mention remaps.
  • forget_pool_span and retired with their copy. Every retirement (free, decommit, unmap) still feeds them.
  • The release queue's joining of touching ranges (title_geometry_watch.h). Unmaps report page runs too.
  • LEONIDA_CONSOLE_RELEASE_FILTER. It predates the mirror, and its sweep reads the copy again.
  • Log formats are unchanged except for the removed LEONIDA_HEAP_MIRROR_CHECK lines.

Not addressed here

The root problems behind both features need proper designs. This change does not touch them:

  • Geometry copies are made per view and kept in VRAM.
  • Descriptor heaps are fixed again by a sweep instead of by tracking each slot's writes.

Tests

  • Linux runtime build and ctest on the Ryzen 9 7950X3D iGPU (RADV RAPHAEL_MENDOCINO, Mesa 26.3.1): 111/111 pass. console_heap_copy is gone.
  • Windows suite (clang-cl + xwin cross-build) under Wine on the same iGPU and driver, compared with main 246791612: 418 pass now, 422 before. The difference is the four removed tests. No other test changed state, and xmem and geometry_views pass.
  • tests/test_ci_registration.py, test_ctest_registration.py, test_docs_env_vars.py, the other test_docs_* and CMake list tests, test_text_write_line_endings.py, compileall and check_no_game_data.py on the changed files all pass.
  • A search of the tree finds no remaining variable or helper names.

World runs

RX 7900 XTX, RADV (Mesa 26.3.1), Wine, the settings of the Linux section in docs/running.md:

Build Result
This branch (b0767fd65) Reached the world with no evictions and no GPU page fault, and took 1,900 compute pipelines from the journal. It ended in a graphics-ring timeout 366 s into the run. The breadcrumbs show all three queues idle. The cause is not known
This branch plus #2222, #2359, #2142 and #2163 merged locally 666 s with no stall, no page fault and no ring timeout. It stopped at the title's own breakpoint, where main with both features off also stops
  • One run each, so the two results do not show whether the hang is intermittent or whether one of the four PRs avoids it.
  • main with both variables unset is the same configuration as this branch, and it reached the title's breakpoint in an earlier run.

Not tested

  • No MSVC build. CI covers it.
  • llvmpipe was not run under Wine.

AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2).

Both came in with ProjectLeonida#2350 as additions on top of stopgap mechanisms, broke world runs (remap release: a GPUVM page
fault and a lost device; the mirror: a GPU hang) and were made opt-in by ProjectLeonida#2356. They go completely; with both
variables unset, main behaves as before.

Remap release (LEONIDA_GEOMETRY_REMAP_RELEASE, from 36771ec):
- xmem.cpp: RemapReleases, remap_releases_enabled() and the page recording in unmap_range_locked; the four call
  sites (XMemMapPhysicalPages, the scatter call, both copy_page_mappings).
- xmem.h/xmem.cpp: the test seam rt::xmem::reload_remap_release_setting().
- xmem_test: test_remap_releases (and the title_geometry_watch.h include only it used).
- README row, the docs/d3d12_vulkan.md paragraph; comments that named it.

Console heap mirror (LEONIDA_HEAP_MIRROR, LEONIDA_HEAP_MIRROR_CHECK, from 7460590):
- src/console_heap_copy.h goes. ConsoleHeap::copy is a plain std::uint8_t* again, written with memcpy/memset as
  before the mirror, including the zeroing site that ProjectLeonida#2350's merge of ProjectLeonida#2162 resolved as heap.copy.zero(); the
  compute-input probe reads it directly again. Without the mirror, view() was the copy itself, so nothing changes.
- heap_mirror_enabled(), heap_mirror_check_enabled(), check_console_heap_mirror(), the per-heap check counters and
  log line, and the test API console_heap_mirror_mismatches() (d3d12_com.h).
- Tests console_heap_copy, d3d12_console_heap_mirror, _off and _default with their CMake entries; README rows and
  the docs/d3d12_vulkan.md sentences.

Kept, because other paths use them or main's behaviour with the variable unset depends on them:
- LEONIDA_GEOMETRY_HOST and its DeviceState memory-type assert (dc9ef1a).
- The final copy at retirement (GeometryViews::retire_range's final_copy, "copied at retirement" in the geometry
  buffers line): XMemFree of a title heap block (free_title_block) reports a release while the block's memory stays
  committed and readable, so that copy is still made without remap release. Comments now say that instead of
  naming remaps; geometry_views_test case 15 stays.
- forget_pool_span and "retired with their copy" in the title memory line: any retirement (free, decommit, unmap)
  feeds it.
- The release queue's joining of touching ranges (title_geometry_watch.h): unmaps report page runs too;
  geometry_views_test case 16 stays.
- LEONIDA_CONSOLE_RELEASE_FILTER, which predates the mirror; its sweep reads the copy again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aslan2142

Copy link
Copy Markdown
Collaborator Author

Merging. This is a self-merge.

AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2)

@aslan2142
aslan2142 merged commit 56bdd7e into ProjectLeonida:main Nov 26, 2026
2 of 5 checks passed
DadaCap added a commit to DadaCap/leonida that referenced this pull request Nov 26, 2026
… mirror test (ProjectLeonida#2370); the shadow_keep test stays

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gt9hwNPurxyJ9LAfUbNiYr
Kokonotcu added a commit to Kokonotcu/leonida that referenced this pull request Nov 26, 2026
…our game-save packing kept

- XDXR builder: upstream's update source check (MODE_CHECK, FLAG_IF_REFIT / FLAG_IF_BUILD) and vertex_count with
  our FLAG_PAGED and dispatch base: flags paged 8, translate 16, if_refit 32, if_build 64; the push block holds both
  sides' last word (vertex_count, base: 112 bytes, xdxr_build.h and .comp in the same order); xdxr_build.inc
  regenerated with glslc --target-env=vulkan1.2 -O -mfmt=c.
- xmem: upstream dropped RemapReleases; our PhysLock stays.
- Game saves: ours. Upstream's aligned blob packing (ProjectLeonida#2359) made the retail title assert at 0x1455AA5EB and fault on
  a string read as a pointer a few seconds into the boot; with our packing it boots to the loading screen as before.
- Tests: upstream removed the console heap mirror test (ProjectLeonida#2370); its shadow-keep refill tests are added.
- Console queues: one line per queue made (the retail title makes 1 direct, 4 compute and 1 copy queue) and per
  queue its executes at powers of two, to place the chained lists against the queues the title uses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant