Card steps: fix the stretched characters and boat (places the title writes after sending are learned; submissions reading them wait) #434

Open
github-bot wants to merge 1 commit from github-bot/gh-434 into main AGit
Owner

@⁠Jrjy3 on GitHub · 2026-11-27 06:10 UTC · original
Jrjy3:card-steps-late-writes → main · +250 −2 · 1 files · 1 commits · open

Fixes the stretched characters and boat with card steps on (VICTORY_CARD_STEPS=1 or 2, play.ps1's default), reported in #13: vertices thrown off into long sheets or spikes. It happens a few times a second, gets more frequent the longer a cutscene runs, and gets much worse after the camera moves up and down.

Cause

Without card steps, a submission that sits behind flights waits for them, so every fill in it reads title memory after that wait. The console's GPU reads a constant buffer when the draw runs, which is also late. The title relies on that: it writes some constant buffers again after it has sent the submission that reads them.

With card steps, a taken submission is sent at once, so its fills read the bytes too early. That applies to the fills done on the card and also to the ones left to the CPU, which run while the submission is prepared.

How it was found

R9700, Windows, main 014d52d + #55, the boat cutscene.

Run Stretching
CARD_STEPS=0 none
CARD_STEPS=1, card steps on everywhere but nothing taken (a test switch) none
CARD_STEPS=1 yes
  • What the card read was wrong in 5 places. A diagnostics check read back what each fill done on the card read and compared it with title memory at landing. In each report window, 19 to 700 fills of about 1,600 differed. Every one was a value the title's CPU wrote after sending; none came from a relay put (the relay's own puts were recorded and checked against). They were always the same 5 places, from 240 bytes to 32 KiB.
  • Fixing those 5 wasn't enough. Learning them so their fills wait made the card's reads match, but the stretching stayed. Neither the relay merge nor runs_left caused it: VICTORY_CARD_STEPS_RUNS=0 still stretched.
  • The rest were CPU fills. Comparing the CPU fills of taken submissions as well found two more places, 32 and 544 bytes. With those learned too, the stretching was gone.

Change (host/card_steps.rs only)

  • What gets compared: what each fill of a taken submission read is compared with title memory when the submission lands. For fills done on the card, that's a read-back of the buffer between. Each pooled list keeps one read-back buffer the size of the buffer between, and the read-back is one CopyBufferRegion of the bytes used. For fills done on the CPU, it's the upload memory they filled.
  • What it learns: pages where the bytes differ are learned. From then on, a submission with any fill on such a page is refused (it waits as before, reason a fill reads a place the title was found writing after sending). The first frame on a new place is drawn with the old bytes; after that it's exact.
  • Logging: one line per frame-rate report, plus one line per page learned.
  • Switch: VICTORY_CARD_STEPS_LEARN=0 turns it off.
  • Tests: two new tests, one for card fills and one for CPU fills. cargo test -p victory-gpu card_steps passes 11/11, Clippy is clean on the file, and the diagnostics build compiles.

Cost

At the boat, idle, per frame:

Setting Frame time
CARD_STEPS=1 with this change 88 ms
CARD_STEPS=1 without it 94 ms
CARD_STEPS=0 95 ms

All three are within run-to-run spread. The frame waits on the card, about 70–77 ms of GPU time.

In this title about every submission card steps took has one of these fills, so in practice they mostly wait now. Card steps no longer buy anything here, but they no longer break the picture either. A faster fix would have to let the card read those few places at draw time, which is what the console does. I haven't tried that.

The CI failures are the ones main has now: Clippy's transmute in descriptor_sites.rs, and depth_bounds_pipeline_loads_and_filters_draws.

🤖 Generated with Claude Code

