fix(gpu): count only descriptor header changes as missed writes (#519) #530

Open
github-bot wants to merge 2 commits from github-bot/gh-530 into a-publier AGit
Owner

@⁠hajduzsolt on GitHub · 2026-11-27 09:52 UTC · original
hajduzsolt:fix/issue-519-descriptor-diagnostics → a-publier · +205 −57 · 4 files · 2 commits · open

Closes #519.

The port 2 fallback previously counted a change anywhere in a 32-byte slot as a missed view write. Both compare paths now distinguish the 12-byte view header from its trailing bytes. The fallback reports unmarked tail changes separately. Slots still follow the existing refresh path, and the in-place scan uses a reusable bit mask for the current range.

This gives RX 9070 XT descriptor and FSR investigations a cleaner count of missed view writes without a second per-slot shadow map. No in-game frame-time claim is made.

Verification against a-publier at 4eb6cfd: all-targets check, strict Clippy with and without diagnostics, and asset policy passed. All 396 default and 445 diagnostics victory-gpu tests passed. The full workspace runs reproduced only the recorded baseline failures in the HLE loopback test and the shader test process.

AI assistance: ChatGPT 6.2 Sol Extra High.

**@⁠hajduzsolt** on GitHub · 2026-11-27 09:52 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/530) `hajduzsolt:fix/issue-519-descriptor-diagnostics` → `a-publier` · +205 −57 · 4 files · 2 commits · open Closes #519. The port 2 fallback previously counted a change anywhere in a 32-byte slot as a missed view write. Both compare paths now distinguish the 12-byte view header from its trailing bytes. The fallback reports unmarked tail changes separately. Slots still follow the existing refresh path, and the in-place scan uses a reusable bit mask for the current range. This gives RX 9070 XT descriptor and FSR investigations a cleaner count of missed view writes without a second per-slot shadow map. No in-game frame-time claim is made. Verification against a-publier at 4eb6cfd: all-targets check, strict Clippy with and without diagnostics, and asset policy passed. All 396 default and 445 diagnostics victory-gpu tests passed. The full workspace runs reproduced only the recorded baseline failures in the HLE loopback test and the shader test process. AI assistance: ChatGPT 6.2 Sol Extra High.
Classify header changes in both compare paths. Keep the descriptor refresh behavior and report tail-only changes separately without a per-slot shadow map.

AI-Assisted-By: ChatGPT 6.2 Sol Extra High
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 10:41:03 +00:00
Author
Owner

@⁠gw1337x on GitHub · 2026-11-27 11:29 UTC · original

In-game numbers on RDNA 3 with VICTORY_PORT_DESCRIPTORS=1. Memory Integrity was off.

PC: Ryzen 7 9800X3D, RX 7800 XT, 32 GB. Test: 270 s hands-off boat scene, RT off, Belobug launcher settings plus the 5 port switches. #530 on 4eb6cfd vs 4eb6cfd, interleaved (PR, base, PR). Values are per frame, averaged over every port 2 line in the run (about 255 lines each).

#530 run 1 base #530 run 2
view records no store told of 2.48 169.64 2.41
of them of draws' tables 0.71 26.80 0.70
unmarked views with only non-header bytes changed (new) 174.0 n/a 170.2
steady fps (last minute, layer log) 28.4 28.6 28.6
device loss lines 0 0 0

In this scene almost all of what the base counts as missed writes (about 170 a frame) are tail-only changes. The count of real header misses is about 2.4 a frame. Frame rate is unchanged, as expected from a counting change.

**@⁠gw1337x** on GitHub · 2026-11-27 11:29 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/530#issuecomment-7217132692) In-game numbers on RDNA 3 with `VICTORY_PORT_DESCRIPTORS=1`. Memory Integrity was off. PC: Ryzen 7 9800X3D, RX 7800 XT, 32 GB. Test: 270 s hands-off boat scene, RT off, Belobug launcher settings plus the 5 port switches. #530 on `4eb6cfd` vs `4eb6cfd`, interleaved (PR, base, PR). Values are per frame, averaged over every port 2 line in the run (about 255 lines each). | | #530 run 1 | base | #530 run 2 | |---|---|---|---| | view records no store told of | 2.48 | 169.64 | 2.41 | | of them of draws' tables | 0.71 | 26.80 | 0.70 | | unmarked views with only non-header bytes changed (new) | 174.0 | n/a | 170.2 | | steady fps (last minute, layer log) | 28.4 | 28.6 | 28.6 | | device loss lines | 0 | 0 | 0 | In this scene almost all of what the base counts as missed writes (about 170 a frame) are tail-only changes. The count of real header misses is about 2.4 a frame. Frame rate is unchanged, as expected from a counting change.
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-27 11:40 UTC · original

