mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:30:53 +01:00
[PR #1867] d3d12: slot-133 shadows guard aliased title pages at every address instead of copying them each submission (RT-SHADOW-ALIAS-GUARD) #1879
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#1879
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/1867
Author: @azsekazvamdimitar
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:shadow-aliased-guard📝 Commits (1)
49a0b69d3d12: slot-133 shadows guard aliased title pages at every address instead of copying them each submission (RT-SHADOW-ALIAS-GUARD)📊 Changes
5 files changed (+241 additions, -44 deletions)
View changed files
📝
runtime/README.md(+1 -1)📝
runtime/shims/d3d12_vulkan_device.cpp(+147 -34)📝
runtime/shims/xmem.cpp(+11 -8)📝
runtime/src/title_page_watch.h(+2 -1)📝
runtime/test/d3d12_existing_heap_test.cpp(+80 -0)📄 Description
Claimed in the coordination issue as: RT-SHADOW-ALIAS-GUARD (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7164143777)
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.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.