**@⁠Jrjy3** on GitHub · 2026-11-27 06:10 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/434) `Jrjy3:card-steps-late-writes` → `main` · +250 −2 · 1 files · 1 commits · open Fixes the stretched characters and boat with card steps on (`VICTORY_CARD_STEPS=1` or `2`, `play.ps1`'s default), reported in #13: vertices thrown off into long sheets or spikes. It happens a few times a second, gets more frequent the longer a cutscene runs, and gets much worse after the camera moves up and down. ### Cause Without card steps, a submission that sits behind flights waits for them, so every fill in it reads title memory after that wait. The console's GPU reads a constant buffer when the draw runs, which is also late. The title relies on that: it writes some constant buffers again **after** it has sent the submission that reads them. With card steps, a taken submission is sent at once, so its fills read the bytes too early. That applies to the fills done on the card and also to the ones left to the CPU, which run while the submission is prepared. ### How it was found R9700, Windows, main `014d52d` + #55, the boat cutscene. | Run | Stretching | |---|---| | `CARD_STEPS=0` | none | | `CARD_STEPS=1`, card steps on everywhere but nothing taken (a test switch) | none | | `CARD_STEPS=1` | yes | - **What the card read was wrong in 5 places.** A diagnostics check read back what each fill done on the card read and compared it with title memory at landing. In each report window, 19 to 700 fills of about 1,600 differed. Every one was a value the title's CPU wrote after sending; none came from a relay put (the relay's own puts were recorded and checked against). They were always the same 5 places, from 240 bytes to 32 KiB. - **Fixing those 5 wasn't enough.** Learning them so their fills wait made the card's reads match, but the stretching stayed. Neither the relay merge nor `runs_left` caused it: `VICTORY_CARD_STEPS_RUNS=0` still stretched. - **The rest were CPU fills.** Comparing the CPU fills of taken submissions as well found two more places, 32 and 544 bytes. With those learned too, the stretching was gone. ### Change (`host/card_steps.rs` only) - **What gets compared:** what each fill of a taken submission read is compared with title memory when the submission lands. For fills done on the card, that's a read-back of the buffer between. Each pooled list keeps one read-back buffer the size of the buffer between, and the read-back is one `CopyBufferRegion` of the bytes used. For fills done on the CPU, it's the upload memory they filled. - **What it learns:** pages where the bytes differ are learned. From then on, a submission with any fill on such a page is refused (it waits as before, reason `a fill reads a place the title was found writing after sending`). The first frame on a new place is drawn with the old bytes; after that it's exact. - **Logging:** one line per frame-rate report, plus one line per page learned. - **Switch:** `VICTORY_CARD_STEPS_LEARN=0` turns it off. - **Tests:** two new tests, one for card fills and one for CPU fills. `cargo test -p victory-gpu card_steps` passes 11/11, Clippy is clean on the file, and the diagnostics build compiles. ### Cost At the boat, idle, per frame: | Setting | Frame time | |---|---| | `CARD_STEPS=1` with this change | 88 ms | | `CARD_STEPS=1` without it | 94 ms | | `CARD_STEPS=0` | 95 ms | All three are within run-to-run spread. The frame waits on the card, about 70–77 ms of GPU time. In this title about every submission card steps took has one of these fills, so in practice they mostly wait now. Card steps no longer buy anything here, but they no longer break the picture either. A faster fix would have to let the card read those few places at draw time, which is what the console does. I haven't tried that. The CI failures are the ones `main` has now: Clippy's `transmute` in `descriptor_sites.rs`, and `depth_bounds_pipeline_loads_and_filters_draws`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Without card steps a submission behind flights waits, and all its fills read
title memory after that; the console's card reads a constant buffer when the
draw runs. Taken, the submission goes at once, and its fills (on the card and
the ones left to the CPU) read the bytes then. The title writes some constant
buffers again between sending and landing (at the boat five places of 240
bytes to 32 KiB read on the card and two of 32 and 544 bytes read on the CPU,
the same ones each frame): skinned characters and the boat threw vertices off
(VICTORY_CARD_STEPS=1 and 2), worse over a cutscene and with the camera moved.

What each fill of a taken submission read (read back from the buffer between,
or the upload memory it filled) is compared with title memory at landing;
pages where they differ are learned, and a submission with any fill there
waits. At the boat: no stretching, 88 ms a frame against 94 without the check
and 95 without card steps. VICTORY_CARD_STEPS_LEARN=0: as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 06:14:25 +00:00
Author
Owner

@⁠UwUCammie on GitHub · 2026-11-27 06:30 UTC · original

I ported the late-fill check to the AMD branch and kept its existing card-step planner. The Windows MSVC build passed nine tests under Wine, including changed and unchanged title pages for both fill paths in one fixture. The separate flight test is still pending. I’ll check the same saved route with learning off and on to see whether it addresses the geometry stretching on RX 7900 XT/RADV. AMD #56

**@⁠UwUCammie** on GitHub · 2026-11-27 06:30 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/434#issuecomment-7211596226) I ported the late-fill check to the AMD branch and kept its existing card-step planner. The Windows MSVC build passed nine tests under Wine, including changed and unchanged title pages for both fill paths in one fixture. The separate flight test is still pending. I’ll check the same saved route with learning off and on to see whether it addresses the geometry stretching on RX 7900 XT/RADV. [AMD #56](https://github.com/jtrudeau1530/VIctory-7900XTX/pull/56)
Author
Owner

@⁠UwUCammie on GitHub · 2026-11-27 06:45 UTC · original

The standalone flight test now passes with learning off and on in separate processes on the RX 7900 XT (RADV 26.3.1, GE vkd3d-proton cae8353ed7959c4). Both runs used relay 2 and card steps 2. This exercises copy and fill ordering across submissions with generated buffers. The saved replay is queued separately. AMD #56

**@⁠UwUCammie** on GitHub · 2026-11-27 06:45 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/434#issuecomment-7211813455) The standalone flight test now passes with learning off and on in separate processes on the RX 7900 XT (RADV 26.3.1, GE vkd3d-proton `cae8353ed7959c4`). Both runs used relay 2 and card steps 2. This exercises copy and fill ordering across submissions with generated buffers. The saved replay is queued separately. [AMD #56](https://github.com/jtrudeau1530/VIctory-7900XTX/pull/56)
Author
Owner

@⁠YaBulochka on GitHub · 2026-11-27 10:13 UTC · original

Tested this branch on Linux under Wine, on top of #440's linux-wine-pr (48b49c7 = b62290c + this branch merged, no conflicts). The learning works, but it does not stop the stretching here, and the one switch that does is the relay.

Environment: RX 7600 XT 8 GB (RDNA3), Mesa 27.0.0-devel (RADV), Wine 11.22 (system), kernel 7.3.5, 30 GB RAM, Series S, 1280x720, VICTORY_RENDER_SCALE=1.0, VICTORY_UPSCALER=6, plus #440's 1080p preset (PORT_CONSTANTS, PORT_DESCRIPTORS, PORT_CBV, FRAME_INTERVAL_MS=16.667 + DRAWS=500, CARD_BUFFERS_MIN_KB=64, JOIN_PARTS_DRAWS=500), textures 3 GB, card buffers 2 GB.

VICTORY_RELAY VICTORY_CARD_STEPS Frame Character meshes
2 2 43 ms still stretch, a few times a second
2 0 42-43 ms same as above, no change
1 2 ~45 ms same as above
0 2 69-75 ms in the world (124 ms while streaming) clean, not one stretched sheet in the same places

With this branch merged, RELAY=2 CARD_STEPS=2 still stretches. The log does show the waits it adds (waits for a fill of upload memory +0xd0 (last at 0xe51b7bfe30), +0xf0, +0x1e0, +0xb0), so it is learning something — it just is not what moves these vertices.

What this points at: with the relay on, something a draw reads is still a submission's own early bytes, and it is not a title CPU write to a page (your comparison would have caught it) and not the card steps' fills (off changes nothing). The two candidates left are the landing of shader writes (a skinning pass's output read before it lands) and a descriptor table rewritten after the send.

Is there already a path that pays for "reads what a flight's shaders wrote" as opposed to "reads a page the title later wrote"? If yes, that is the switch I should be testing; if not, this may be a second, unrelated race on the same relay.

For reference, RELAY=0 on this card costs about 60 % (43 -> 70 ms), so it is not a usable setting, only a diagnostic.

**@⁠YaBulochka** on GitHub · 2026-11-27 10:13 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/434#issuecomment-7215623102) Tested this branch on Linux under Wine, on top of #440's `linux-wine-pr` (`48b49c7` = `b62290c` + this branch merged, no conflicts). The learning works, but it does not stop the stretching here, and the one switch that does is the relay. Environment: RX 7600 XT 8 GB (RDNA3), Mesa 27.0.0-devel (RADV), Wine 11.22 (system), kernel 7.3.5, 30 GB RAM, Series S, 1280x720, `VICTORY_RENDER_SCALE=1.0`, `VICTORY_UPSCALER=6`, plus #440's 1080p preset (`PORT_CONSTANTS`, `PORT_DESCRIPTORS`, `PORT_CBV`, `FRAME_INTERVAL_MS=16.667` + `DRAWS=500`, `CARD_BUFFERS_MIN_KB=64`, `JOIN_PARTS_DRAWS=500`), textures 3 GB, card buffers 2 GB. | `VICTORY_RELAY` | `VICTORY_CARD_STEPS` | Frame | Character meshes | |---|---|---|---| | 2 | 2 | 43 ms | still stretch, a few times a second | | 2 | 0 | 42-43 ms | same as above, no change | | 1 | 2 | ~45 ms | same as above | | 0 | 2 | 69-75 ms in the world (124 ms while streaming) | **clean**, not one stretched sheet in the same places | With this branch merged, `RELAY=2 CARD_STEPS=2` still stretches. The log does show the waits it adds (`waits for a fill of upload memory +0xd0 (last at 0xe51b7bfe30)`, `+0xf0`, `+0x1e0`, `+0xb0`), so it is learning something — it just is not what moves these vertices. What this points at: with the relay on, something a draw reads is still a submission's own early bytes, and it is not a title CPU write to a page (your comparison would have caught it) and not the card steps' fills (off changes nothing). The two candidates left are the landing of shader writes (a skinning pass's output read before it lands) and a descriptor table rewritten after the send. Is there already a path that pays for "reads what a flight's shaders wrote" as opposed to "reads a page the title later wrote"? If yes, that is the switch I should be testing; if not, this may be a second, unrelated race on the same relay. For reference, `RELAY=0` on this card costs about 60 % (43 -> 70 ms), so it is not a usable setting, only a diagnostic.
Author
Owner

@⁠UwUCammie on GitHub · 2026-11-27 10:28 UTC · original

I brought this over to the current #440 Wine test build and kept its placement-order behavior. The nine focused Windows MSVC tests passed under Wine 11.22, including both CPU and GPU late-fill comparisons with distinct live pages. The flight test also passed with the switch off and on on an RX 7900 XT, RADV 26.3.1, with vkd3d-proton 71cae091.

I’ve queued an off/on replay of the same indoor save at 720p. That will show whether this path is exercised there and whether the visible flicker changes. Wine port and fixture results

**@⁠UwUCammie** on GitHub · 2026-11-27 10:28 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/434#issuecomment-7215936836) I brought this over to the current #440 Wine test build and kept its placement-order behavior. The nine focused Windows MSVC tests passed under Wine 11.22, including both CPU and GPU late-fill comparisons with distinct live pages. The flight test also passed with the switch off and on on an RX 7900 XT, RADV 26.3.1, with vkd3d-proton `71cae091`. I’ve queued an off/on replay of the same indoor save at 720p. That will show whether this path is exercised there and whether the visible flicker changes. [Wine port and fixture results](https://github.com/UwUCammie/victory-amd/commit/52414bb7)
This pull request can be merged automatically.
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/434/head:github-bot/gh-434'
git switch 'github-bot/gh-434'

Merge

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