shader: clamp record constant loads per dword (fixes torn faces, #18) #29

Manually merged
github merged 1 commit from gh-pr/29/head into gh-pr/29/base 2026-12-01 07:41:42 +00:00
Owner

@⁠Tom1tk on GitHub · 2026-11-30 12:56 UTC · original
Tom1tk:fix-face-record-bounds → main · +18 −4 · 2 files · 1 commits · merged 2026-11-30 15:36 UTC

Fixes #18: torn faces and colourful noise on characters' faces in cutscenes.

Cause

In records mode, scalar constant loads (s_buffer_load_dwordx2..x16) go through raw_dwords(), which clamped each group of up to four dwords as one unit (self.at(h, a, 4 * n)). If any dword ran past the end of the record, all of them read 0.

The console checks each dword against the record size on its own, so the dwords before the end are still read. Face shaders read indices that sit just before a record's end. For example, 6b176df5514d9a3f does an s_buffer_load_dwordx4 at 0x14 and uses s28–s30 as indices. Those came back 0, and the shader pulled the wrong face data.

Change

crates/victory-shader/src/emit/lower.rs, raw_dwords():

  • Each load is placed by its first dword (self.at(h, start, 4)).
  • Dwords after the first read 0 only when they fall outside the record. This uses the same IULT check as at().

TRANSLATOR_VERSION goes from 7 to 8, so cached translations are redone.

The other smem path was already per-dword. The WIDE path is untouched (off by default).

The bounds clamp stays on for every load, so there is no need to bring back the VICTORY_REC_BOUNDS switch or change any record lengths, the two options raised in #18.

Before / after

Same frames, same build, with only this change reverted vs applied:

Lucia

Therapist

Testing

  • cargo test -p victory-shader --release on this branch: 276 passed, 0 failed.
  • In game (RX 9070 XT, RADV), therapist cutscene, all shader/pipeline caches wiped between runs: faces are clean with the fix and torn without it.
  • Warm fps over the same window: 51.4 mean / 57.9 median with the fix vs 52.5 / 61.1 without. That is one run each and within run-to-run noise.

The in-game runs were done on a branch based on 2773fdf, before the latest main. On current main, this branch was only checked by the unit tests. Only the opening and therapist cutscenes were checked.

**@⁠Tom1tk** on GitHub · 2026-11-30 12:56 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/29) `Tom1tk:fix-face-record-bounds` → `main` · +18 −4 · 2 files · 1 commits · merged 2026-11-30 15:36 UTC Fixes #18: torn faces and colourful noise on characters' faces in cutscenes. ## Cause In records mode, scalar constant loads (`s_buffer_load_dwordx2..x16`) go through `raw_dwords()`, which clamped each group of up to four dwords as one unit (`self.at(h, a, 4 * n)`). If any dword ran past the end of the record, **all** of them read 0. The console checks each dword against the record size on its own, so the dwords before the end are still read. Face shaders read indices that sit just before a record's end. For example, `6b176df5514d9a3f` does an `s_buffer_load_dwordx4` at 0x14 and uses s28–s30 as indices. Those came back 0, and the shader pulled the wrong face data. ## Change `crates/victory-shader/src/emit/lower.rs`, `raw_dwords()`: - Each load is placed by its first dword (`self.at(h, start, 4)`). - Dwords after the first read 0 only when they fall outside the record. This uses the same `IULT` check as `at()`. `TRANSLATOR_VERSION` goes from 7 to 8, so cached translations are redone. The other smem path was already per-dword. The `WIDE` path is untouched (off by default). The bounds clamp stays on for every load, so there is no need to bring back the `VICTORY_REC_BOUNDS` switch or change any record lengths, the two options raised in #18. ## Before / after Same frames, same build, with only this change reverted vs applied: ![Lucia](https://raw.githubusercontent.com/Tom1tk/VIctory-xmem/pr-assets/lucia.png) ![Therapist](https://raw.githubusercontent.com/Tom1tk/VIctory-xmem/pr-assets/therapist.png) ## Testing - `cargo test -p victory-shader --release` on this branch: 276 passed, 0 failed. - In game (RX 9070 XT, RADV), therapist cutscene, all shader/pipeline caches wiped between runs: faces are clean with the fix and torn without it. - Warm fps over the same window: 51.4 mean / 57.9 median with the fix vs 52.5 / 61.1 without. That is one run each and within run-to-run noise. The in-game runs were done on a branch based on 2773fdf, before the latest main. On current main, this branch was only checked by the unit tests. Only the opening and therapist cutscenes were checked.
A scalar constant load (s_buffer_load_dwordx2..x16) in records mode was
clamped as a whole group of up to four dwords: if any dword ran past the
end of the record, all of them read 0. The console checks each dword on
its own, so the dwords before the end must still be read.

Face shaders read indices that sit just before a record's end (e.g.
6b176df5514d9a3f: s_buffer_load_dwordx4 at 0x14, s28..s30 used as
indices). They got zeros and tore the faces in cutscenes (#18).

Place each load by its first dword and zero only the later dwords that
fall outside the record. Bump TRANSLATOR_VERSION so cached translations
are redone.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 07:41:40 +00:00
github manually merged commit 245c4a7bab into gh-pr/29/base 2026-12-01 07:41:42 +00:00
Author
Owner

@⁠thedee8086 on GitHub · 2026-12-01 03:17 UTC · original

Confirmed on RDNA3 (RX 7900 XTX): before this clamp, wobbling "underwater" character faces at 1440p upscaled; after, completely gone. The symptom read as temporal wobble at reduced render scale rather than tearing, in case that helps anyone connect reports.

**@⁠thedee8086** on GitHub · 2026-12-01 03:17 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/29#issuecomment-7299556403) Confirmed on RDNA3 (RX 7900 XTX): before this clamp, wobbling "underwater" character faces at 1440p upscaled; after, completely gone. The symptom read as temporal wobble at reduced render scale rather than tearing, in case that helps anyone connect reports.
This discussion has been locked. Commenting is limited to contributors.
No description provided.