GPU: a frame wait takes its tick before it sleeps #174
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!174
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/174/head"
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?
@AndyLatimer on GitHub · 2026-11-24 01:06 UTC · original
AndyLatimer:fix/gpu-frame-wait-reserves-tick→main· +29 −11 · 1 files · 2 commits · merged 2026-11-25 00:18 UTCThe
frame.rsmodule doc says each event kind (origin, vblank, flip) happens once per tick, so two waits for the same kind never end on the same tick.waitpicked the next tick innext_tickunder the clock's lock, but marked it as taken (LAST[kind]) only afterstd::thread::sleep, with the lock released. Two threads waiting for one kind at the same time therefore both read the sameLAST, both got tick T, and both returnedS_OKon it. For the origin, that begins two frames (FRAME+= 2) in one interval.next_ticknow takes alimit(the wait's time-out). When the tick comes within it,next_tickrecords the tick under the clock's lock, before anyone sleeps. A wait that times out takes no tick, as before. Sequential waits behave as before.Testing
cargo test --workspace: 265 passed, 4 ignored (need external files). Includes 1 new test,waits_begun_together_take_different_ticks: twonext_tickcalls before any sleep get different ticks, and a timed-out call leavesLASTalone. It fails on the old behaviour ("1 after 1"), checked by putting it back.cargo clippy --workspace --all-targets: no new warnings. The two that remain (xmem.rsandhost.rs:267) are onmain.cargo xtask policy: pass.rustfmt --checkonframe.rs: clean.🤖 Generated with Claude Code
@DaviTostes on GitHub · 2026-11-24 01:21 UTC · original
Tested
810f442under Wine 11.22 + vkd3d-proton 3.1 on Arch Linux x86_64 (AMD RX 9060 XT, RADV 26.3.1), Windows build withcargo xwin ... --target x86_64-pc-windows-msvcand a native Microsoftd3dcompiler_47: pass, no regression.victory_gpu: 42 passed, 2 failed, 1 ignored, including the 1 test this PR adds.a_rejected_blob_gives_an_empty_library(vkd3d needs a non-empty blob) and #128.host::batch::texture_checks_per_submission(benchmark).No game data used.
@Sunkiller-qc on GitHub · 2026-11-24 01:29 UTC · original
The
diagnosticsbuild no longer compiles with this change.waitnow drops the tick (let (_, wait) = next_tick(kind, limit);atcrates/victory-gpu/src/frame.rs:133), but the#[cfg(feature = "diagnostics")]tracing::debug!further down still logstick(frame.rs:156), so thediagbuild fails with E0425. Keeping the binding (let (tick, wait) = ...) fixes it. The logic change itself looks right to me.Static review, not built or run.
@r4tedx on GitHub · 2026-11-24 03:29 UTC · original
Review note: merged onto current
main(d2a4bae), the default build is fine but the diagnostics build does not compile:(
cargo check -p victory-gpu --features diagnostics;mainalone builds with that feature.)waitno longer bindstick, and the tracing call underdiagnosticsstill names it. Testers use the diagnostics build for device-removal reports, so it is worth fixing before this goes in.From building only; I have no copy of the title.
@AndyLatimer on GitHub · 2026-11-24 07:46 UTC · original
Thanks @Sunkiller-qc and @r4tedx, you are right. Fixed on the new head
882664e:waitbinds the tick again for thediagnosticslog (withunused_variablesallowed when the feature is off).cargo check -p victory-gpunow passes with and without--features diagnostics, no warnings, and the frame tests pass.@alexdeliu on GitHub · 2026-11-24 18:45 UTC · original
Heads-up: #319 (
b36bd4c1) and #174 (882664e1) each pass onmain, but merged togetherframe::tests::waits_end_on_ticks_and_count_framesfails on every run (left: 10, right: 11atframe.rs:254).#174 moves taking the tick (
last(kind).fetch_max) intonext_tick. #319 adds an earlyreturn (passed, Duration::ZERO)for a late flip wait, before that point, so the late wait's tick is never taken. Taking it in the early return too fixes it. The tests pass (710 in the merge train):Whichever of the two lands second needs this. It is in
e3f72c57on the train branch.@Marvisak on GitHub · 2026-11-25 00:21 UTC · original
Automated triage for the maintainers.
Merge candidate. In
crates/victory-gpu/src/frame.rs,waitchose its tick innext_tickunder the clock lock but recorded it inLASTonly after sleeping, so two threads waiting for the same kind could both end on one tick (for the origin wait, two frames in one interval).next_ticknow takes the time-out and records the tick under the lock when the wait will not time out; timed-out waits still take no tick, and single-thread behaviour is unchanged. Thediagnosticsbuild issue raised in review is fixed on this head, and the new test fails on the old order.Note for whoever merges: #319 adds an early return in
next_tickthat would also need to record its tick, so whichever lands second needs that line.CI: no check runs on the head commit.
Generated by Claude Code