GPU: a frame whose presented image a dropped draw left unwritten is not shown #3353
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!3353
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3353"
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?
@neonbyte1 on GitHub · 2026-11-26 19:53 UTC · original
neonbyte1:fix/hold-unwritten-frames→main· +461 −6 · 6 files · 2 commits · openWhat is wrong
A draw whose pipeline is still being made is dropped once the frame's wait budget is spent, and leaves its render targets as they were. When that draw is the one that writes a presented image, the image still holds what was drawn into it the last time. Titles present two back buffers in turn, so the window alternates between two old frames.
In Grand Theft Auto VI's world start with a cold driver cache (seven runs, RTX 5090, Wine + vkd3d-proton), the first world frame first-binds ~1,900 pipelines. The final upscale (
VS_TAA2_SpatialUpscale+PS_TAA2_SpatialUpscaleWithDithering) is one of them, queued behind the others: in one run it waited 41 s and then took 3.3 ms to make. Until then every other frame was black (the fade's last frame in one back buffer) and the others dim (the first fade-in frame in the other), 46 frames in a row. In every run the flicker stopped within one frame of that pipeline being made; runs whose cache was warm had it before the world started and never flickered.What changes
make::hurry).crate::shown). The log says where a run of held frames starts and ends.HOLD_LIMIT): the pipeline held for is the next one a worker takes, and the longest worker job in my cold-cache runs was 10.5 s (typically 4–6 s). Past it the frames are shown as they come and the log names the pipelines waited for, so a pipeline that never arrives (a dead worker, a hung driver compile) cannot freeze the window.VICTORY_SHOW_UNWRITTEN=1shows those frames as before.Trade-off: a first-use draw into the back buffer (a new HUD element) whose pipeline misses the budget now holds the frame until it is made, which is the next thing a worker makes, instead of showing a frame without it.
Related: #2582/#2435 give full-screen passes their own workers (that would also shorten this if the upscale classifies as one, but never holds), #3025 orders graphics before compute; both edit the same queue in
pipeline/make.rs, so whichever lands second needs a small rebase. I found no open PR that holds the present of an unwritten image.Tested
New tests:
shown::tests(an unwritten image is held once, an image never presented is never held, old images are forgotten, a hold is given up after the limit with an injected clock) andpipeline::make::tests::a_pipeline_a_presented_image_waits_for_goes_first(order, once, not when taken or made). They pass under Wine.clippy
-D warningsforx86_64-pc-windows-msvc, with and without--all-features: clean;cargo xtask policyok.In game: two 8-minute runs of the same build with the driver's and vkd3d-proton's shader caches off (
__GL_SHADER_DISK_CACHE=0 VKD3D_SHADER_CACHE_PATH=0), so the first world frame starts with the backlog every time:made firstvertex 0309a446…, pixel 4f4ec7b1…)Captures of frames 1300–1303 show the alternation without the change (dark, stale grey, dark, stale grey) and a steady image with it.
Not fixed here: after the upscale exists, the world stays dark (brightness 0–1) until a
CS_RaytracingResolvecompute pipeline is made, about 50 s and ~55 frames later in the cold run. That image is written, so holding is not the right tool; making the pipelines that feed the presented image earlier is a follow-up I'm looking at.AI-assisted (Claude); measured on my machine, no game data shared.
@Dukestar69 on GitHub · 2026-11-26 20:07 UTC · original · approved these changes
LGTM — verified on RTX 5090 (Windows / D3D12) against
origin/main(63bcca4).cargo test -p victory-gpu --lib shown:: -- --test-threads=1: all passed.cargo test -p victory-gpu --lib pipeline::make:: -- --test-threads=1: all passed.cargo test -p victory-gpu --lib draw:: -- --test-threads=1: 20 passed, 0 failed.cargo test -p victory-gpu --lib queue:: -- --test-threads=1: 5 passed, 0 failed.cargo clippy -p victory-gpu --all-targets -- -D warnings(default +--features diagnostics): clean.cargo xtask policy: 192 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@andrewpozdnakov7-jpg on GitHub · 2026-11-26 20:14 UTC · original
I resolved the
pipeline/make.rsconflict between this head and #3025 in4a59f2e, retaining both exact heads. A draw that holds presentation goes to the front of the graphics queue. Compute entries still take a compute slot, and a promoted entry already claimed by another worker does not take a second slot. Workers also wait for the final pool size to be published, so an early starter sees the same compute limit as the others.The new regression takes both queues through the two-worker case with the compute slot occupied. The urgent draw goes first, ordinary graphics can follow, and compute resumes when a slot is available. The other queue and presentation tests passed too (11 with default features, 12 with diagnostics). Both strict all-target Clippy checks and the policy check passed. These were scheduler and presentation-state tests.
If this or #3025 lands first, the combined commit is available for the second PR’s rebase. Please preserve the Git author or add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>if you fold in the resolution or test.@neonbyte1 on GitHub · 2026-11-26 20:16 UTC · original
@andrewpozdnakov7-jpg thank you, that saves a careful rebase. I checked that
4a59f2emerges exactly this head (489ec500) and #3025's current head (018b56ac). Keeping urgency within the worker classes, so a held frame's draw goes first in the graphics queue and compute keeps its slot limit, is the right way to combine them. The pool-size wait for early starters is a good catch too.If #3025 lands first, I'll rebase onto your resolution and keep you as the commit's author (or add the
Co-authored-byline if it gets folded in).One heads-up: I have a follow-up on top of this PR that also touches that queue. When the presented image is written but still dark, it walks back from the image and hurries the dropped passes that feed it. It's in testing now and not opened yet, and it uses the same "first" place, so it should fit your resolution as is; I'll check that when I rebase.
AI-assisted (Claude); no game data shared.
@fuzeofficlal on GitHub · 2026-11-26 20:24 UTC · original · approved these changes
Verified locally merged onto
origin/main(63bcca43) at PR head489ec500(Windows 11 x64, NVIDIA GeForce RTX 5090 + Microsoft WARP,VICTORY_D3D12_DEBUG=1):crates/victory-gpu/src/{draw.rs, pipeline.rs, pipeline/make.rs, queue.rs, shown.rs}:draw.rs(L539,L1736-L1738) andpipeline.rs(dropped_into,L259-L273) only flag a presented target and promote its pipeline viamake::hurrywhenmake::being_made(&p.host)is true, so refused/untranslated pipelines and compute indirect dispatches never trigger holds, and clear-only/copy-only frames without dropped draws always show normally.pipeline/make.rs(Place::First,hurried,L232-L246,L292-L309): duplicate front insertion is safely deduplicated byp.taken.swap(true)in the worker loop without double-decrementingWAITING.queue.rs(present,L538,holds,L589-L621):pump_held, frame accounting/budget reset, and diagnostics target dumps still run beforeholds(), so holding does not stall submission progress or wait budgets, andHOLD_LIMITbounds any hold run to 10 s.cargo xtask policy: 192 files ok.cargo clippy --locked -p victory-gpu --all-targets -- -D warnings(default and--all-features): 0 warnings.cargo test --locked -p victory-gpu --features diagnostics --lib -- shown:: pipeline::make:: draw:: queue::: 33/33 passed on both RTX 5090 (0.65s) and WARP (3.09s) withVICTORY_D3D12_DEBUG=1.[unwritten, new]registers both planes and clearsunwrittenvia the non-short-circuiting fold.Two small non-blocking follow-up notes:
shown.rs(unwritten, lines 104-106), whenself.images.remove(0)evicts an old image at capacityIMAGES, removing that pointer fromself.unwrittenas well (self.unwritten.retain(|&s| s != evicted)) prevents a stale entry if a later allocation reuses the same address.shown.rs(frame, lines 172-174),if *SHOW_ALL && matches!(frame, Frame::Hold { .. })suppressesHoldbut still returnsShowAgain { held }/GiveUp { held, waited_for }toqueue.rs::holds(), which can log non-zeroheldcounts even thoughVICTORY_SHOW_UNWRITTEN=1showed every frame.Solid fix overall; synthetic tests only, looks good to merge.
@neonbyte1 on GitHub · 2026-11-26 20:30 UTC · original
@fuzeofficlal thanks for the review and the synthetic probe. Both notes are fixed in
df15a80, a follow-up commit that touches onlyshown.rs:unwritten, so a later image at the same address doesn't inherit the stale mark. New test:an_evicted_image_is_not_left_unwrittenpresentsIMAGES + 1images with the first one unwritten, then the first address again, and expects a plainShow(without the fix it's aHold).VICTORY_SHOW_UNWRITTEN=1:Shown::framenow takes the switch as a parameter. With it on, it returnsShowand clears the held run, the give-up state and the waited-for list, soholds()never seesShowAgain/GiveUpwith counts. New test:show_all_holds_and_counts_nothing(onlyShowacross unwritten frames, past the 10 s limit too; turning the switch off then starts a freshHold { first: true }). Presented images are still recorded with the switch on, so their pipelines are still moved to the front of the queue as before.Tested:
shown::6/6 andpipeline::make::3/3 under Wine, clippy-D warningsdefault and--all-features,cargo xtask policy, formatting.AI-assisted (Claude); no game data shared.
@andrewpozdnakov7-jpg on GitHub · 2026-11-26 20:47 UTC · original
I retested the new eviction and show-all cases at
df15a80together with #3025. Both passed, including with a compute slot occupied and an urgent draw waiting. I also found a separate path into the #2223 queue-count race. If the first registration is paused before the count,hurrycan promote that pipeline before it is counted.Combined commit
335eb7bkeeps the graphics priority and compute cap and waits for completed registration beforehurrycan promote. The new regression fails on the two-PR control and passes with #2223 integrated. All 15 default and 16 diagnostics queue and presentation tests passed, along with strict Clippy in both configurations and the asset policy check. Details in #2223.@neonbyte1, if your follow-up uses the same
hurrypath, it can use this resolution too. If you fold it into another commit, please keep the Git author or useCo-authored-by: andrewpozdnakov7-jpg <[email protected]>.@neonbyte1 on GitHub · 2026-11-26 20:49 UTC · original
@andrewpozdnakov7-jpg thanks again, and good catch. I read it in
make.rs:enqueuesetsqueuedand only then counts the pipeline inWAITING, so ahurryfrom another thread in between can let a worker build it and decrementWAITINGbefore the increment. The counter wraps for a moment, and thedrained()check can misfire.main's existing promotion for a waiting draw has the same window, so #2223 is the right fix for both paths. I'd rather not duplicate its "registration complete" flag in this PR. If this lands first, your335eb7bis the resolution to carry forward, with your authorship kept. My follow-up (hurrying the dropped passes that feed the presented image) goes through the samehurry, so it's covered by the same resolution; I'll rebase it onto whichever order the maintainers pick.AI-assisted (Claude); no game data shared.
@neonbyte1 on GitHub · 2026-11-26 20:58 UTC · original
Follow-up for the dark phase mentioned above: #3378, stacked on this PR. It hurries the dropped passes the presented image reads (at most 8 per present) and remembers them for the next cold start. In the same cold-cache runs, the lighting resolve went from 47–54 s waiting in the queue to being made ~6 s after its first bind, and the next run makes the final upscale before it's needed.
AI-assisted (Claude); measured on my machine, no game data shared.
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.