GPU: let card-buffer readback flag 4 or 16 KiB at a time #1164

Open
github-bot wants to merge 3 commits from github-bot/gh-1164 into main AGit
Owner

@⁠UwUCammie on GitHub · 2026-11-25 22:15 UTC · original
UwUCammie:pr/card-hash-piece → main · +139 −82 · 3 files · 3 commits · open

Changing a few bytes in a card-resident buffer flags a whole 64 KiB piece for readback. VICTORY_CARD_PIECE_KB=4|16|64 lets the compare, hash table and fetch plan use smaller pieces. The default is still 64. The CPU snapshot and write-watch pages keep their original size. In-flight fetch slots still have room for the maximum piece.

On an RX 7900 XT (RADV 26.3.1, Wine 11.22), all seven card-span and ticket tests passed at each size. I also ran the compare and in-flight fetch tests at all three sizes with a local harness selecting the physical D3D12 adapter. All six runs passed, including the writes that changed back and the fetch with an unaligned buffer base.

I ran the same integration binary at all three sizes on the RX 7900 XT. The only setting I changed was the piece size. All three runs finished the 230-second session. These are the complete measurement intervals between 150 and 225 seconds in the first room.

Piece Successful presents / time FPS Draws/frame Median readback MB/frame Median time on copy queue
64 KiB 663 / 73.99 s 8.96 4,895 93.5 5.3 ms
16 KiB 752 / 74.31 s 10.12 4,829 85.8 4.7 ms
4 KiB 591 / 73.67 s 8.02 4,875 59.7 6.3 ms

This integration build used the parallel compare. A second run of the same executable and route measured 538 presents in 73.74 s at 16 KiB (7.30 FPS, 4,867 draws/frame) and 610 in 74.02 s at 64 KiB (8.24 FPS, 4,870 draws/frame). Pooling the two runs for each size gives 8.71 and 8.60 FPS respectively. The switch reduced readback volume in the first comparison. These frame-rate measurements do not establish a reliable winner. The same-scene image comparison is still open.

Updated against 6d20eed after #1014 merged. Both the one-thread and 64-thread hashes now use the chosen piece size. On the physical RX 7900 XT, all three D3D12 fixtures passed for both hashes at all three sizes (18 cases). They cover changes that are restored, shifted buffer bases and ranges that begin at a later piece, and fetching changed pieces through the ticketed readback slots. The 30 shadow tests passed under Wine.