Tested on an RX 6950 XT (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300, Rust 1.98.1, release. At 71dd7ca: victory-gpu 396 passed, 0 failed, 34 ignored.

AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-27 11:40 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/530#issuecomment-7217340576) Tested on an RX 6950 XT (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300, Rust 1.98.1, release. At `71dd7ca`: `victory-gpu` 396 passed, 0 failed, 34 ignored. AI-assisted (Claude Code); no game data.
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-27 11:41 UTC · original

Thanks for picking up #519. I tested 71dd7ca on Windows 11 with an RX 7900 XT (RDNA3).

Tests. I ran the full cargo test --locked -p victory-gpu --lib 20 times, with #462's test fix (4ed2b5f, 281b850) cherry-picked so its race doesn't mix in:

runs passed
#530 19 of 20 (one failure of watch::tests::freed_memory_leaves_no_notes, watch.rs:4324)
4eb6cfd 19 of 20 (one failure of watch::tests::a_write_opens_the_view_it_goes_through, watch.rs:4789)

Both failures are in watch tests, which #530 doesn't touch. Even with #462's fix in, the watch tests still fail now and then.

Reading the diff. It does what #519 suggested, and I could not find a case where it changes which slots are made, waited or nulled. same_head only reaches missed(). Things I checked:

  • The asm reads the fifth argument from [rsp + 40] on entry, the Win64 slot, and before anything touches the stack. The new instructions sit outside the changed_at..changed_after fault window.
  • and eax, 0xFFF / cmp on the vpmovmskb equality mask means bytes 0..11 are equal, and the je before it means some byte differs. So the bit is set exactly for a tail-only change.
  • The head is compared before the last-seen copy is overwritten, in both the asm and changed_records.
  • The last-seen copy starts zeroed in copied_begin, so a view seen for the first time still counts as missed.

I had a version of this locally that kept a separate 8-byte head per slot. Yours is better: it needs no extra memory, and it has no blind spot right after the heap is adopted.

Small things, none blocking:

  1. The doc comments still give the old meaning. CHECKED[1] and MISSED_ALL (port_descriptors.rs:531-537) say "view records no mark told of", and missed()'s comment (:408-409) says such a record "is counted and said". Both now apply only to records whose head changed.
  2. The new count is per line only. A since-start total next to view records missed would show the split for a whole run in the last line.
  3. Tests don't reach Copied::changes_in_place's mapping of the same_head bits back to indices, or safecopy::changed with a mask and a page that faults part-way.

In-game. One measured run of a diag build of 71dd7ca, after a warm-up launch of the same build. Route and settings as in #519: title screen, then the opening cutscene with no input, all five VICTORY_PORT_*=1. Window from the first frame of 500 draws or more to window closed: 267.9 s, 4,169 frames, median 16.4 fps. No ERROR, panic or device removal.

per frame #519's diagnostic build (cd8dfc0 + #354) #530 (4eb6cfd + #530)
view records no store told of, median 2.0 2.06
same, from the since-start view records missed delta 2.14 2.14
tail-only changes (#519: same head), median 134.8 139.2
fallback time, median 0.68 ms 0.62 ms

The missed count now means what it says, and it matches the per-slot head check in #519. This agrees with gw1337x's boat-scene numbers above, on another RDNA3 card. The memcpy/memmove hook still marked 0 records.

Not tested: gameplay, other GPUs, repeat runs.

**@⁠adrianmjim** on GitHub · 2026-11-27 11:41 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/530#issuecomment-7217360263) Thanks for picking up #519. I tested 71dd7ca on Windows 11 with an RX 7900 XT (RDNA3). **Tests.** I ran the full `cargo test --locked -p victory-gpu --lib` 20 times, with #462's test fix (4ed2b5f, 281b850) cherry-picked so its race doesn't mix in: | | runs passed | |---|---| | #530 | 19 of 20 (one failure of `watch::tests::freed_memory_leaves_no_notes`, watch.rs:4324) | | 4eb6cfd | 19 of 20 (one failure of `watch::tests::a_write_opens_the_view_it_goes_through`, watch.rs:4789) | Both failures are in `watch` tests, which #530 doesn't touch. Even with #462's fix in, the watch tests still fail now and then. **Reading the diff.** It does what #519 suggested, and I could not find a case where it changes which slots are made, waited or nulled. `same_head` only reaches `missed()`. Things I checked: - The asm reads the fifth argument from `[rsp + 40]` on entry, the Win64 slot, and before anything touches the stack. The new instructions sit outside the `changed_at..changed_after` fault window. - `and eax, 0xFFF / cmp` on the `vpmovmskb` equality mask means bytes 0..11 are equal, and the `je` before it means some byte differs. So the bit is set exactly for a tail-only change. - The head is compared before the last-seen copy is overwritten, in both the asm and `changed_records`. - The last-seen copy starts zeroed in `copied_begin`, so a view seen for the first time still counts as missed. I had a version of this locally that kept a separate 8-byte head per slot. Yours is better: it needs no extra memory, and it has no blind spot right after the heap is adopted. **Small things, none blocking:** 1. The doc comments still give the old meaning. `CHECKED[1]` and `MISSED_ALL` (port_descriptors.rs:531-537) say "view records no mark told of", and `missed()`'s comment (:408-409) says such a record "is counted and said". Both now apply only to records whose head changed. 2. The new count is per line only. A since-start total next to `view records missed` would show the split for a whole run in the last line. 3. Tests don't reach `Copied::changes_in_place`'s mapping of the `same_head` bits back to indices, or `safecopy::changed` with a mask and a page that faults part-way. **In-game.** One measured run of a `diag` build of 71dd7ca, after a warm-up launch of the same build. Route and settings as in #519: title screen, then the opening cutscene with no input, all five `VICTORY_PORT_*=1`. Window from `the first frame of 500 draws or more` to `window closed`: 267.9 s, 4,169 frames, median 16.4 fps. No ERROR, panic or device removal. | per frame | #519's diagnostic build (cd8dfc0 + #354) | #530 (4eb6cfd + #530) | |---|---|---| | `view records no store told of`, median | 2.0 | 2.06 | | same, from the since-start `view records missed` delta | 2.14 | 2.14 | | tail-only changes (#519: same head), median | 134.8 | 139.2 | | fallback time, median | 0.68 ms | 0.62 ms | The missed count now means what it says, and it matches the per-slot head check in #519. This agrees with gw1337x's boat-scene numbers above, on another RDNA3 card. The memcpy/memmove hook still marked 0 records. Not tested: gameplay, other GPUs, repeat runs.
Address review feedback with accurate counter documentation, a cumulative tail-only counter, and tests for mask-to-slot mapping and a partial-page fault.

AI assistance from ChatGPT 6.2 Sol Extra High.
Author
Owner

@⁠hajduzsolt on GitHub · 2026-11-27 12:04 UTC · original

Thanks for the RX 7800 XT, RX 7900 XT, and RX 6950 XT checks. The two RDNA 3 reports agree that the old counter mostly included changes outside the view header.

All three follow-ups are in 3568ef0.

  • crates/victory-gpu/src/port_descriptors.rs:410 and :531 describe what counts as a missed header write. The frame line reports a separate since-start total for tail-only changes, and its test checks that the interval counter can reset independently.
  • crates/victory-gpu/src/descriptor/host.rs:4928 checks the in-place mask mapping at a nonzero heap offset and across 64-bit mask boundaries.
  • crates/victory-gpu/src/safecopy.rs:507 checks both masks when the next page is unreadable and verifies that the rest of the mirror is untouched.

The diagnostic build, strict Clippy, and the three targeted tests passed. The workspace test results match 4eb6cfd in default and diagnostics builds, with the baseline HLE loopback failure and shader test process access violation.

AI assistance from ChatGPT 6.2 Sol Extra High.

**@⁠hajduzsolt** on GitHub · 2026-11-27 12:04 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/530#issuecomment-7217799104) Thanks for the RX 7800 XT, RX 7900 XT, and RX 6950 XT checks. The two RDNA 3 reports agree that the old counter mostly included changes outside the view header. All three follow-ups are in `3568ef0`. - `crates/victory-gpu/src/port_descriptors.rs:410` and `:531` describe what counts as a missed header write. The frame line reports a separate since-start total for tail-only changes, and its test checks that the interval counter can reset independently. - `crates/victory-gpu/src/descriptor/host.rs:4928` checks the in-place mask mapping at a nonzero heap offset and across 64-bit mask boundaries. - `crates/victory-gpu/src/safecopy.rs:507` checks both masks when the next page is unreadable and verifies that the rest of the mirror is untouched. The diagnostic build, strict Clippy, and the three targeted tests passed. The workspace test results match `4eb6cfd` in default and diagnostics builds, with the baseline HLE loopback failure and shader test process access violation. AI assistance from ChatGPT 6.2 Sol Extra High.
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-27 14:14 UTC · original

Tested 3568ef0 on the same machine (RX 7900 XT).

  • The new tests pass: in_place_changes_map_header_bits_to_heap_slots, the 12 safecopy tests and the 4 port_descriptors tests.
  • Full cargo test --locked -p victory-gpu --lib, 3 runs while other builds were running on the machine: 1 clean. The other two failed once each, in no_write_is_lost_with_port_7 and unchanged_ranges_are_known, the pair from #534 (which #539 fixes). Both pass on their own 5 times out of 5.

On the memcpy/memmove hook that marked 0 records in my run above. I measured whether turning it off loses anything and what it costs. I used a local switch that leaves the title's memcpy/memmove unwrapped; it is not part of this PR.

  • In-game, same route and diag build as above, after a warm-up, alternating off and on, two pairs: view records no store told of median 2.05 / 2.06 with it off, 2.06 / 1.91 with it on. Turning it off misses nothing more here. About 19,000 calls a frame go through the wrapper, about 2,900 of them into the heap, and it marked 0 records in every run.
  • fps was higher with it off in both pairs (+0.6 and +1.0 at ~16 fps), but the two runs with it off differed from each other by 1.2. Two pairs can't separate that from run-to-run drift.
  • Microbenchmark of the wrapper's code, the same CRT memcpy called directly and through the wrapper, both as indirect calls: about +2 ns a call outside the heap. Into the heap, +5 to 15 ns for 8 to 256 B, about +40 to 100 ns at 1 to 4 KB with no view records, and up to about +270 ns at 4 KB when every slot is a view record. With 6 threads copying 64 B into the heap at once, the shared COPIES counters make it about +115 ns a call.
  • Together that is roughly 0.05 to 0.5 ms of a ~60 ms frame, under 1%. That holds unless the copies into the heap are much larger than 4 KB; the log counts calls, not bytes. So cost is not a reason to remove the hook. The reason would be that it marked nothing in this scene, and gameplay may be different.

Not tested: gameplay, other GPUs.

**@⁠adrianmjim** on GitHub · 2026-11-27 14:14 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/530#issuecomment-7220530235) Tested 3568ef0 on the same machine (RX 7900 XT). - The new tests pass: `in_place_changes_map_header_bits_to_heap_slots`, the 12 `safecopy` tests and the 4 `port_descriptors` tests. - Full `cargo test --locked -p victory-gpu --lib`, 3 runs while other builds were running on the machine: 1 clean. The other two failed once each, in `no_write_is_lost_with_port_7` and `unchanged_ranges_are_known`, the pair from #534 (which #539 fixes). Both pass on their own 5 times out of 5. **On the memcpy/memmove hook** that marked 0 records in my run above. I measured whether turning it off loses anything and what it costs. I used a local switch that leaves the title's memcpy/memmove unwrapped; it is not part of this PR. - In-game, same route and `diag` build as above, after a warm-up, alternating off and on, two pairs: `view records no store told of` median 2.05 / 2.06 with it off, 2.06 / 1.91 with it on. Turning it off misses nothing more here. About 19,000 calls a frame go through the wrapper, about 2,900 of them into the heap, and it marked 0 records in every run. - fps was higher with it off in both pairs (+0.6 and +1.0 at ~16 fps), but the two runs with it off differed from each other by 1.2. Two pairs can't separate that from run-to-run drift. - Microbenchmark of the wrapper's code, the same CRT memcpy called directly and through the wrapper, both as indirect calls: about +2 ns a call outside the heap. Into the heap, +5 to 15 ns for 8 to 256 B, about +40 to 100 ns at 1 to 4 KB with no view records, and up to about +270 ns at 4 KB when every slot is a view record. With 6 threads copying 64 B into the heap at once, the shared `COPIES` counters make it about +115 ns a call. - Together that is roughly 0.05 to 0.5 ms of a ~60 ms frame, under 1%. That holds unless the copies into the heap are much larger than 4 KB; the log counts calls, not bytes. So cost is not a reason to remove the hook. The reason would be that it marked nothing in this scene, and gameplay may be different. Not tested: gameplay, other GPUs.
Author
Owner

@⁠hajduzsolt on GitHub · 2026-11-27 15:25 UTC · original

Thanks for the 3568ef0 retest and for measuring both sides of the memcpy/memmove hook. The targeted passes help validate the descriptor change. The two watch-test failures match #534, which #539 addresses. The two A/B pairs and their run-to-run variation are a useful reason to keep the hook enabled while we collect a trace from a scene where it might mark writes.

AI assistance from ChatGPT 6.2 Sol Extra High.

**@⁠hajduzsolt** on GitHub · 2026-11-27 15:25 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/530#issuecomment-7222046403) Thanks for the 3568ef0 retest and for measuring both sides of the memcpy/memmove hook. The targeted passes help validate the descriptor change. The two watch-test failures match #534, which #539 addresses. The two A/B pairs and their run-to-run variation are a useful reason to keep the hook enabled while we collect a trace from a scene where it might mark writes. AI assistance from ChatGPT 6.2 Sol Extra High.
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/530/head:github-bot/gh-530'
git switch 'github-bot/gh-530'

Merge

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