d3d12: slot-133 shadows guard aliased title pages at every address instead of copying them each submission (RT-SHADOW-ALIAS-GUARD) #1867
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!1867
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1867"
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?
@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 UTCClaimed 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 (main0d80bc5df, 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_MScan 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 ofrefresh()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 addressgeometry_aliasesnames, 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 intoshadow_write_fault, which already notifies the geometry watch first; a remap, commit or protection change moves a cell's version too.armrefuses it), and in the refreshesLEONIDA_SHADOW_ALIAS_MSthrottles.note_mappingnow 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:
0d80bc5dfLEONIDA_SHADOW_ALIAS_MS=3600000(aliased pages copied once: stale, an upper bound)98c2f7777)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_testgainscheck_aliased_guard: one page mapped at A and B (the test answersgeometry_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 existingcheck_aliased_write, which has no other address to arm, still copies every time and passes.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_shadowandxs_proxy_mockpass under both.xmemfails one check, "writing to 512 of them charges about those 512 pages", under Wine; it fails the same way on main without this change.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
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.@Timon360SB on GitHub · 2026-11-25 15:30 UTC · original
Independent verification — Turing and Blackwell
5e95fa2f46d5df1a8397d5ee871add369031d8b63124ca8e495a02585fc8f952f833bc4ee4c1802eEnvironment
NVIDIA 621.14, Vulkan SDK 1.4.363.0,
MSVC 19.44.35230, Ninja RelWithDebInfo.
Three repetitions per GPU, revision and validation mode.
Results
d3d12_existing_heapd3d12_existing_heap_no_write_watchd3d12_existing_heap_write_watchd3d12_xmem_placedd3d12_title_vad3d12_title_va_shadowxs_proxy_mockxmem192 executions: 192 passed, 0 failed, 0 skipped.
Findings
check_aliased_guardfixture passed all36 executions across the three existing-heap variants.
The unreported-view control produced the expected stale
byte at offset 69632; writing through B correctly
propagated the updated data.
without deadlocks, with correct final readbacks.
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.
@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):
VirtualProtectcalls;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).
@MoonEyes on GitHub · 2026-11-25 18:15 UTC · original
Independent test run: Windows 11, RTX 4060
Head
3124ca8e4, compared with its merge base5e95fa2f4(main when the pull request was opened). Main was atb9320a118when I checked, 60 commits after that base; GitHub reports the pull request as mergeable. I did not build or run the merge.Setup
-DLEONIDA_REQUIRE_VULKAN=ONctest -R "title|shadow|alias|existing_heap|xmem|xs_proxy_mock|geometry"Results
5e95fa2f43124ca8e4, run 1xs_proxy_mock,xmem,xmem_no_write_watch,xmem_write_watchd3d12_existing_heap,_no_write_watch,_write_watchcheck_aliased_guardon head prints protection0x2at A and at B between submissions.The failures on head are
xs_proxy_mock(both runs) and the threexmemvariants (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 isg_tear.torn == 0 && g_tear.reads > 0(line 4487), after a 200,000-store loop racing a reader thread.xs_proxy_mock_testdoes not compilexmem.cppord3d12_vulkan_device.cpp; the only changed file it sees is a comment intitle_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 isthe 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 basemapping them does not charge them).wrongwas 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 loggedxmemruns 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,
xmemfails on both revisions here, and anxs_proxy_mockfailure on head that I cannot explain and cannot tie to the change.Mutation
The
d3d12_existing_heap_test.cppof the pull request, built against the base versions ofd3d12_vulkan_device.cpp,xmem.cppandtitle_page_watch.h: all three variants fail, at the new check.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:
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)
@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 phasesandslot-133 shadow copies by causelines at the opening credits:No device loss or new fault in either run. AI-assisted: yes.
@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 only3124ca8e495a02585fc8f952f833bc4ee4c1802eon 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:
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.
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
@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 withmain+ local diagnostics; this PR at 3124ca8e4 merged on top (one textual conflict with #2098, in the comment aboveshadow_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):
--trace-d3d12I 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:
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);raxwas one of those pages. My runs without the PR that I checked (n33, n35 to n41) have none, but they were also slower.If you want a log line or a switch checked on this machine, say which. AI-assisted (Claude Code).
ae0a95dbefto49a0b69fcd@aslan2142 on GitHub · 2026-11-26 22:35 UTC · original
Merging.
df92abca8, a merge ofmaine5a7c8942. One conflict, inruntime/README.md: this PR rewrote theLEONIDA_SHADOW_ALIAS_MSrow and #2163 added theLEONIDA_SHADOW_KEEProw 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.main(all threed3d12_existing_heapvariants) and pass here.ctest: 115/115.main. The three that changed arexmemandxmem_write_watch, which are flaky here and run none of this PR's code, and onexdxr_build_checktimeout while other builds were loading the machine.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)