Skip to content

GPU: preserve the latest draw counter sample across presents - #2340

Open
andrewpozdnakov7-jpg wants to merge 1 commit into
Marvisak:mainfrom
andrewpozdnakov7-jpg:codex2/present-counter-order
Open

andrewpozdnakov7-jpg wants to merge 1 commit into
Marvisak:mainfrom
andrewpozdnakov7-jpg:codex2/present-counter-order

Conversation

@andrewpozdnakov7-jpg

Copy link
Copy Markdown

Two presents can sample the host draw or dispatch counter, then report in the opposite order. present used swap and subtracted the previous value, so a late older sample could underflow and move the saved count backwards.

fetch_max keeps 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, then 15 to the same accounting used by present. The calculation from 940d32f panics on the second sample. After the change, the reported deltas are 12, 0, and 3. 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 <andrewpozdnakov7-jpg@users.noreply.github.com>.

@DenRakEiw DenRakEiw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified against origin/main (940d32f):

  • Using now.saturating_sub(last.fetch_max(now, Ordering::Relaxed)) in since_last_count cleanly prevents overlapping Present calls from rolling back or underflowing the reported draw/dispatch counters.
  • cargo test -p victory-gpu queue::tests: 5/5 passed (including an_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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants