GPU: upload dirty title textures in HostList::prelude #80
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!80
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-80"
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?
@adritoyalser on GitHub · 2026-11-24 21:18 UTC · original
adritoyalser:fix/prelude-texture-upload→main· +302 −111 · 2 files · 1 commits · openProblem
efresh while the second defer_host cleared dirty), the next CPU write was detiled into the staging buffer at submission without a recorded CopyTextureRegion, so the GPU sampled stale texels until a subsequent use.
efresh (which set dirty = true again), the next submission recorded and executed an extra CopyTextureRegion even when nothing had changed.
Fix
un_deferred() has refreshed staging buffers for the submission.
Verification
@adriaespii on GitHub · 2026-11-24 21:37 UTC · original
Independent test run on commit
231b835(AMD RDNA4):x86_64-pc-windows-msvc)cargo clippy --workspace --all-targets -- -D warnings: 0 warningscargo test --workspace: 498 passed, 0 failed, 7 ignored (victory-gpu: 112 passed, 0 failed, 1 ignored;victory-shader: 210 passed, 0 failed, 2 ignored)AI use: Antigravity (Gemini 4 Neon) ran clippy/tests locally and wrote this report.
@brunofgmag on GitHub · 2026-11-24 22:57 UTC · original
I tested this on Linux (RTX 4080, Proton Experimental) against the startup flicker from #39. The tree was
1684989with #63 and upstream's #1524 applied.The measure is a count of presented frames that repeat a frame from up to six frames back while differing from the frame just before. Each run is 30 s, with every second frame captured from 100 to 600:
texture::uploadswitched off locally so the copy is always recordedWith #63 alone, every repeat that is left has the same cause. The title draws one Bink slot in two frames in a row. The second refresh finds it unchanged and clears
dirty. One cycle later, the next list that uses that slot skips the copy, although its own refresh has already detiled the new picture into staging, so the screen shows the previous cycle's picture. In the run I looked at, each exact repeat comes four frames after such a break in the ring order. This PR records the copy after the refresh, and that removes them.There is also something in the world, from one run of each build, so take it as a lead. In the prison cell, with the skip switched off, the left wall, the window frame and the posters all render. With the skip on, the left wall is missing (the horizon shows through it) and the posters come out in blocks. With this PR the window frame renders, but the left wall is still missing and the main character's shirt is dark. A changed texture may have a second way to miss its copy that this PR doesn't cover. I haven't found it yet. #168 also reports walls missing in the first room.
Thanks to @adritoyalser for the fix, to @arminkhaleghirod for tracing the flicker to the texture guard in #39 and #63, and to @fxceless for the fork.
@brunofgmag on GitHub · 2026-11-24 23:46 UTC · original
A follow-up on the walls, with five runs in the same spot (the prison cell window, nobody touching the pad) on the same tree as before (
1684989with #63 and upstream #1524).The cell's left wall shows up in both runs of the old path with the record-time skip switched off, so every list records its own copy. One run used stock Proton's wineserver and one a patched one. With this PR the wall is missing in all three runs: plain, with
VICTORY_RELAY=2, and with a local switch that makestake_uploadalways return true. The last one rules out thedirtybookkeeping. Even with a copy in every prelude, the wall stays missing.So something else in the move to
HostList::preludeloses it. Two things I noticed but did not test:submit, each list'sprelude()runs inside the loop overruns, andbatch.flush()runs after the loop. A refresh that the batch holds back is not done yet whentake_uploadreadsdirty.COPY_DESTand back to its real state, and the list's own barriers are built fromcopy.state. I could not tell whether that still matches what the copy left behind.The always-copy switch also showed that this PR misses some changes the old path caught: the character's shirt print and the window frame's lighting came back with it. It cost about 2.5 % per frame here (253 ms to 260 ms median with
VICTORY_RELAY=2). So always recording the copy is a cheap fallback if the cause takes a while to find.The PR does fix the flicker. Thanks again to @adritoyalser.
@adritoyalser on GitHub · 2026-11-24 23:51 UTC · original
Thanks for the 5-run follow-up @brunofgmag — forcing
take_upload()to always returntrueis a super useful data point because it isolates the wall difference from thedirtybookkeeping.I double-checked both points in the code:
batch.flush()vsprelude():Step::Texture(staging)runs synchronously insideHostList::run_deferred()(right beforelist.prelude()), not insidebatch.flush()(which only batches bufferStep::Refreshranges). Sostaging.refresh()has already run for that list whentake_upload()checksdirty.prelude(): for each uploaded texture,prelude()transitionsreal -> COPY_DESTinto_copy, recordsCopyTextureRegion, and then transitionsCOPY_DEST -> *first(storing*lastincopy.state), orCOPY_DEST -> realif the list has nostatesentry for it. That matches whatlist.listexpects at entry.That leaves two narrower differences between "always copy in
list.list" and "always copy inlist.prelude()":CopyTextureRegion+COPY_DEST -> SHADER_RESOURCErun in a separate preceding command list beforelist.listrather than inline right before the draw/copy that uses the texture.VICTORY_RELAY=2: if a subsequent submission refreshes the sameStagingbuffer while an earlier prelude'sCopyTextureRegionis still in flight on the GPU, the staging buffer can be overwritten mid-copy (tracked separately in #141).Happy to investigate further or adjust the approach if you spot anything in the logs/captures or if the maintainer prefers a different trade-off here.
@ericomeehan on GitHub · 2026-11-25 00:15 UTC · original
brunofgmag's flicker counts on #39 make a strong case for moving the uploads into
prelude().A heads-up on overlap: #272 changes the same record-time block in
texture.rs(the two don't merge textually). With it, a submission counts as reading a texture's staging buffer only when it recorded a realCopyTextureRegion(defer_texture(staging, uploads)andnote_upload_fenceafter the submission's signal), so a later detile waits for that submission only when the contents changed. With the copy moved intoprelude(), that marking would need to move there too (set wheretake_upload()returns true), or detiles underVICTORY_LATE_WAIT/VICTORY_RELAYcould again overwrite staging that a submission still in flight copies from. Whichever lands second will need to carry that over; a rebase on #272, or comparing notes with fffluffy-dev, might be the easiest route.Written with an AI assistant (Claude).
@brunofgmag on GitHub · 2026-11-25 00:23 UTC · original
Thanks for checking both points, @adritoyalser. I added a local switch at the end of
upload()and ran it again at the same spot with nobody touching the pad. Each run lasts 200 s on an RTX 4080 with Proton Experimental. Both textures that go missing here, the cell's left wall and the window's chain-link fence, show up again once the copy is back inlist.list. They come back for different reasons, though.Tree A is the one from before:
1684989with #63, upstream #1524 and this PR. Tree B is2119b0ewith this PR, #343, #256, #95, #231, #257 and #187.upload()does besides deferring the prelude copyensure_state(list, resource, COPY_DEST)only, no copy in the listensure_state+record_copy(&list.list, texture), prelude copy keptensure_state+record_copy, prelude copy keptensure_state+record_copy, with or without the prelude copyThe wall reading is the mean brightness of the frame's left strip in the last captured frames. It is 3 to 60 where the wall is drawn and 140 to 240 where the sky shows through.
So the fence needs only the list to know the texture's state. That points at the prelude's barriers for a texture the list has no
statesentry for, even though the sequence reads right in the code. The wall needs the copy itself to sit at the first-use point inside the list. A prelude copy, even one made on every submission, does not bring it back. My guess, which I have not checked, is that the list writes that texture on the card before it samples it (a clear or a copy into it), and the old in-list copy overwrote that with the title's contents. The prelude copy runs first and loses to it.The relay is a separate problem. With stage 2 the wall is missing even with the copy in the list, so it is not this PR's doing. It may be the in-flight staging overwrite from your point 2 (#141, #272). In tree B the relay is the default through #187, so I'll note it there.
@adritoyalser on GitHub · 2026-11-25 01:29 UTC · original
Thanks for that ablation table @brunofgmag — that isolates both pieces cleanly:
ensure_state(..., COPY_DEST)only): recordingCOPY_DESTinlist.listforces an inlineCOPY_DEST -> SHADER_RESOURCEbarrier insidelist.listrather than only inprelude(), which points at a prelude-only barrier interaction (possibly withvkd3d-protonor a state mismatch when a texture enterslist.listalready transitioned).record_copyinline inlist.list): needing the copy itself at the first-use point insidelist.list(and not before the list inprelude()) strongly supports your hypothesis that an earlier command inlist.listtouches the texture before the first sampling draw.And good catch separating the
RELAY=2wall loss — I just updated #141 so it only waits on actualdetile()overwrites of real in-flight uploads (avoiding the settle overhead @tycosnh measured there).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.