GPU: heap pacing against stretched-triangle spikes (#90), opt-in for now #357

Open
github-bot wants to merge 2 commits from github-bot/gh-357 into main AGit
Owner

@⁠cafeoh on GitHub · 2026-11-27 19:39 UTC · original
cafeoh:pr/heap-sync-pace → main · +127 −0 · 4 files · 2 commits · open

What it fixes

Fixes #90: the stretched-triangle spikes ("wedges"), seen on both Series S and Series X.

The title reuses its descriptor slots every frame. On the console that's safe: the card runs right behind the title.
Here, our preparing puts the card about a frame behind. So the title's records for frame F+1 reached the host heaps while the card still drew F, and F's draws read F+1's buffer addresses.

Timeline: today the card runs a frame behind, so F3 rewrites slot B while the card still reads it for F2. With the fix, our side waits for the card, and the card idles in the gaps.

What it does

Our side prepares a submission only once the card has run the last frame we sent. The heaps' own 4 ms sync rounds stop too.
The title is not held. Only our side waits.
VICTORY_HEAP_SYNC_PACE=1 turns it on. Off by default for now. The frame line counts submissions held and ms held.

Proof (RTX 2080 Ti, Ryzen 7 7800X3D)

Off (default) On (=1)
Wedges, Series S (cell, inmates) yes no (3 runs)
Wedges, Series X yes no (1 run, our test branch)
Host heap writes per frame while the card hadn't finished the last frame ~8,340 ~160
fps, Series S, café / cell 17.05 / 18.61 12.5 / 13.7

Holding only the sync rounds was not enough: several writers land early (our translation threads, card steps, the title's view calls). Counter and every test: see #90.

Why some PCs see it and others don't

It needs the card to run behind the title: a fast CPU with a slower card, long preparing, busy scenes. A very fast card, or vsync/a frame cap, hides it. So it can look fine on one PC and broken on another.

Why opt-in for now

It costs about a quarter of the frame rate on our PC: the card idles while our side waits. Elsewhere it depends on how our preparing compares with the card's time: little when one is much faster than the other, up to about half when they are equal. Off by default while a narrower wait is checked (see #90).
The same race could plausibly cause other one-frame glitches (texture blinking, objects jumping). Not verified: see #90.

Real fix later

One host heap copy per frame in flight. Then the next frame's records never overwrite the ones the card still reads, and the cost goes away. That's a bigger change (lists bake heap addresses).

**@⁠cafeoh** on GitHub · 2026-11-27 19:39 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/357) `cafeoh:pr/heap-sync-pace` → `main` · +127 −0 · 4 files · 2 commits · open **What it fixes** Fixes #90: the stretched-triangle spikes ("wedges"), seen on both Series S and Series X. The title reuses its descriptor slots every frame. On the console that's safe: the card runs right behind the title. Here, our preparing puts the card about a frame behind. So the title's records for frame F+1 reached the host heaps while the card still drew F, and F's draws read F+1's buffer addresses. <picture> <source media="(prefers-color-scheme: dark)" srcset="https://github.com/user-attachments/assets/13f31425-e849-4a4a-9a84-ba44a34b5494"> <img width="680" alt="Timeline: today the card runs a frame behind, so F3 rewrites slot B while the card still reads it for F2. With the fix, our side waits for the card, and the card idles in the gaps." src="https://github.com/user-attachments/assets/b4c36621-ad67-468d-be87-e7faef46cfe1"> </picture> **What it does** Our side prepares a submission only once the card has run the last frame we sent. The heaps' own 4 ms sync rounds stop too. The title is not held. Only our side waits. `VICTORY_HEAP_SYNC_PACE=1` turns it on. Off by default for now. The frame line counts submissions held and ms held. **Proof** (RTX 2080 Ti, Ryzen 7 7800X3D) | | Off (default) | On (`=1`) | |---|---|---| | Wedges, Series S (cell, inmates) | yes | no (3 runs) | | Wedges, Series X | yes | no (1 run, our test branch) | | Host heap writes per frame while the card hadn't finished the last frame | ~8,340 | ~160 | | fps, Series S, café / cell | 17.05 / 18.61 | 12.5 / 13.7 | Holding only the sync rounds was not enough: several writers land early (our translation threads, card steps, the title's view calls). Counter and every test: see #90. **Why some PCs see it and others don't** It needs the card to run behind the title: a fast CPU with a slower card, long preparing, busy scenes. A very fast card, or vsync/a frame cap, hides it. So it can look fine on one PC and broken on another. **Why opt-in for now** It costs about a quarter of the frame rate on our PC: the card idles while our side waits. Elsewhere it depends on how our preparing compares with the card's time: little when one is much faster than the other, up to about half when they are equal. Off by default while a narrower wait is checked (see #90). The same race could plausibly cause other one-frame glitches (texture blinking, objects jumping). Not verified: see #90. **Real fix later** One host heap copy per frame in flight. Then the next frame's records never overwrite the ones the card still reads, and the cost goes away. That's a bigger change (lists bake heap addresses).
Our side prepares a submission only once the card has run the last frame we
sent, and the host heaps' own sync rounds stop. Without it, the title's
descriptor records for frame F+1 reached the host heaps while the card still
drew frame F, so F's draws read F+1's views: stretched triangles. Seen on
Series S and Series X. The title is not held. VICTORY_HEAP_SYNC_PACE=0 turns
it off; it costs frame rate until the heaps get one copy per frame in flight.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 19:44:35 +00:00
github-bot changed title from GPU: heap pacing against stretched-triangle spikes (#90), on by default to GPU: heap pacing against stretched-triangle spikes (#90), opt-in for now 2026-11-27 20:18:44 +00:00
Author
Owner

@⁠hamdanpor-ctrl on GitHub · 2026-11-27 22:42 UTC · original

Build and test check on a laptop, no game run (default settings, so the opt-in pacing itself is not exercised):

  • PC: RTX 3050 Laptop GPU 4 GB (driver 617.42), i7-12700H, 16 GB, Windows 11 Pro; Rust 1.98.1
  • This PR's own diff (6d20a25 against its merge base) applied on main at 0148258
  • Clippy with and without --all-features: clean
  • cargo test -p victory-gpu --locked, parallel: 9 of 10 runs passed (527 tests each). The one failure was host::refresh_tests::raw_title_copy_keeps_write_watch_and_resends_equal_bytes, which also fails now and then on main (#354, addressed in #382), so not from this change.

AI-assisted (Claude Code).

**@⁠hamdanpor-ctrl** on GitHub · 2026-11-27 22:42 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/357#issuecomment-7229544428) Build and test check on a laptop, no game run (default settings, so the opt-in pacing itself is not exercised): - PC: RTX 3050 Laptop GPU 4 GB (driver 617.42), i7-12700H, 16 GB, Windows 11 Pro; Rust 1.98.1 - This PR's own diff (`6d20a25` against its merge base) applied on `main` at `0148258` - Clippy with and without `--all-features`: clean - `cargo test -p victory-gpu --locked`, parallel: 9 of 10 runs passed (527 tests each). The one failure was `host::refresh_tests::raw_title_copy_keeps_write_watch_and_resends_equal_bytes`, which also fails now and then on `main` (#354, addressed in #382), so not from this change. AI-assisted (Claude Code).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/357/head:github-bot/gh-357'
git switch 'github-bot/gh-357'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-357'
git switch 'github-bot/gh-357'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-357'
git switch 'github-bot/gh-357'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-357'
git switch 'main'
git merge --squash 'github-bot/gh-357'
git switch 'main'
git merge --ff-only 'github-bot/gh-357'
git switch 'main'
git merge 'github-bot/gh-357'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.