fix: a texture's staging buffer is not rewritten while a copy from it may be on the card #254
No reviewers
Labels
No labels
accessibility
bloqué : binaire console
bug
chargeur
console-dll
cpu
documentation
duplicate
enhancement
good first issue
gpu
help wanted
invalid
performance
question
runtime-gdk
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LooperSalty--AnyXboxX!254
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-254"
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?
@Skyfrye on GitHub · 2026-11-25 21:57 UTC · original
Skyfrye:nep/staging-refresh-guard→main· +113 −13 · 2 files · 1 commits · draftDraft: the in-game check on this base is pending (the test machine's GPU is in use for a few hours). Everything below the game run is done.
Change
A list that samples a title texture whose staging buffer is newer than the host texture records a copy from that buffer, and the buffer is brought up to date while the list's submission is prepared (
Step::Texture→Staging::refresh). A later submission that samples the same texture checks it again while it is prepared and, when the title changed the texture's memory, detiles the new bytes into the same buffer at once. With flights in the air (the relay), the earlier submission's copy can still be waiting on the card, and then reads bytes of two versions of the texture.The previous base waited for the card at such a point (
staging_in_flight→ a settle; on an RTX 5080 about 14 settles a frame, most of the ~97 ms the submitting thread stood waiting). The Neptune base no longer waits, and I found nothing else that keeps the buffer from being written (no fence, no double buffer; the pool only reuses a buffer after every list holding it was reset, which is a different case). This may be part of the known issue "objects and clothes can turn black for a moment while their textures are swapped" — not shown.Now:
Stagingnotes the last submission whose lists copy from it (copied_by;Step::Texturecarries whether the list recorded a copy,Batchcarries the submission's number);copied_by > finishedand< preparing): nothing waits; the texture's notes (Last) are left untouched so the change is found again at a later check; copies are recorded only after a detiling (a list may still record one from a detiling that came before the guard held off, which is fine: it copies what the buffer holds), socopied_bystops moving, the earlier submission lands and a later check goes ahead. A texture the title rewrites at every submission is then brought up to date about once per flights-in-the-air plus one submissions instead of at every one; it is never starved (an independent review traced this). The texture shows a change that much later;VICTORY_STAGING_GUARD=0restores the previous behaviour. The frame line counts the checks put off ("texture refreshes put off per frame ...").Linked issue: none.
Verification
Windows 11 26300, Rust 1.98.1 (MSVC), RTX 5080, on upstream
mainataffaf15, fromthird_party/victory:With
copy_in_flightmade to returnfalseand the test kept, the test fails.Pending: a game run (GTA VI 1.0.2.1, my own copy, launcher settings) with the frame line's new counter, against
mainand withVICTORY_STAGING_GUARD=0, and a picture comparison of the same frames. I will add the numbers here before marking the PR ready.First game run with the guard on (5 minutes, release build with this and the other open changes of mine, launcher settings, the world of the prologue): the frame line counted 1.3 to 3.7 texture refreshes per frame put off by the guard, that is, that often a staging buffer would have been rewritten while a submission copying from it was still on the card. No exception, no device loss. The A/B against
VICTORY_STAGING_GUARD=0with picture captures is still pending.Oracle and test data
None involved. Failure case:
a_staging_buffer_is_left_alone_while_an_earlier_copy_from_it_may_be_on_the_card(a pure function of the three submission numbers: an earlier copy in the air, landed, none, and the submission's own copy).Checklist
E_NOTIMPL), never a fake success. (Not concerned.)AI assistance: written with Claude Code (Claude Opus 5.5): the reading of the base, the change, its test, the checks on my machine and this description.
🤖 Generated with Claude Code
@LooperSalty on GitHub · 2026-11-26 00:06 UTC · original
Thanks — the guard looks right. The only test covers the
copy_in_flighthelper; could you add one that exercisesrefresh()itself (a staging buffer still read by an in-flight copy is not rewritten), so the test fails without the change? Since it is on by default, a short in-game note (before/after on brief black textures) would also help. Then please mark it ready for review.@KainanP on GitHub · 2026-11-26 10:32 UTC · original
Test report for #254 on three adapters.
Merges cleanly onto current main. Setup: current
origin/main(c4c93bd) merged with this PR, Windows 11,cargo test --lockedinthird_party/victory. Adapters: RTX 4060 Laptop (DXGI 0), Intel UHD 8086:a78b (16-lane waves, no FP64), WARP. The hardware adapter is picked by name through a local, uncommitted test hook and confirmed in its log; WARP for victory-gpu is--features diagnostics+VICTORY_D3D12_WARP=1. victory-gpu runs with--test-threads=1.victory-gpu --lib"main's 3" =
descriptor::host::tests::spans_say_the_next_start_and_the_lowest_level_viewed,indirect::tests::warp_card_fetch_copies_flagged_pieces_to_their_slots,indirect::tests::warp_card_patch_writes_the_masked_bytes_and_no_others. They fail on all three adapters on main too. The newguard_teststest passes everywhere. No new failure.Notes from reading the diff:
copy_in_flightis only tested as a pure function. Nothing testsrefresh+note_copythroughrun_deferred: that a guarded refresh leavesLast/dirtyas they were, so the change is picked up after the landing. That path is where starvation or a lost update would show up. A WARP test with two submissions in the air would cover it.Batch::default()still givessubmission: 0. Any refresh outsideHost::submit's preparing getscopy_in_flight(_, 0, _) == false, so it is never guarded. I think that is right, but a one-line comment at theBatchdefault would say so.AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.