**@⁠UwUCammie** on GitHub · 2026-11-25 22:15 UTC · [original](https://github.com/fxceless/victory-fork/pull/1164) `UwUCammie:pr/card-hash-piece` → `main` · +139 −82 · 3 files · 3 commits · open Changing a few bytes in a card-resident buffer flags a whole 64 KiB piece for readback. `VICTORY_CARD_PIECE_KB=4|16|64` lets the compare, hash table and fetch plan use smaller pieces. The default is still 64. The CPU snapshot and write-watch pages keep their original size. In-flight fetch slots still have room for the maximum piece. On an RX 7900 XT (RADV 26.3.1, Wine 11.22), all seven card-span and ticket tests passed at each size. I also ran the compare and in-flight fetch tests at all three sizes with a local harness selecting the physical D3D12 adapter. All six runs passed, including the writes that changed back and the fetch with an unaligned buffer base. I ran the same integration binary at all three sizes on the RX 7900 XT. The only setting I changed was the piece size. All three runs finished the 230-second session. These are the complete measurement intervals between 150 and 225 seconds in the first room. | Piece | Successful presents / time | FPS | Draws/frame | Median readback MB/frame | Median time on copy queue | | --- | --- | ---: | ---: | ---: | ---: | | 64 KiB | 663 / 73.99 s | 8.96 | 4,895 | 93.5 | 5.3 ms | | 16 KiB | 752 / 74.31 s | 10.12 | 4,829 | 85.8 | 4.7 ms | | 4 KiB | 591 / 73.67 s | 8.02 | 4,875 | 59.7 | 6.3 ms | This integration build used the parallel compare. A second run of the same executable and route measured 538 presents in 73.74 s at 16 KiB (7.30 FPS, 4,867 draws/frame) and 610 in 74.02 s at 64 KiB (8.24 FPS, 4,870 draws/frame). Pooling the two runs for each size gives 8.71 and 8.60 FPS respectively. The switch reduced readback volume in the first comparison. These frame-rate measurements do not establish a reliable winner. The same-scene image comparison is still open. Updated against `6d20eed` after #1014 merged. Both the one-thread and 64-thread hashes now use the chosen piece size. On the physical RX 7900 XT, all three D3D12 fixtures passed for both hashes at all three sizes (18 cases). They cover changes that are restored, shifted buffer bases and ranges that begin at a later piece, and fetching changed pieces through the ticketed readback slots. The 30 shadow tests passed under Wine.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:58:44 +00:00
Author
Owner

@⁠alpz1000 on GitHub · 2026-11-25 22:24 UTC · original · edited 2026-11-25 22:45 UTC

Windows / RTX 3060 follow-up. I combined the piece-size change from d3b2bb9 with the group-per-piece shader from #253 and verified both sizing and shader behavior. The wide shader uses the same piece-size constant as the scalar shader and fetch plan, and dispatches are split at the D3D12 group limit.

All three settings (4, 16 and 64 KiB) passed the WARP compare and fetch cases, the wide-shader change-detection case, and the seven card-span and ticket tests.

I also timed the group shader on an RTX 3060 12 GB, driver 610.88, using generated data in a D3D12 DEFAULT-heap buffer. Medians of nine batches per setting, 16 hash dispatches per batch, with a UAV barrier between dispatches:

Total bytes hashed 64 KiB pieces 16 KiB pieces 4 KiB pieces
64 KiB 5.12 µs 2.30 µs 1.66 µs
256 KiB 5.18 µs 2.43 µs 1.92 µs
4 MiB 13.89 µs 13.70 µs 13.89 µs
32 MiB 97.47 µs 97.60 µs 98.50 µs

The table isolates GPU hashing. It does not measure readback volume or frame time.

Full renderer follow-up on the same Windows and RTX 3060 setup. A warmed 16 KiB run averaged 4.80 FPS over 564 frames at a stationary checkpoint, with a median 30.9 MiB copied back per frame. An earlier 64 KiB run with #253 averaged 4.90 FPS over 449 frames and 35.9 MiB copied back per frame. The 16 KiB build also included the placeholder/guard patch and reduced texture preload limits, so these numbers are a directional comparison across configurations. Visual rendering reached the checkpoint in the 16 KiB run.

AI-assisted with OpenAI Codex.

**@⁠alpz1000** on GitHub · 2026-11-25 22:24 UTC · [original](https://github.com/fxceless/victory-fork/pull/1164#issuecomment-7176315217) · edited 2026-11-25 22:45 UTC Windows / RTX 3060 follow-up. I combined the piece-size change from `d3b2bb9` with the group-per-piece shader from #253 and verified both sizing and shader behavior. The wide shader uses the same piece-size constant as the scalar shader and fetch plan, and dispatches are split at the D3D12 group limit. All three settings (4, 16 and 64 KiB) passed the WARP compare and fetch cases, the wide-shader change-detection case, and the seven card-span and ticket tests. I also timed the group shader on an RTX 3060 12 GB, driver 610.88, using generated data in a D3D12 DEFAULT-heap buffer. Medians of nine batches per setting, 16 hash dispatches per batch, with a UAV barrier between dispatches: | Total bytes hashed | 64 KiB pieces | 16 KiB pieces | 4 KiB pieces | | --- | ---: | ---: | ---: | | 64 KiB | 5.12 µs | 2.30 µs | 1.66 µs | | 256 KiB | 5.18 µs | 2.43 µs | 1.92 µs | | 4 MiB | 13.89 µs | 13.70 µs | 13.89 µs | | 32 MiB | 97.47 µs | 97.60 µs | 98.50 µs | The table isolates GPU hashing. It does not measure readback volume or frame time. Full renderer follow-up on the same Windows and RTX 3060 setup. A warmed 16 KiB run averaged 4.80 FPS over 564 frames at a stationary checkpoint, with a median 30.9 MiB copied back per frame. An earlier 64 KiB run with #253 averaged 4.90 FPS over 449 frames and 35.9 MiB copied back per frame. The 16 KiB build also included the placeholder/guard patch and reduced texture preload limits, so these numbers are a directional comparison across configurations. Visual rendering reached the checkpoint in the 16 KiB run. AI-assisted with OpenAI Codex.
Author
Owner

@⁠Proudnoob4 on GitHub · 2026-11-25 23:17 UTC · original · edited 2026-11-25 23:26 UTC

AI-assisted (Claude Opus 5.5 in OpenCode), measured on my own machine. This replaces two overlapping AI-written reports I posted here earlier; on re-auditing the logs, some of their numbers were single samples or misattributed, and one said there were no visual artifacts, which was wrong.

Setup: RTX 4080 16 GB, Windows 10 22H2, Series X build, diagnostics release, prison-cell scene (~4,800 draws/frame). Three single 360 s runs, so this is a bundle comparison, not an isolated A/B:

  • A fxceless stack, f32 path
  • B = A + a local port of Marvisak/VIctory#2825 native f16
  • C = B + #1168 + #1147 + #1164 (VICTORY_CARD_PIECE_KB=16) + #1171 + #1172 + a local commit (skip clean card_dirty copies; chunk wide compare dispatches to ≤ 65,535 groups)
In-world, from the logs A B C
FPS, 2nd-half median (max) 8.8 (9.3) 8.8 (9.7) 8.9 (9.4)
Usual frame, median 112 ms 111 ms 113 ms
GPU title lists (all other lists), 2nd-half median 40.0 ms 38.1 ms 31.8 ms
cardmeter, 256-frame mean, steady 40.8 ms 40.9 ms 31.6–33.7 ms
Copy-back (last usual-frame summary) 23.2 ms / 62.5 MB 22.4 ms / 60.9 MB 28.4 ms / 49.4 MB
Pieces fetched on the copy queue / frame ~1,370 ~1,388 ~4,138
Writes back in place / frame 1,386 1,390 4,150
Card idle per frame 62.5 ms 68.7 ms 68.8 ms
  • GPU: title-list time fell by ~8 ms between B and C. Native f16 alone (A→B) changed it by ~2 ms at most (cardmeter unchanged). Which of C's additions gave the 8 ms is not isolated.
  • No FPS change: the frame is CPU-bound on the submit thread (copies ~63 ms + copy-back 22–28 ms of a ~110 ms frame), so the GPU saving does not reach the screen.
  • Artifacts in C: a frame grabbed at 330 s shows blocky corrupted tiles along the bottom of the screen and a stair-stepped edge on the character's shoulder. Which change causes it is not isolated. B's earlier frame looked clean.
  • Stability: no panic, device-removed or ERROR lines in C's log, no crash in 360 s.

For this PR: with 16 KiB pieces, copy-back bytes fell ~19% (60.9 → 49.4 MB). But pieces fetched and writes back both tripled (~1,388 → ~4,138), and copy-back time rose 22.4 → 28.4 ms. On this CPU-bound setup that is a net loss. A suggestion I haven't tested: coalescing adjacent dirty pieces into one fetch or write-back might keep the byte saving without the per-piece cost. C was the only run with 16 KiB pieces, so this PR is a suspect for the artifacts above, not proven. The ≤ 65,535-group chunking in our local commit came from reading the code: 16 KiB pieces over a buffer larger than 1 GiB would pass the D3D12 per-dimension dispatch limit with VICTORY_CARD_HASH_WIDE=1. We did not hit it in game, and HASH_WIDE was off in these runs.

**@⁠Proudnoob4** on GitHub · 2026-11-25 23:17 UTC · [original](https://github.com/fxceless/victory-fork/pull/1164#issuecomment-7177367923) · edited 2026-11-25 23:26 UTC *AI-assisted (Claude Opus 5.5 in OpenCode), measured on my own machine. **This replaces two overlapping AI-written reports I posted here earlier; on re-auditing the logs, some of their numbers were single samples or misattributed, and one said there were no visual artifacts, which was wrong.*** **Setup:** RTX 4080 16 GB, Windows 10 22H2, Series X build, diagnostics release, prison-cell scene (~4,800 draws/frame). Three single 360 s runs, so this is a bundle comparison, not an isolated A/B: - **A** fxceless stack, f32 path - **B** = A + a local port of `Marvisak/VIctory#2825` native f16 - **C** = B + `#1168` + `#1147` + `#1164` (`VICTORY_CARD_PIECE_KB=16`) + `#1171` + `#1172` + a local commit (skip clean `card_dirty` copies; chunk wide compare dispatches to ≤ 65,535 groups) | In-world, from the logs | A | B | C | |---|---:|---:|---:| | FPS, 2nd-half median (max) | 8.8 (9.3) | 8.8 (9.7) | 8.9 (9.4) | | Usual frame, median | 112 ms | 111 ms | 113 ms | | GPU title lists (`all other lists`), 2nd-half median | 40.0 ms | 38.1 ms | **31.8 ms** | | `cardmeter`, 256-frame mean, steady | 40.8 ms | 40.9 ms | **31.6–33.7 ms** | | Copy-back (last usual-frame summary) | 23.2 ms / 62.5 MB | 22.4 ms / 60.9 MB | **28.4 ms** / 49.4 MB | | Pieces fetched on the copy queue / frame | ~1,370 | ~1,388 | **~4,138** | | Writes back in place / frame | 1,386 | 1,390 | 4,150 | | Card idle per frame | 62.5 ms | 68.7 ms | 68.8 ms | - **GPU:** title-list time fell by ~8 ms between B and C. Native f16 alone (A→B) changed it by ~2 ms at most (`cardmeter` unchanged). Which of C's additions gave the 8 ms is **not isolated**. - **No FPS change:** the frame is CPU-bound on the submit thread (copies ~63 ms + copy-back 22–28 ms of a ~110 ms frame), so the GPU saving does not reach the screen. - **Artifacts in C:** a frame grabbed at 330 s shows blocky corrupted tiles along the bottom of the screen and a stair-stepped edge on the character's shoulder. Which change causes it is **not isolated**. B's earlier frame looked clean. - **Stability:** no panic, device-removed or ERROR lines in C's log, no crash in 360 s. **For this PR:** with 16 KiB pieces, copy-back bytes fell ~19% (60.9 → 49.4 MB). But pieces fetched and writes back both tripled (~1,388 → ~4,138), and copy-back time rose 22.4 → 28.4 ms. On this CPU-bound setup that is a net loss. A suggestion I haven't tested: coalescing adjacent dirty pieces into one fetch or write-back might keep the byte saving without the per-piece cost. C was the only run with 16 KiB pieces, so this PR is a suspect for the artifacts above, not proven. The ≤ 65,535-group chunking in our local commit came from reading the code: 16 KiB pieces over a buffer larger than 1 GiB would pass the D3D12 per-dimension dispatch limit with `VICTORY_CARD_HASH_WIDE=1`. We did not hit it in game, and HASH_WIDE was off in these runs.
Author
Owner

@⁠UwUCammie on GitHub · 2026-11-26 13:53 UTC · original

@⁠Proudnoob4 Fixed the group-count limit you flagged in a8306950. Both the initial hash and the later comparison split at 65,535 X groups. Each chunk advances the hash index and the output flag address. The boundary regression passed under Wine in both shader layouts, including one piece beyond the limit and a span covering three dispatches.

Your 16 KiB result also matches the tradeoff we saw: fewer readback bytes can still cost more when there are more pieces to land. I’m keeping that setting opt-in. Your artifact run had the wide hash off, so the dispatch fix doesn’t explain those tiles.

**@⁠UwUCammie** on GitHub · 2026-11-26 13:53 UTC · [original](https://github.com/fxceless/victory-fork/pull/1164#issuecomment-7193978477) @⁠Proudnoob4 Fixed the group-count limit you flagged in `a8306950`. Both the initial hash and the later comparison split at 65,535 X groups. Each chunk advances the hash index and the output flag address. The boundary regression passed under Wine in both shader layouts, including one piece beyond the limit and a span covering three dispatches. Your 16 KiB result also matches the tradeoff we saw: fewer readback bytes can still cost more when there are more pieces to land. I’m keeping that setting opt-in. Your artifact run had the wide hash off, so the dispatch fix doesn’t explain those tiles.
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/host.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

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