d3d12: slot-133 shadows guard aliased title pages at every address instead of copying them each submission (RT-SHADOW-ALIAS-GUARD) #1867

Manually merged
github merged 1 commit from github-bot/gh-1867 into main 2026-11-27 00:35:17 +00:00 AGit
Owner

@⁠azsekazvamdimitar on GitHub · 2026-11-25 13:41 UTC · original
azsekazvamdimitar:shadow-aliased-guard → main · +326 −45 · 5 files · 3 commits · merged 2026-11-26 22:35 UTC

Claimed in the coordination issue as: RT-SHADOW-ALIAS-GUARD (#1608)

What and why

The slot-133 shadows and title windows (ShadowPages, runtime/shims/d3d12_vulkan_device.cpp) never guarded a page xmem maps at more than one address (title_page_aliases): a guard on one view doesn't fault a write through the other, so every refresh copied those pages whole. After the story load the stream pools make that the bulk of each submission. On my retail boot (main 0d80bc5df, RTX 3090, GE-Proton, LEONIDA_TITLE_WATCHDOG=0) the by-cause line read about 987 MB aliased, 7 MB guarded and 2.4 MB pinned a submission, about 300 ms of each one, and the title presented about 0.3 frames a second. LEONIDA_SHADOW_ALIAS_MS can only make those copies older.

This guards the aliased blocks at every address instead, with the geometry watch's cells (runtime/src/title_geometry_watch.h), which the geometry views already use for the same problem:

  • ShadowPages::update_aliased, at the start of refresh() and outside the tracker's lock, acquires a cell for each aliased 64 KiB block the copies read, at its own address and at each other address geometry_aliases names, and arms them (read-only at every address). A block whose cells kept their versions since they were armed is skipped by the walk; any other is armed again before the walk copies it, so a write after the arming is copied at the next refresh. A write through any address faults into shadow_write_fault, which already notifies the geometry watch first; a remap, commit or protection change moves a cell's version too.
  • A block is still copied every time when no other address is known (no xmem), when a page is pinned for a kernel write (arm refuses it), and in the refreshes LEONIDA_SHADOW_ALIAS_MS throttles.
  • xmem: note_mapping now tells the cells of a mapping change after it updated the peers, so a watcher that sees the new mapping gets the new addresses; write_title_bytes (list value writes, through the section rather than the title's views) notifies the geometry watch, since no fault tells a guard of those writes.

The same retail boot, after the story load:

main 0d80bc5df main, LEONIDA_SHADOW_ALIAS_MS=3600000 (aliased pages copied once: stale, an upper bound) this pull request (on 98c2f7777)
aliased copies a submission ~987 MB 0 2.3-5 MB
shadow refresh a submission ~300 ms 12-130 ms 23-150 ms
frames a second ~0.3 0.6-11 1.1-9

All three runs end in the same world-start device loss, about 180-220 s after the story load starts (queue waits on memory nothing wrote, indirect draws not emitted, then VK_ERROR_DEVICE_LOST). This pull request doesn't change that; it makes the loading screen run at a usable rate up to that point. No frames were captured that show a visible difference.

Tested

  • d3d12_existing_heap_test gains check_aliased_guard: one page mapped at A and B (the test answers geometry_writes::aliases) is read-only at both addresses between submissions, a write through an unreported third view stays stale (nothing was copied), a write through B faults and arrives with it, and both addresses are writable again after the shadow is released. The existing check_aliased_write, which has no other address to arm, still copies every time and passes.
  • On this branch (rebased on main a73a57e13), cross-built with clang-cl and run under WineHQ 11.22 (winewayland) and GE-Proton11-14 (winex11): d3d12_existing_heap, d3d12_existing_heap_no_write_watch, d3d12_existing_heap_write_watch, d3d12_xmem_placed, d3d12_title_va, d3d12_title_va_shadow and xs_proxy_mock pass under both.
  • xmem fails one check, "writing to 512 of them charges about those 512 pages", under Wine; it fails the same way on main without this change.
  • The boot numbers above are from the same change on 98c2f7777. Not run on Windows.

GPUs tested: NVIDIA GeForce RTX 3090, driver 590.48.01, Debian 13 (Linux 6.12), Wine/Proton as above.

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.
**@⁠azsekazvamdimitar** on GitHub · 2026-11-25 13:41 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1867) `azsekazvamdimitar:shadow-aliased-guard` → `main` · +326 −45 · 5 files · 3 commits · merged 2026-11-26 22:35 UTC Claimed in the coordination issue as: RT-SHADOW-ALIAS-GUARD (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) ### What and why The slot-133 shadows and title windows (`ShadowPages`, `runtime/shims/d3d12_vulkan_device.cpp`) never guarded a page xmem maps at more than one address (`title_page_aliases`): a guard on one view doesn't fault a write through the other, so every refresh copied those pages whole. After the story load the stream pools make that the bulk of each submission. On my retail boot (main 0d80bc5df, RTX 3090, GE-Proton, `LEONIDA_TITLE_WATCHDOG=0`) the by-cause line read about 987 MB aliased, 7 MB guarded and 2.4 MB pinned a submission, about 300 ms of each one, and the title presented about 0.3 frames a second. `LEONIDA_SHADOW_ALIAS_MS` can only make those copies older. This guards the aliased blocks at every address instead, with the geometry watch's cells (`runtime/src/title_geometry_watch.h`), which the geometry views already use for the same problem: - `ShadowPages::update_aliased`, at the start of `refresh()` and outside the tracker's lock, acquires a cell for each aliased 64 KiB block the copies read, at its own address and at each other address `geometry_aliases` names, and arms them (read-only at every address). A block whose cells kept their versions since they were armed is skipped by the walk; any other is armed again before the walk copies it, so a write after the arming is copied at the next refresh. A write through any address faults into `shadow_write_fault`, which already notifies the geometry watch first; a remap, commit or protection change moves a cell's version too. - A block is still copied every time when no other address is known (no xmem), when a page is pinned for a kernel write (`arm` refuses it), and in the refreshes `LEONIDA_SHADOW_ALIAS_MS` throttles. - xmem: `note_mapping` now tells the cells of a mapping change after it updated the peers, so a watcher that sees the new mapping gets the new addresses; `write_title_bytes` (list value writes, through the section rather than the title's views) notifies the geometry watch, since no fault tells a guard of those writes. The same retail boot, after the story load: | | main 0d80bc5df | main, `LEONIDA_SHADOW_ALIAS_MS=3600000` (aliased pages copied once: stale, an upper bound) | this pull request (on 98c2f7777) | |---|---|---|---| | aliased copies a submission | ~987 MB | 0 | 2.3-5 MB | | shadow refresh a submission | ~300 ms | 12-130 ms | 23-150 ms | | frames a second | ~0.3 | 0.6-11 | 1.1-9 | All three runs end in the same world-start device loss, about 180-220 s after the story load starts (queue waits on memory nothing wrote, indirect draws not emitted, then `VK_ERROR_DEVICE_LOST`). This pull request doesn't change that; it makes the loading screen run at a usable rate up to that point. No frames were captured that show a visible difference. ### Tested - `d3d12_existing_heap_test` gains `check_aliased_guard`: one page mapped at A and B (the test answers `geometry_writes::aliases`) is read-only at both addresses between submissions, a write through an unreported third view stays stale (nothing was copied), a write through B faults and arrives with it, and both addresses are writable again after the shadow is released. The existing `check_aliased_write`, which has no other address to arm, still copies every time and passes. - On this branch (rebased on main a73a57e13), cross-built with clang-cl and run under WineHQ 11.22 (winewayland) and GE-Proton11-14 (winex11): `d3d12_existing_heap`, `d3d12_existing_heap_no_write_watch`, `d3d12_existing_heap_write_watch`, `d3d12_xmem_placed`, `d3d12_title_va`, `d3d12_title_va_shadow` and `xs_proxy_mock` pass under both. - `xmem` fails one check, "writing to 512 of them charges about those 512 pages", under Wine; it fails the same way on main without this change. - The boot numbers above are from the same change on 98c2f7777. Not run on Windows. GPUs tested: NVIDIA GeForce RTX 3090, driver 590.48.01, Debian 13 (Linux 6.12), Wine/Proton as above. AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed.
A page xmem maps at two addresses was copied whole at every refresh, since
a guard on one view doesn't fault a write through the other: about 1 GB a
submission after the story load on a retail boot. ShadowPages now arms the
geometry watch's cells of each aliased 64 KiB block at every address it is
mapped and copies a block only when a cell's version moved. xmem tells the
cells of a mapping change after updating the peers, and of list value
writes made through the section.

AI-assisted; tested under WineHQ 11.22 and GE-Proton11-14 on an RTX 3090
(NVIDIA 590.48.01).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:09:20 +00:00
Author
Owner

@⁠Timon360SB on GitHub · 2026-11-25 15:30 UTC · original

Independent verification — Turing and Blackwell

  • Base: 5e95fa2f46d5df1a8397d5ee871add369031d8b6
  • Head: 3124ca8e495a02585fc8f952f833bc4ee4c1802e

Environment

GPU Windows 11 build
RTX 5070 (Blackwell) 26200
RTX 2060 SUPER (Turing) 28000

NVIDIA 621.14, Vulkan SDK 1.4.363.0,
MSVC 19.44.35230, Ninja RelWithDebInfo.

Three repetitions per GPU, revision and validation mode.

Results

Test Base Head
d3d12_existing_heap 12/12 12/12
d3d12_existing_heap_no_write_watch 12/12 12/12
d3d12_existing_heap_write_watch 12/12 12/12
d3d12_xmem_placed 12/12 12/12
d3d12_title_va 12/12 12/12
d3d12_title_va_shadow 12/12 12/12
xs_proxy_mock 12/12 12/12
xmem 12/12 12/12
Total 96/96 96/96

192 executions: 192 passed, 0 failed, 0 skipped.

Findings

  • The new check_aliased_guard fixture passed all
    36 executions across the three existing-heap variants.
  • Both registered views were protected between submissions.
    The unreported-view control produced the expected stale
    byte at offset 69632; writing through B correctly
    propagated the updated data.
  • Concurrent-write and heap-lock stress checks passed
    without deadlocks, with correct final readbacks.
  • XMem reported 480 successful checks in every execution.
  • No VUID diagnostics in the captured logs.
    Validation-layer feature-adjustment warnings were present.

No regressions observed. The new alias-guard mechanism
is independently verified under native Windows/MSVC
on both systems.

Retail workloads and comparative performance
measurements were not included.

Synthetic tests only. No game files used.
AI-assisted: yes.

**@⁠Timon360SB** on GitHub · 2026-11-25 15:30 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1867#issuecomment-7166939773) ## Independent verification — Turing and Blackwell - **Base:** `5e95fa2f46d5df1a8397d5ee871add369031d8b6` - **Head:** `3124ca8e495a02585fc8f952f833bc4ee4c1802e` ### Environment | GPU | Windows 11 build | |---|---| | RTX 5070 (Blackwell) | 26200 | | RTX 2060 SUPER (Turing) | 28000 | NVIDIA 621.14, Vulkan SDK 1.4.363.0, MSVC 19.44.35230, Ninja RelWithDebInfo. Three repetitions per GPU, revision and validation mode. ### Results | Test | Base | Head | |---|---:|---:| | `d3d12_existing_heap` | 12/12 | 12/12 | | `d3d12_existing_heap_no_write_watch` | 12/12 | 12/12 | | `d3d12_existing_heap_write_watch` | 12/12 | 12/12 | | `d3d12_xmem_placed` | 12/12 | 12/12 | | `d3d12_title_va` | 12/12 | 12/12 | | `d3d12_title_va_shadow` | 12/12 | 12/12 | | `xs_proxy_mock` | 12/12 | 12/12 | | `xmem` | 12/12 | 12/12 | | **Total** | **96/96** | **96/96** | 192 executions: 192 passed, 0 failed, 0 skipped. ### Findings - The new `check_aliased_guard` fixture passed all 36 executions across the three existing-heap variants. - Both registered views were protected between submissions. The unreported-view control produced the expected stale byte at offset 69632; writing through B correctly propagated the updated data. - Concurrent-write and heap-lock stress checks passed without deadlocks, with correct final readbacks. - XMem reported 480 successful checks in every execution. - No VUID diagnostics in the captured logs. Validation-layer feature-adjustment warnings were present. No regressions observed. The new alias-guard mechanism is independently verified under native Windows/MSVC on both systems. Retail workloads and comparative performance measurements were not included. Synthetic tests only. No game files used. AI-assisted: yes.
Author
Owner

@⁠DadaCap on GitHub · 2026-11-25 17:15 UTC · original

@⁠azsekazvamdimitar thank you. I have the same numbers from a local version of the same idea: 1.1 GB aliased before every submission down to 15 MB, shadow phase 173 ms to 6 to 40 ms, 17,939 of 18,226 tiles settled (RTX 5080, Windows 11, 4 GiB window cap). Yours is claimed, so I will not open mine. Some points from building and reviewing it that may help #1867, from reading your diff (not run):

  • a limit on how many blocks are armed per refresh (mine: 512): with ~18,000 blocks the first refreshes otherwise do a great many VirtualProtect calls;
  • a backoff for a block written every frame, which else re-arms and faults every refresh;
  • an early return for a tracker with nothing moved (1,600 trackers here);
  • the OVERLAPPED structure of a pending read pinned like its buffer, and mapped textures' section pointers: writes through those fault no guard;
  • a check mode was worth having: re-comparing 256 settled blocks a submission found 0 missed writes and four places where the GPU had written into a copy (those are no longer rewritten every submission, which is a change of behaviour).

I can't say which of these matter on your machine. If a retail run of #1867 on this card would help, say so. AI-assisted (Claude Code).

**@⁠DadaCap** on GitHub · 2026-11-25 17:15 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1867#issuecomment-7169229254) @⁠azsekazvamdimitar thank you. I have the same numbers from a local version of the same idea: 1.1 GB aliased before every submission down to 15 MB, shadow phase 173 ms to 6 to 40 ms, 17,939 of 18,226 tiles settled (RTX 5080, Windows 11, 4 GiB window cap). Yours is claimed, so I will not open mine. Some points from building and reviewing it that may help #1867, from reading your diff (not run): - a limit on how many blocks are armed per refresh (mine: 512): with ~18,000 blocks the first refreshes otherwise do a great many `VirtualProtect` calls; - a backoff for a block written every frame, which else re-arms and faults every refresh; - an early return for a tracker with nothing moved (1,600 trackers here); - the OVERLAPPED structure of a pending read pinned like its buffer, and mapped textures' section pointers: writes through those fault no guard; - a check mode was worth having: re-comparing 256 settled blocks a submission found **0 missed writes** and four places where the GPU had written into a copy (those are no longer rewritten every submission, which is a change of behaviour). I can't say which of these matter on your machine. If a retail run of #1867 on this card would help, say so. AI-assisted (Claude Code).
Author
Owner

@⁠MoonEyes on GitHub · 2026-11-25 18:15 UTC · original

Independent test run: Windows 11, RTX 4060

Head 3124ca8e4, compared with its merge base 5e95fa2f4 (main when the pull request was opened). Main was at b9320a118 when I checked, 60 commits after that base; GitHub reports the pull request as mergeable. I did not build or run the merge.

Setup

  • Windows 11 Pro 26300, NVIDIA RTX 4060, driver 610.88, Vulkan SDK 1.4.363.0
  • MSVC 19.44, Ninja, RelWithDebInfo, -DLEONIDA_REQUIRE_VULKAN=ON
  • 16 test targets built, 34 tests selected with ctest -R "title|shadow|alias|existing_heap|xmem|xs_proxy_mock|geometry"
  • The machine was shared with another CPU-bound job for part of the session. I did not log the load, so I cannot say which runs it affected.

Results

Base 5e95fa2f4 Head 3124ca8e4, run 1 Head, run 2
34 selected tests 34/34 30/34 33/34
the 30 other than xs_proxy_mock, xmem, xmem_no_write_watch, xmem_write_watch 30/30 30/30 30/30
d3d12_existing_heap, _no_write_watch, _write_watch 3/3 3/3 3/3

check_aliased_guard on head prints protection 0x2 at A and at B between submissions.

The failures on head are xs_proxy_mock (both runs) and the three xmem variants (run 1 only).

  • xs_proxy_mock: in the runs I kept logs of, head failed 7 of 7 and base passed its one run. The failing check is g_tear.torn == 0 && g_tear.reads > 0 (line 4487), after a 200,000-store loop racing a reader thread. xs_proxy_mock_test does not compile xmem.cpp or d3d12_vulkan_device.cpp; the only changed file it sees is a comment in title_page_watch.h. So I see no way for the change to cause it, but my logs do not show base failing, and the runs Timon360SB posted above pass 12 of 12 on both revisions. Treat it as unexplained on this machine.
  • xmem: the check that failed in run 1 on all three variants is the reader of the views' last pages never faults or misreads. Base and head binaries run in turn, 16 runs each, with the counters of the reader printed: base passed 12, head passed 11. None of those failures was the reader check; they were the system-commit checks (writing to 512 of them charges about those 512 pages, and once on base mapping them does not charge them). wrong was 0 in all 32 runs, and the read count went as low as 1 and 2 on head, so that check is one scheduling slip from failing with no misread. Over all logged xmem runs head failed 8 of 31 and base 4 of 34, but the runs outside the 16-and-16 set were not made under the same conditions, so I cannot call that a difference.

So: no regression in the 30 other tests, xmem fails on both revisions here, and an xs_proxy_mock failure on head that I cannot explain and cannot tie to the change.

Mutation

The d3d12_existing_heap_test.cpp of the pull request, built against the base versions of d3d12_vulkan_device.cpp, xmem.cpp and title_page_watch.h: all three variants fail, at the new check.

vulkan slot-133 aliased page, guarded line 851: (at_a & 0xff) == PAGE_READONLY
0% tests passed, 3 tests failed out of 3

The new test does fail without the change. The mutation was against the merge base, not current main, whose copy of the test file has moved on.

In game (measured by OreoFR in game, not by me)

RTX 4070 Laptop 8 GB, driver 621.40, main + #1849 + a local texture pass. At 140 s:

without this pull request with it
frames a second 19 40.8
memory copies 18 ms 10.5 ms
submissions a second not given 81

The wall at about 222 s is still there. I did not run the game and have not reproduced these numbers.

AI-assisted: yes (Claude Code built and ran the tests)

**@⁠MoonEyes** on GitHub · 2026-11-25 18:15 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1867#issuecomment-7170653211) ## Independent test run: Windows 11, RTX 4060 Head `3124ca8e4`, compared with its merge base `5e95fa2f4` (main when the pull request was opened). Main was at `b9320a118` when I checked, 60 commits after that base; GitHub reports the pull request as mergeable. I did not build or run the merge. ### Setup - Windows 11 Pro 26300, NVIDIA RTX 4060, driver 610.88, Vulkan SDK 1.4.363.0 - MSVC 19.44, Ninja, RelWithDebInfo, `-DLEONIDA_REQUIRE_VULKAN=ON` - 16 test targets built, 34 tests selected with `ctest -R "title|shadow|alias|existing_heap|xmem|xs_proxy_mock|geometry"` - The machine was shared with another CPU-bound job for part of the session. I did not log the load, so I cannot say which runs it affected. ### Results | | Base `5e95fa2f4` | Head `3124ca8e4`, run 1 | Head, run 2 | |---|---|---|---| | 34 selected tests | 34/34 | 30/34 | 33/34 | | the 30 other than `xs_proxy_mock`, `xmem`, `xmem_no_write_watch`, `xmem_write_watch` | 30/30 | 30/30 | 30/30 | | `d3d12_existing_heap`, `_no_write_watch`, `_write_watch` | 3/3 | 3/3 | 3/3 | `check_aliased_guard` on head prints protection `0x2` at A and at B between submissions. The failures on head are `xs_proxy_mock` (both runs) and the three `xmem` variants (run 1 only). - `xs_proxy_mock`: in the runs I kept logs of, head failed 7 of 7 and base passed its one run. The failing check is `g_tear.torn == 0 && g_tear.reads > 0` (line 4487), after a 200,000-store loop racing a reader thread. `xs_proxy_mock_test` does not compile `xmem.cpp` or `d3d12_vulkan_device.cpp`; the only changed file it sees is a comment in `title_page_watch.h`. So I see no way for the change to cause it, but my logs do not show base failing, and the runs Timon360SB posted above pass 12 of 12 on both revisions. Treat it as unexplained on this machine. - `xmem`: the check that failed in run 1 on all three variants is `the reader of the views' last pages never faults or misreads`. Base and head binaries run in turn, 16 runs each, with the counters of the reader printed: base passed 12, head passed 11. None of those failures was the reader check; they were the system-commit checks (`writing to 512 of them charges about those 512 pages`, and once on base `mapping them does not charge them`). `wrong` was 0 in all 32 runs, and the read count went as low as 1 and 2 on head, so that check is one scheduling slip from failing with no misread. Over all logged `xmem` runs head failed 8 of 31 and base 4 of 34, but the runs outside the 16-and-16 set were not made under the same conditions, so I cannot call that a difference. So: no regression in the 30 other tests, `xmem` fails on both revisions here, and an `xs_proxy_mock` failure on head that I cannot explain and cannot tie to the change. ### Mutation The `d3d12_existing_heap_test.cpp` of the pull request, built against the base versions of `d3d12_vulkan_device.cpp`, `xmem.cpp` and `title_page_watch.h`: all three variants fail, at the new check. vulkan slot-133 aliased page, guarded line 851: (at_a & 0xff) == PAGE_READONLY 0% tests passed, 3 tests failed out of 3 The new test does fail without the change. The mutation was against the merge base, not current main, whose copy of the test file has moved on. ### In game (measured by OreoFR in game, not by me) RTX 4070 Laptop 8 GB, driver 621.40, main + #1849 + a local texture pass. At 140 s: | | without this pull request | with it | |---|---|---| | frames a second | 19 | 40.8 | | memory copies | 18 ms | 10.5 ms | | submissions a second | not given | 81 | The wall at about 222 s is still there. I did not run the game and have not reproduced these numbers. AI-assisted: yes (Claude Code built and ran the tests)
Author
Owner

@⁠x2Tweek on GitHub · 2026-11-25 18:39 UTC · original

Measured on Windows 11 with an NVIDIA RTX 5090 (driver 32.0.16.2124), retail boot, runtime at the #1723 integration point with and without this PR, same settings and the same scripted input for both runs, read from the [rt] submit phases and slot-133 shadow copies by cause lines at the opening credits:

main main + #1867
aliased pages copied per submission ~1.3 GiB ~6-20 MiB
shadows phase per submission 285-330 ms 1-3 ms
frames per second at the credits 0.2 0.8
time to reach the credits ~13 min ~5 min

No device loss or new fault in either run. AI-assisted: yes.

**@⁠x2Tweek** on GitHub · 2026-11-25 18:39 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1867#issuecomment-7171205988) Measured on Windows 11 with an NVIDIA RTX 5090 (driver 32.0.16.2124), retail boot, runtime at the #1723 integration point with and without this PR, same settings and the same scripted input for both runs, read from the `[rt] submit phases` and `slot-133 shadow copies by cause` lines at the opening credits: | | main | main + #1867 | |---|---|---| | aliased pages copied per submission | ~1.3 GiB | ~6-20 MiB | | shadows phase per submission | 285-330 ms | 1-3 ms | | frames per second at the credits | 0.2 | 0.8 | | time to reach the credits | ~13 min | ~5 min | No device loss or new fault in either run. AI-assisted: yes.
Author
Owner

@⁠gmankab on GitHub · 2026-11-25 21:16 UTC · original · edited 2026-11-26 00:50 UTC

I tested the alias guard patch on an Intel Xeon E5-2670 v3 with Fedora Linux 45, Wine 11.21 Staging and Lavapipe. The control was db1a22d290f5e86fff9282fce3d4e02e788b05b4. The second build added only 3124ca8e495a02585fc8f952f833bc4ee4c1802e on the same base. Both runs used equivalent copies of one Wine prefix seed, a fresh overlay and an 80-second limit.

In the four late startup samples (63–78 seconds), the runtime reported:

Build Aliased copies per submission Average shadow time per submission Reported FPS
Control 577,701.7 KiB 102.55–106.26 ms 4.34–4.55
With this PR 0 KiB 3.09–3.15 ms 43.88–43.95

Both runs reached PresentX and ended at the test time limit. The figures cover startup, with hardware rendering disabled.

Tested-on: Intel Xeon E5-2670 v3, Fedora Linux 45, Wine 11.21 Staging, Lavapipe.
Assisted-by: gpt-6.2 sol xhigh

Retest on the current main branch

I repeated the comparison on 61732ac with the same Wine and Lavapipe setup, a fresh overlay for each build and a 95-second limit. The tested rebase keeps the upstream stray read-only page diagnostics; the overlap was in the comment preceding that helper.

Build Median shadow work per submission Median reported frame rate
Current main 107.91 ms 4.36 FPS
Current main with the alias guard 3.46 ms 42.69 FPS

These are startup samples from the final 26 seconds. Both runs reached PresentX and ended at the time limit.

Tested-on: Intel Xeon E5-2670 v3, Fedora Linux 45, Wine 11.21 Staging, Mesa Lavapipe 26.2.7.
Assisted-by: gpt-6.2 sol xhigh

**@⁠gmankab** on GitHub · 2026-11-25 21:16 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1867#issuecomment-7174840488) · edited 2026-11-26 00:50 UTC I tested the alias guard patch on an Intel Xeon E5-2670 v3 with Fedora Linux 45, Wine 11.21 Staging and Lavapipe. The control was `db1a22d290f5e86fff9282fce3d4e02e788b05b4`. The second build added only `3124ca8e495a02585fc8f952f833bc4ee4c1802e` on the same base. Both runs used equivalent copies of one Wine prefix seed, a fresh overlay and an 80-second limit. In the four late startup samples (63–78 seconds), the runtime reported: | Build | Aliased copies per submission | Average shadow time per submission | Reported FPS | | --- | ---: | ---: | ---: | | Control | 577,701.7 KiB | 102.55–106.26 ms | 4.34–4.55 | | With this PR | 0 KiB | 3.09–3.15 ms | 43.88–43.95 | Both runs reached PresentX and ended at the test time limit. The figures cover startup, with hardware rendering disabled. Tested-on: Intel Xeon E5-2670 v3, Fedora Linux 45, Wine 11.21 Staging, Lavapipe. Assisted-by: gpt-6.2 sol xhigh ### Retest on the current main branch I repeated the comparison on [61732ac](https://github.com/ubiquitarianism/leonida/commit/61732aca16fb0d63deb5e9987f9758d4e6ce0228) with the same Wine and Lavapipe setup, a fresh overlay for each build and a 95-second limit. The [tested rebase](https://github.com/gmankab/ubiquitarianism-leonida/commit/fc19a7707151c082315b5b192a49d51f5d39bee0) keeps the upstream stray read-only page diagnostics; the overlap was in the comment preceding that helper. | Build | Median shadow work per submission | Median reported frame rate | | --- | ---: | ---: | | Current main | 107.91 ms | 4.36 FPS | | Current main with the alias guard | 3.46 ms | 42.69 FPS | These are startup samples from the final 26 seconds. Both runs reached PresentX and ended at the time limit. Tested-on: Intel Xeon E5-2670 v3, Fedora Linux 45, Wine 11.21 Staging, Mesa Lavapipe 26.2.7. Assisted-by: gpt-6.2 sol xhigh
Author
Owner

@⁠Snooozs on GitHub · 2026-11-25 22:04 UTC · original

Native Windows result with the game (the earlier numbers here were Wine). RTX 5060 Ti 16 GB, NVIDIA 621.01, Windows 10 19045, 32 GB RAM, own 1.0.2.1. Base: #2098 at 9f98dcc61 + #1592 merged with main + local diagnostics; this PR at 3124ca8e4 merged on top (one textual conflict with #2098, in the comment above shadow_write_fault). LEONIDA_ASYNC_PIPELINES=1, LEONIDA_TITLE_WINDOWS_MB=1024, LEONIDA_ARENA_MB=2048.

From the slot-133 refresh line, averaged over the submissions after the 4,000th (the world start):

Run This PR --trace-d3d12 Submissions averaged Copied per submission Time per submission
n39 no on 1,345 867.1 MiB 100.5 ms
n40 no on 1,382 860.7 MiB 103.7 ms
n41 no on 193 894.7 MiB 107.1 ms
n43 yes off 1,405 3.7 MiB 8.8 ms
n44 yes off 6,371 4.6 MiB 7.4 ms

I turned the D3D12 trace off in the same step, so the time column is not a clean A/B; the copied bytes are. n44 reached the opening cutscene's prompts and ran 585 s with no device loss.

Two things I can't attribute and am not claiming are from this PR:

  • One of three runs with it (n42, not repeated in n43 and n44) ended at t=94.6 s with a title read of address 0 at game_scarlett_master.exe+0x22bfc0. In the second before, xmem logged 8 "zero plant" pages (a title write into a window page that was never mapped); rax was one of those pages. My runs without the PR that I checked (n33, n35 to n41) have none, but they were also slower.
  • In n44, some lower-case letters of one text page are missing for the whole run. I have not compared that page without the PR.

If you want a log line or a switch checked on this machine, say which. AI-assisted (Claude Code).

**@⁠Snooozs** on GitHub · 2026-11-25 22:04 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1867#issuecomment-7175907242) Native Windows result with the game (the earlier numbers here were Wine). RTX 5060 Ti 16 GB, NVIDIA 621.01, Windows 10 19045, 32 GB RAM, own 1.0.2.1. Base: #2098 at 9f98dcc61 + #1592 merged with `main` + local diagnostics; this PR at 3124ca8e4 merged on top (one textual conflict with #2098, in the comment above `shadow_write_fault`). `LEONIDA_ASYNC_PIPELINES=1`, `LEONIDA_TITLE_WINDOWS_MB=1024`, `LEONIDA_ARENA_MB=2048`. From the slot-133 refresh line, averaged over the submissions after the 4,000th (the world start): | Run | This PR | `--trace-d3d12` | Submissions averaged | Copied per submission | Time per submission | | --- | --- | --- | ---: | ---: | ---: | | n39 | no | on | 1,345 | 867.1 MiB | 100.5 ms | | n40 | no | on | 1,382 | 860.7 MiB | 103.7 ms | | n41 | no | on | 193 | 894.7 MiB | 107.1 ms | | n43 | yes | off | 1,405 | 3.7 MiB | 8.8 ms | | n44 | yes | off | 6,371 | 4.6 MiB | 7.4 ms | I turned the D3D12 trace off in the same step, so the time column is not a clean A/B; the copied bytes are. n44 reached the opening cutscene's prompts and ran 585 s with no device loss. Two things I can't attribute and am not claiming are from this PR: - One of three runs with it (n42, not repeated in n43 and n44) ended at t=94.6 s with a title read of address 0 at `game_scarlett_master.exe+0x22bfc0`. In the second before, xmem logged 8 "zero plant" pages (a title write into a window page that was never mapped); `rax` was one of those pages. My runs without the PR that I checked (n33, n35 to n41) have none, but they were also slower. - In n44, some lower-case letters of one text page are missing for the whole run. I have not compared that page without the PR. If you want a log line or a switch checked on this machine, say which. AI-assisted (Claude Code).
github-bot force-pushed github-bot/gh-1867 from ae0a95dbef to 49a0b69fcd 2026-11-26 11:25:04 +00:00 Compare
github manually merged commit df92abca8e into main 2026-11-27 00:35:17 +00:00
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-26 22:35 UTC · original

Merging.

  • Why: aliased title pages were copied whole at every submission, because a guard on one address does not catch a write through another. They are now guarded at every address they are mapped at, and a block is copied only after a write reached it. A block that cannot be guarded is still copied every time, as before.
  • Maintainer commits on the branch:
    • df92abca8, a merge of main e5a7c8942. One conflict, in runtime/README.md: this PR rewrote the LEONIDA_SHADOW_ALIAS_MS row and #2163 added the LEONIDA_SHADOW_KEEP row after it. Both are kept.
    • 4f364c857, a test and no fix: an alias that appears after the cells were armed is guarded at the next submission, and a write through it is copied.
  • Reviewed for the lock order, since a run here once froze on the shadow lock: the alias lookup and the arming run outside the tracker's lock, the geometry watch's mutex is a leaf, and the fault handler never takes the shadow mutex.
  • Tested on that head, integrated RDNA2 GPU (RADV, Mesa 26.3.1):
    • The new checks fail on main (all three d3d12_existing_heap variants) and pass here.
    • Linux runtime ctest: 115/115.
    • Windows suite under Wine: 422 pass and 26 fail, against 425 and 23 on main. The three that changed are xmem and xmem_write_watch, which are flaky here and run none of this PR's code, and one xdxr_build_check timeout while other builds were loading the machine.
    • Registration, docs, line-ending and game-data checks pass.
  • Not tested: no game run from this head yet; it is in the next one here. In our earlier runs the aliased copies are one full pass of about 345 MiB every 5 s (LEONIDA_SHADOW_ALIAS_MS=5000), with the shadows phase peaking at 100 to 570 ms on the submission that carries it.

Thanks @⁠azsekazvamdimitar, and @⁠Timon360SB, @⁠MoonEyes, @⁠x2Tweek, @⁠gmankab, @⁠Snooozs and @⁠DadaCap for the runs and reviews.

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

**@⁠aslan2142** on GitHub · 2026-11-26 22:35 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1867#issuecomment-7204820154) Merging. - **Why:** aliased title pages were copied whole at every submission, because a guard on one address does not catch a write through another. They are now guarded at every address they are mapped at, and a block is copied only after a write reached it. A block that cannot be guarded is still copied every time, as before. - **Maintainer commits on the branch:** - `df92abca8`, a merge of `main` `e5a7c8942`. One conflict, in `runtime/README.md`: this PR rewrote the `LEONIDA_SHADOW_ALIAS_MS` row and #2163 added the `LEONIDA_SHADOW_KEEP` row after it. Both are kept. - `4f364c857`, a test and no fix: an alias that appears after the cells were armed is guarded at the next submission, and a write through it is copied. - **Reviewed for the lock order,** since a run here once froze on the shadow lock: the alias lookup and the arming run outside the tracker's lock, the geometry watch's mutex is a leaf, and the fault handler never takes the shadow mutex. - **Tested on that head**, integrated RDNA2 GPU (RADV, Mesa 26.3.1): - The new checks fail on `main` (all three `d3d12_existing_heap` variants) and pass here. - Linux runtime `ctest`: 115/115. - Windows suite under Wine: 422 pass and 26 fail, against 425 and 23 on `main`. The three that changed are `xmem` and `xmem_write_watch`, which are flaky here and run none of this PR's code, and one `xdxr_build_check` timeout while other builds were loading the machine. - Registration, docs, line-ending and game-data checks pass. - **Not tested:** no game run from this head yet; it is in the next one here. In our earlier runs the aliased copies are one full pass of about 345 MiB every 5 s (`LEONIDA_SHADOW_ALIAS_MS=5000`), with the shadows phase peaking at 100 to 570 ms on the submission that carries it. Thanks @⁠azsekazvamdimitar, and @⁠Timon360SB, @⁠MoonEyes, @⁠x2Tweek, @⁠gmankab, @⁠Snooozs and @⁠DadaCap for the runs and reviews. AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2)
This discussion has been locked. Commenting is limited to contributors.
No description provided.