mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:10:51 +01:00
[PR #2404] [MERGED] d3d12: the title write-back asks the write watch first and copies back only the bytes a copy changed (RT-TITLE-WRITEBACK-STALE-BYTES) #2404
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#2404
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/2404
Author: @OreoFR
Created: 11/26/2026
Status: ✅ Merged
Merged: 11/26/2026
Merged by: @aslan2142
Base:
main← Head:fix/title-writeback-asks-first📝 Commits (2)
0894ecdd3d12: the title write-back asks the write watch first and copies back only the bytes a copy changed46aeaaedocs: the title write-back asks the write watch first and writes only the pieces that differ📊 Changes
2 files changed (+93 additions, -44 deletions)
View changed files
📝
docs/d3d12_vulkan.md(+6 -3)📝
runtime/shims/d3d12_vulkan_device.cpp(+87 -41)📄 Description
Claimed in the coordination issue as: RT-TITLE-WRITEBACK-STALE-BYTES (released to me by @DadaCap)
What and why
Since #2350 (which brings #2129, the title write-back), the story load crashes on Windows/NVIDIA. The title faults at a different place on every run: null writes, a non-pointer read, its own
int3. Turning the write-back off removes these faults, but it is still needed for #1537.The cause is in
ShadowPages::write_back(runtime/shims/d3d12_vulkan_device.cpp):write_back_titles()runs at the start of the shadow refresh, beforeShadowPages::refresh()asks the write watch. A hot page (write-watched, never guarded) still carrieskCleanfrom the last asking. Every write the title made to it since the last submission was therefore copied over with the older shadow. Hot pages are the ones the title writes most.reopen_locked) before amemcpyof the whole range. A title thread writing it in between did not fault, and its write was lost.This change keeps the write-back on and does three things:
write_backasks the write watch first. The asking moves intoask_written_locked(), whichrefresh()uses too, so a hot page the title wrote is held.title_memory_mapjournal; nothing goes back when the journal no longer reaches back), pages pinned for a kernel write, and pages xmem maps at another address.docs/d3d12_vulkan.mddescribes the new behaviour.Tested
d3d12_title_vaandd3d12_title_va_shadow(the write-back tests from #2129) pass.tests/test_docs_env_vars.pypasses, andscripts/check_no_game_data.pyis clean on both changed files.mainfac8b4bb9, 600 s, shaders retranslated, write-back on (default):main, and2d43417d4the same apart from #2401): the title faulted at 95-170 s in 5 of 5 runs, each time somewhere else. One run onfac8b4bb9reached the watchdog stop at 186 s first.+0x23cf683), after the title polled a fence value that stopped arriving for about 50 s. The same stop happens withLEONIDA_TITLE_WRITEBACK=0, so it is a separate issue and not part of this change.LEONIDA_TITLE_WRITEBACK=0.GPUs tested: NVIDIA GeForce RTX 4070 Laptop 8 GB, driver 621.40, Windows 11.
AI-assisted: yes (Claude Code, Claude Opus 5.5)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: runtime only)🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
[PR #2404] d3d12: the title write-back asks the write watch first and copies back only the bytes a copy changed (RT-TITLE-WRITEBACK-STALE-BYTES)to [PR #2404] [MERGED] d3d12: the title write-back asks the write watch first and copies back only the bytes a copy changed (RT-TITLE-WRITEBACK-STALE-BYTES)