watch, draw: tell the texture pass of the title's own writes to guarded blocks (DARNER_TITLE_WRITE_NOTICE, off by default) #461
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
hle
input
INTEL
lighting
linux-proton
memory
MULDER
needs-info
needs-logs
needs-rebase
NVIDIA
performance
post-merge
pr-diagnostics
pr-docs
pre-merge
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
relevance
high
relevance
low
relevance
medium
relevance
very-high
rendering
report
roadmap-proposal
saves
series-s
shaders
startup
status
blocked-by-rework
status
needs-test-report
status
needs-triage
status
ready-for-review
status
stale
status
superseded
status
wip
tools
ui
upstream
wontfix
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
TrustNo1/Darner!461
Loading…
Reference in a new issue
No description provided.
Delete branch "Layne/Darner:pr/title-write-notice"
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?
Off by default; nothing changes while the switch is unset. It has been in play on a fork of this tree (other local changes included) since early December; on this branch only the unit tests and the gates below were run (see "How it was tested").
Contributor role (optional)
What it changes
descriptor::host::remapped_ranges). When the title writes that memory itself with the CPU, nothing tells the pass. The texture is uploaded again only when one of its own looks finds the fingerprint changed (RECHECK_FRAMES: 4, 12, 40, 120, 400 frames, so 4 to 576 frames late). Until then the old copy is drawn, and the title's next writes can make old and new versions show in turn.DARNER_TITLE_WRITE_NOTICEset, that handler (both paths: the lockedopeninon_writeandopen_unlocked, including the blocks opened with it bywiden_after), and the store done beside a guard (titlewrite::store), keep the block number for the next texture pass (watch::title_wrote).watch::title_writes_told, just beforehost.texture_slots_remapped(frame)), adds the other views of their pages (inplace::shown_elsewhere), and hands them toremapped_ranges. The placed textures there are due from the next frame, through the existing path.count: the blocks are only noted, with their frame. The existing warning "a texture picked by index changed after its upload with nothing to tell of it" gets atitle_wrotefield saying whether a write was noted since the upload (diagnostic only).painted: told to the pass. A texture a look found changed with nothing told of it is remembered (at most 4096 addresses) and guarded each time it is uploaded or looked at whole from then on (title_write_watch, bywrites_since(.., guarded = true, ..)). Its first change is still found late, the next ones are not.1: told, and every texture in view memory that the pass uploads whole is guarded so from its first upload.Bits::swap_on, so a block faulting again before a pass takes it costs nothing more) and a push under a mutex that nothing else is taken under; nothing is called and no title memory is touched with it held. The list holds at most 16,384 blocks between two passes; a fault past that is counted (not_kept) and left to the looks, as today. The texture pass takes the list's lock alone, then the views' lock to read, then the ranges', one after the other, so no new lock order.TITLE_WROTE(the frame of each told block) is the existingLandedtable: 256 KiB pieces allocated per 4 GiB of address space touched.title_write_notice()is aOnceLock<u8>read (done once ininstall, so never first in a fault); every new call returns at once. No guard, no lock, no allocation, no per-frame work.Relation to other pull requests
remapped_rangescallers inwatch.rs.How it was tested
Tested revision:
ceedffcf0, on top ofmaind91d8e4d6.Commands and results:
cargo check --release -p darner-gpu: finished, no warningscargo clippy -p darner-gpu --all-targets --locked -- -D warnings: cleancargo test --release -p darner-gpu --lib watch: 106 passed, 0 failed, 1 ignored (3 of them new)title_wrote_blocks); the kept list takes each block once, stays within its bound and keeps a block again once taken (TitleWrites::keep/take);Landed::afterleaves out the frame asked about (a note from the upload's own frame does not count as after it).Changes a default: no (off unless
DARNER_TITLE_WRITE_NOTICEis set).How the switch was checked: in play with
DARNER_TITLE_WRITE_NOTICE=1on a fork of this tree since our build of early December, RTX 4070 Ti 12 GB, Series X profile, 1440p. The player reports the skin and clothes flicker as "almost gone". No counted A/B (same route, off and on) has been run; the report is a player's impression, not a measurement. One log of mode 1 on that fork: about 1,400 guard faults a second from this switch once in the open world, every one kept (not_kept0), about 3 blocks told per fault with the other views.1)Gates run on that revision: none of the three full gates. Only the narrower checks above.
Gameplay: fork sessions above (not this branch). Their logs were not reviewed for this PR beyond the counts quoted.
Hardware dependence: none expected (CPU-side, guard faults and the existing upload path).
Coverage gaps: the fault handler path and the texture pass call are not unit tested (they need guarded view memory and a device). The 16,384 bound and the 4096-address
paintedset were not tuned.Risks
1adds write faults: one for the first write to each guarded block after each upload, and aVirtualProtectper block (and per other view) at each guard. That is CPU time on the title's threads; not measured in frame time.paintedempties its address set when it reaches 4096 entries; textures still being painted are found again by the looks.How to test
DARNER_TITLE_WRITE_NOTICE=1(orpaintedfor fewer guards,countto only count).the title's own writes to guarded blocks, noted for the textures picked by index:faultsandblocks_toldshould grow in the open world,not_keptshould stay at 0.Checklist
main.docs/asset-policy.md.Checked for overlap
🤖 Generated with Claude Code
Native guarded-write A/B on Windows 11 and an RTX 4060. I integrated
ceedffcfwithc8258f95so the fixture could reuse the placed-texture readback from #433. Each mode ran in its own process withDARNER_PAGE_WRITES=0. The fixture made two views of a test-owned section, verified both were read-only under the same guard, and performed a plain CPU store through the writer alias.0countpainted1I also exercised a lifecycle case with
1. After the same store, the writer view was unmapped beforetitle_writes_toldwhile the sampled alias stayed mapped. The fault was recorded, but only one block was noted and the slot never became due in that pass. All 1,024 GPU pixels still had the previous value. The pending notice appears to lose its alias lookup when the writer's view is removed.The test-only fixture runs with
cargo test --locked --offline -p darner-gpu --lib watch::tests::guarded_cpu_write_refreshes_a_placed_texture_at_its_alias -- --exact --ignored --nocapture. SetDARNER_TEST_UNMAP_WRITER=1for the failing case. This checks next-frame delivery after the guard is installed. A counted gameplay A/B for #311 would still test a separate effect.[pr-fix][rendering][memory] watch, draw: tell the texture pass of the title's own writes to guarded blocks (DARNER_TITLE_WRITE_NOTICE, off by default)to watch, draw: tell the texture pass of the title's own writes to guarded blocks (DARNER_TITLE_WRITE_NOTICE, off by default)Test needed — commit
ceedffcf; what to check:DARNER_TITLE_WRITE_NOTICE=1(orpaintedfor fewer guards,countto only count).the title's own writes to guarded blocks, noted for the textures picked by index:faultsandblocks_toldshould grow in the open world,not_keptshould stay at 0.Evidence to post: card + driver, settings, commit tested, before/after (switch off vs on, two runs each), fps median and p99, and one line saying you looked at the picture.
Reply
testingto take this run; it's free again after 24 h with no results.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.