GPU: preserve the latest draw counter sample across presents #2338
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2340"
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?
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-25T11:04:54Z.
Two presents can sample the host draw or dispatch counter, then report in the opposite order.
presentusedswapand subtracted the previous value, so a late older sample could underflow and move the saved count backwards.fetch_maxkeeps the highest reported count. An older sample contributes zero, and the next newer sample reports only the additional work.A synthetic Windows regression delivers samples
12,10, then15to the same accounting used bypresent. The calculation from940d32fpanics on the second sample. After the change, the reported deltas are12,0, and3. All five queue tests, strict GPU Clippy with diagnostics, and the staged asset policy pass.Coordination claim
Please retain the Git author when reapplying this change. If you fold it into another commit, please add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T11:25:24Z.
Review: APPROVED
Verified against
origin/main(940d32f):now.saturating_sub(last.fetch_max(now, Ordering::Relaxed))insince_last_countcleanly prevents overlappingPresentcalls from rolling back or underflowing the reported draw/dispatch counters.cargo test -p victory-gpu queue::tests: 5/5 passed (includingan_older_present_sample_cannot_roll_back_the_reported_count).cargo clippy -p victory-gpu --all-targets -- -D warnings: 0 warnings.cargo xtask policy: 183 files ok.AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T11:51:57Z.
Review: COMMENTED
Draw counter samples preserved across presents via fetch_max instead of swap (saturating). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1.
Imported from Marvisak/VIctory. Originally posted by welisonzika14-jpg on 2026-11-25T12:00:23Z.
First run on NVIDIA hardware here, as far as I can see (the reviews above are static or WARP). RTX 5070 (Blackwell, driver 621.24), Ryzen 7 5700X, Windows 11, Rust 1.98.1 MSVC, no game files. Head
4efd8c7merged ontomain940d32f,cargo test -p victory-gpu -p victory-shader --lib --no-fail-fast.The PR's test
queue::tests::an_older_present_sample_cannot_roll_back_the_reported_countpasses on this card. The rest is the same asmainon this card: the 5 known NVIDIA failures from #1744 (2 view heap cap tests invictory-gpu, 3 invictory-shader), nothing new.One run, unit tests only, title not run.
Written with AI help (Claude/Kiro); the numbers are from runs on my machine.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T15:27:16Z.
Automated triage for the maintainers.
Merge candidate (small). In
queue.rspresent, the per-line draw and dispatch deltas werenow - last.swap(now). If two presents race, the older sample can arrive second and the subtraction underflows: a panic inside anextern "system"function in debug builds, a huge logged count in release. The newsince_last_countusesfetch_maxwithsaturating_sub, so a late older sample reports 0 and the saved count never goes backwards; the unit test covers exactly that ordering. It only affects logging. CI: passing.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:08:34Z.
Automated triage for the maintainers, second look (a review against current
main, with builds and tests where they could change the verdict).Closing because the case cannot occur. The deltas are computed only when the presented frame number is a power of two, and the title presents from one thread, so samples arrive in order. The values feed one info log line.
If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.
Pull request closed