d3d12: a window's GPU writes go back to the title's pages (RT-TITLE-WINDOW-WRITE-BACK) #2129
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!2129
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2129"
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?
@star41905453-coder on GitHub · 2026-11-25 22:01 UTC · original
star41905453-coder:rt-title-window-write-back→main· +400 −2 · 6 files · 4 commits · merged 2026-11-26 14:41 UTCCloses the world-start stop of #1537 (QemmHD's WRITE_INVALID, about 160 s into the load): a title window is a read-side mirror, so a UAV or raw write into one landed in the copy and the title never saw it.
What it does
LEONIDA_TITLE_WRITEBACK=0turns it off.It also covers the slot-133 case: a placed buffer whose pages the driver will not import is a shadow too, and a write through it landed in the copy exactly the same way. The pages there are title memory, the buffer's alias resolves through the same noter and the tracker carries the range, so the mechanism needed nothing new — only proof,
d3d12_placed_write_back.Test —
d3d12_title_window_write_back(new ctest entry,--window-writeback): a dispatch through a root UAV at the title's own pages. The pages stay untouched until the next submission, then hold exactly the words the shader wrote, across two submissions, and a title write survives the next forward copy. No game files.Run — Linux, Wine 10, Mesa llvmpipe (no GPU on this box). The 21 failures of a full 448-test run are environmental and were confirmed by running the same list on unmodified
main(9f9a7c5f3): every one fails there too, most withWARP reference unavailable, and the title tests pass there. Nothing in this diff causes a failure thatmaindoes not already have.d3d12_title_va,d3d12_title_va_shadow,d3d12_geometry_views,d3d12_title_window_cap,d3d12_title_window_write_back,d3d12_placed_write_back: pass.ctest -R 'write_back|title|shadow|alias|arena|stream': 20/20 pass.main(baseline above); 7 of themxmem/file_system/bcrypt_rng/root_sigare Wine gaps, the rest sayWARP reference unavailable.gta6rt --runoftiny_asyncthrough the rebuilt loader:PASS, exit 0.What is still wanted: a retail
--runpast the cap on a GPU (the package is 208 GiB and this box has 36), withLEONIDA_DEVICE_FAULT=1if it still dies.Item: RT-TITLE-WINDOW-WRITE-BACK, claimed in #1608.
@ecox982745 on GitHub · 2026-11-25 22:17 UTC · original · edited 2026-11-25 23:48 UTC
Retested at
fa3885a7fwith the new retirement-ticket handling. On the RTX 4090, the stock test passed 6/6 and lower-address-first passed 6/6. Upper-address-first still failed 6/6. The lower window contained 0/64 written words and the upper one contained 64/64. Each set includes three runs with Vulkan validation and three without. Every submission in this test waits for its fence.The patch below merges touching ranges under their lowest address and charges only newly covered bytes against the cap. Applied on top of this head, it passed all 18 GPU runs. Separately, I compiled the insertion code in a CPU harness with limits of five bytes and two ranges. Across all 46,656 ordered triples of nonempty intervals in an eight-byte space, the stored ranges and byte total matched a byte-set reference after every insertion, including refused insertions.
Tested patch for note_title_write (applies to
fa3885a7f)Two adjacent windows lose the lower window's GPU writes when the command list binds the upper address first. I reproduced this at
f55177efbon an RTX 4090, Windows 11, NVIDIA 616.64. Each submission waited for its fence before the next began.I extended the PR's synthetic
--window-writebackfixture locally. In one command list, dispatch the existing shader twice through its root UAV, once at the base of the fixture's zeroed 256 KiB buffer and once 64 KiB above it. Both dispatches write the same 64-word pattern. Submit that list, wait, then repeat to trigger write-back and inspect the original CPU pages. Changing only the dispatch order gave these results:The cause is in
DeviceState::note_title_write. Whenlower_bound(va)finds a touching successor, the branch extends its end and keeps its old start. With the upper window already recorded, the lower one disappears. Re-keying that entry to the lower start made all 64 corresponding word pairs equal in both orders. For the full fix, merge every interval the new binding touches and charge the byte cap for the additional covered bytes. The current extension branches return before updating the byte count.The PR's unmodified five title-window and geometry CTests passed on this card, both plain and with Vulkan validation. This additional case checks writes to two adjacent windows. All inputs were synthetic.
AI-assisted with OpenAI Codex (
gpt-6.2-astra).@JordanWebDev on GitHub · 2026-11-25 23:41 UTC · original · approved these changes
@qhukz13 on GitHub · 2026-11-26 00:25 UTC · original
Heads-up for whoever merges either: this PR and #2032 (TITLE-GPU-WRITE-BACK, BubsMcgee) implement the same thing, copying a shader's writes in a title window back to the title's pages. I reviewed #2032 earlier today (comment); reading this one against the three points there:
write_back's tracker check), stated in the description. #2032 loses the GPU bytes of such a page without saying so.d3d12_title_window_write_backdrives a dispatch through a root UAV and reads the title's pages back on the CPU, which is the end-to-end case #2032's registry test does not reach.So this one covers what I raised there; the two authors may want to settle on one. ecox982745's upper-address-first ordering case above is still open here.
Native Windows run (the description has Wine/llvmpipe; ecox982745 ran an RTX 4090): GTX 1050 Ti, Windows 10 Pro 19045, NVIDIA 582.66, MSVC RelWithDebInfo, this head merged onto main
c50ed94b3(clean).d3d12_title_window_write_back,d3d12_title_va,d3d12_title_va_shadow,d3d12_title_window_cap,d3d12_api_descriptor_copy,d3d12_rebound_tables,d3d12_title_index_window,d3d12_title_vertex_window,xbox_geometry_upload_batch,d3d12_unmapped_vsharp: 10/10, 3 runs each, plain and withLEONIDA_VK_VALIDATION=1, no validation messages. I did not apply ecox982745's range-merge patch here.AI-assisted (Claude Code).
@ecox982745 on GitHub · 2026-11-26 05:48 UTC · original
The new slot-133 test passes on my RTX 4090 at
990a9f931c391334d93674e2dabbe86e3d6d4aac. I extended it to two adjacent placed buffers. When the upper address was submitted first, the lower buffer received 0/64 expected words on all six runs. The range-merging patch from the window test applies cleanly to this head and fixes both orders.I created two separate 64 KiB slot-133 buffers over adjacent halves of one registered 128 KiB synthetic allocation. In one command list, each dispatch used its own root UAV and the fixture shader's existing root-read mode to write
original_word[i + 64] + 7into words 0–63. All CPU words still held their initial values after the first fence. The next submission triggered the copy back. In every run the other 32,640 words stayed unchanged. Each table cell represents three runs with Vulkan validation enabled and three with it disabled. Turning write-back off on the patched runtime returned 0/64 for both buffers in both orders.One detail for the new stock test: its
untouched == kElementsassertion is skipped on this device. The host-import counter stayed flat across placement, and the shadow's shader address was inside the arena. The current guard requires an address at or above the arena size. The fixture can assert the timing directly when it disables host import, or use the import-count delta around placement to choose that assertion.Windows 11, NVIDIA 616.64, synthetic GPU readback only. AI-assisted verification (OpenAI Codex).
@Timon360SB on GitHub · 2026-11-26 06:41 UTC · original
Testing Results — PR #2129
PR #2129 — title-window GPU write-back
Configuration
9f9a7c5f30f8559c52675780cf84004571b8d6e5990a9f931c391334d93674e2dabbe86e3d6d4aacBoth revisions built successfully.
Results
180 actual test executions, 11 distinct test names. No checkpoint-restored results were counted.
The four shared tests passed on both revisions:
d3d12_title_va,d3d12_title_va_shadow,d3d12_geometry_views,d3d12_title_window_cap.Write-back checks
Both new fixtures passed 6/6 times on each GPU:
d3d12_title_window_write_backd3d12_placed_write_backNo VUID messages were captured.
Coverage limits: the new fixtures ran only on HEAD. They do not check every word against an exact shader-output reference. The placed-buffer pre-write-back timing assertion did not execute on either GPU.
Testing used synthetic fixtures on physical GPUs. AI assisted log analysis and report preparation.
298748a92ato5fa864e539@aslan2142 on GitHub · 2026-11-26 14:42 UTC · original
Thank you, @star41905453-coder. This went into
mainthrough #2350 (RT-LINUX-AMD-WORLD), merged at your head5fa864e53with your commits and authorship kept. The one conflict, in the title-window members, kept your write-back state as it is. The two-adjacent-buffers case reported above is still open; a follow-up is welcome. GitHub shows this PR as merged for that reason, so nothing needs closing.AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2)