Shaders: join straddling global 16-bit loads across dwords #565

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

@⁠DecayingEagle on GitHub · 2026-11-27 11:41 UTC · original
DecayingEagle:fix/global-half-straddle → a-publier · +252 −3 · 4 files · 2 commits · draft

A root-SRV global_load_ushort or global_load_sshort at byte 3 modulo 4 loses its high byte. On the RX 7900 XT, the new test reads 0x00f2 where the input contains 0x17f2. Bytes at offsets 0, 1 and 2 already follow unaligned semantics.

Join the next dword's low byte for a straddling half; otherwise read the first dword again. Keep the existing sign extension and byte loads. Bump TRANSLATOR_VERSION from 2 to 3 so an older cached translation cannot hide the fix. The common path also serves code-constant-table loads, although the new hardware test covers root SRVs.

The join follows Marvisak/VIctory#3333 (80e8cede), applied to this branch's separate global-load path. Its buffer-load path already handles straddling halves.

Validation

RX 7900 XT, Mesa 26.3.1 RADV, Wine 11.22, vkd3d-proton 71cae09; Rust 1.98.1, MSVC cross-target:

  • Root-SRV GPU regression: fails before the fix at byte 3; passes afterward for signed/unsigned bytes and halves, every byte alignment, wave32 and wave64 (8 configurations, 384 lane results).
  • Review follow-up 62fd607: added the same coverage through a code-constant table addressed by s_getpc_b64, explicitly asserting CODE resource tracking and no root SRV. The new route also fails before the fix at byte 3 and passes afterward (8 more configurations, 384 lane results). Both tests, both Clippy configurations and policy pass on the RX 7900 XT/Wine setup. The new code-table case has not yet been run on native Windows.
  • Independent validation from @⁠MamaLeVrai on RX 6950 XT / Windows 11 at the preceding 3edb877: 304 shader tests passed, 0 failed, 4 ignored.
  • The WARP request falls back to the same hardware adapter under DXVK; this is not independent WARP validation.
  • Existing lowering tests: 17 passed, 1 existing ignored.
  • Workspace/all-target Clippy, default and all features, -D warnings: passed.
  • Repository policy: 272 files passed.
  • A separate local integration with the existing facial and constant-order patches: 49 targeted checks passed; release and diagnostic builds and Wine version checks passed. Another 12 f16 checks passed on that integration.
  • Two automated 150-second cutscene runs at 1440p fullscreen completed without recorded game/kernel faults. Mixed-scene sampled median FPS was 17.5 before and 17.3 after; no speedup is claimed. Mouth deformation and pale eyes remain visible, so this is not a facial-animation fix.
  • A subsequent eight-minute run of the same integration completed without a recorded title fault, device loss or kernel GPU fault; stopped at its planned test limit. Its mixed-scene median was 13.4 FPS across 86 periodic world samples. This does not establish a fix for the previously reported intermittent access violation.

Limits

A later manual gameplay run failed after 606.5 seconds with the previously observed null command-allocator access at title +0x4e9b578; no matching GPU reset was recorded. This predates this shader change and remains unresolved. Full setup and a descriptor-fallback control are recorded in #583.

The console driver's alignment mode is still unconfirmed; this makes byte 3 consistent with the unaligned behavior already used at byte 1 and by this branch's buffer loads. Bounds/host-copy crossings and the separate arbitrary-title-address path are unchanged. Native Windows full-suite CI is pending. Synthetic test data only; no title assets attached.

Implementation, tests and this description were assisted by OpenAI Codex.

**@⁠DecayingEagle** on GitHub · 2026-11-27 11:41 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/565) `DecayingEagle:fix/global-half-straddle` → `a-publier` · +252 −3 · 4 files · 2 commits · draft A root-SRV `global_load_ushort` or `global_load_sshort` at byte 3 modulo 4 loses its high byte. On the RX 7900 XT, the new test reads `0x00f2` where the input contains `0x17f2`. Bytes at offsets 0, 1 and 2 already follow unaligned semantics. Join the next dword's low byte for a straddling half; otherwise read the first dword again. Keep the existing sign extension and byte loads. Bump `TRANSLATOR_VERSION` from 2 to 3 so an older cached translation cannot hide the fix. The common path also serves code-constant-table loads, although the new hardware test covers root SRVs. The join follows [Marvisak/VIctory#3333](https://github.com/Marvisak/VIctory/pull/3333) (`80e8cede`), applied to this branch's separate global-load path. Its buffer-load path already handles straddling halves. ### Validation RX 7900 XT, Mesa 26.3.1 RADV, Wine 11.22, vkd3d-proton `71cae09`; Rust 1.98.1, MSVC cross-target: - Root-SRV GPU regression: fails before the fix at byte 3; passes afterward for signed/unsigned bytes and halves, every byte alignment, wave32 and wave64 (8 configurations, 384 lane results). - Review follow-up `62fd607`: added the same coverage through a code-constant table addressed by `s_getpc_b64`, explicitly asserting CODE resource tracking and no root SRV. The new route also fails before the fix at byte 3 and passes afterward (8 more configurations, 384 lane results). Both tests, both Clippy configurations and policy pass on the RX 7900 XT/Wine setup. The new code-table case has not yet been run on native Windows. - Independent validation from @⁠MamaLeVrai on RX 6950 XT / Windows 11 at the preceding `3edb877`: 304 shader tests passed, 0 failed, 4 ignored. - The WARP request falls back to the same hardware adapter under DXVK; this is not independent WARP validation. - Existing lowering tests: 17 passed, 1 existing ignored. - Workspace/all-target Clippy, default and all features, `-D warnings`: passed. - Repository policy: 272 files passed. - A separate local integration with the existing facial and constant-order patches: 49 targeted checks passed; release and diagnostic builds and Wine version checks passed. Another 12 f16 checks passed on that integration. - Two automated 150-second cutscene runs at 1440p fullscreen completed without recorded game/kernel faults. Mixed-scene sampled median FPS was 17.5 before and 17.3 after; no speedup is claimed. Mouth deformation and pale eyes remain visible, so this is not a facial-animation fix. - A subsequent eight-minute run of the same integration completed without a recorded title fault, device loss or kernel GPU fault; stopped at its planned test limit. Its mixed-scene median was 13.4 FPS across 86 periodic world samples. This does not establish a fix for the previously reported intermittent access violation. ### Limits A later manual gameplay run failed after 606.5 seconds with the previously observed null command-allocator access at title `+0x4e9b578`; no matching GPU reset was recorded. This predates this shader change and remains unresolved. Full setup and a descriptor-fallback control are recorded in [#583](https://git.gtahub.st/github/Belobug--VIctory-Belobug-AMD/issues/583). The console driver's alignment mode is still unconfirmed; this makes byte 3 consistent with the unaligned behavior already used at byte 1 and by this branch's buffer loads. Bounds/host-copy crossings and the separate arbitrary-title-address path are unchanged. Native Windows full-suite CI is pending. Synthetic test data only; no title assets attached. Implementation, tests and this description were assisted by OpenAI Codex.
A root-SRV global_load_ushort/sshort at byte 3 mod 4 dropped its high
byte. Join the next dword's low byte, and reuse the first dword for
non-straddling loads. Keep the existing sign extension and byte loads.
Bump the translator version so cached translations do not hide the fix.

The boundary join follows the buffer-load fix in Marvisak/VIctory#3333
(80e8cede); this applies it to this branch's separate global-load path.
Add synthetic GPU coverage for both signednesses and both wave sizes,
with byte-load controls at every byte alignment.

Implementation and testing assisted by OpenAI Codex.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 11:54:46 +00:00
Author
Owner

@⁠gut0to on GitHub · 2026-11-27 13:03 UTC · original · reviewed

AI-assisted review. I checked the unaligned-load fix and left one coverage suggestion inline.

**@⁠gut0to** on GitHub · 2026-11-27 13:03 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/565#pullrequestreview-6088555959) · **reviewed** AI-assisted review. I checked the unaligned-load fix and left one coverage suggestion inline.
@ -2299,3 +2298,4 @@
// A half at byte 3 continues in the next dword.
let (not3, three) = (self.s.m.i32(!3), self.s.m.i32(3));
let at = self.s.m.bin(c, Bin::And, off, not3);
let w = dword(self, at)?;
Author
Owner

@⁠gut0to on GitHub · 2026-11-27 13:03 UTC · original

AI-assisted review: The PR notes that this shared path also serves code-constant-table loads, while the new hardware regression exercises only a root SRV. Could you add a byte-3 straddling case through the constant-table route too? That would protect both callers of the newly added second-dword read.

**@⁠gut0to** on GitHub · 2026-11-27 13:03 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/565#discussion_r4719715788) AI-assisted review: The PR notes that this shared path also serves code-constant-table loads, while the new hardware regression exercises only a root SRV. Could you add a byte-3 straddling case through the constant-table route too? That would protect both callers of the newly added second-dword read.
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-27 15:56 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 3edb877: victory-shader 304 passed, 0 failed, 4 ignored.

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

**@⁠MamaLeVrai** on GitHub · 2026-11-27 15:56 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/565#issuecomment-7222663221) Tested on an RX 6950 XT (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300, Rust 1.98.1, release. At `3edb877`: `victory-shader` 304 passed, 0 failed, 4 ignored. AI-assisted (Claude Code); no game data.
Address gut0to's review on Belobug/VIctory-Belobug-AMD#565.
Build the input table into synthetic code and address it with s_getpc_b64;
assert CODE tracking and no root SRV binding. Cover signed and unsigned
bytes and halves, all byte alignments, wave32 and wave64.

The new GPU test fails with the old lowering at byte 3 and passes with
the fix on RX 7900 XT/RADV under Wine 11.22. Existing root-SRV cases,
both workspace Clippy configurations and repository policy pass.
DXVK maps the WARP request to the same hardware, not independent WARP.

Assisted by OpenAI Codex.
@ -2299,3 +2298,4 @@
// A half at byte 3 continues in the next dword.
let (not3, three) = (self.s.m.i32(!3), self.s.m.i32(3));
let at = self.s.m.bin(c, Bin::And, off, not3);
let w = dword(self, at)?;
Author
Owner

@⁠DecayingEagle on GitHub · 2026-11-27 16:39 UTC · original

Added in 62fd6072450e1b0c54cfd60c6c92c8f4521840e1.

The new code_table_subdword_loads_read_all_bytes_and_extend_the_sign appends synthetic bytes to the program, addresses them through s_getpc_b64, asserts resource tracking selected CODE, and dispatches without a root SRV. It covers signed/unsigned bytes and halves at every byte alignment in wave32 and wave64.

On RX 7900 XT / RADV / Wine 11.22, reverting only the production lowering makes the new case fail at byte 3 in the unsigned-half check; restoring it passes all eight configurations (384 lane results). The existing root-SRV test passes too. Both workspace/all-target Clippy configurations (-D warnings) and policy pass. DXVK maps the WARP request to the same hardware here, so independent WARP/native Windows coverage of this new case remains unverified.

No production lowering changed in this follow-up. Assisted by OpenAI Codex.

**@⁠DecayingEagle** on GitHub · 2026-11-27 16:39 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/565#discussion_r4721784488) Added in `62fd6072450e1b0c54cfd60c6c92c8f4521840e1`. The new `code_table_subdword_loads_read_all_bytes_and_extend_the_sign` appends synthetic bytes to the program, addresses them through `s_getpc_b64`, asserts resource tracking selected `CODE`, and dispatches without a root SRV. It covers signed/unsigned bytes and halves at every byte alignment in wave32 and wave64. On RX 7900 XT / RADV / Wine 11.22, reverting only the production lowering makes the new case fail at byte 3 in the unsigned-half check; restoring it passes all eight configurations (384 lane results). The existing root-SRV test passes too. Both workspace/all-target Clippy configurations (`-D warnings`) and policy pass. DXVK maps the WARP request to the same hardware here, so independent WARP/native Windows coverage of this new case remains unverified. No production lowering changed in this follow-up. Assisted by OpenAI Codex.
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/565/head:github-bot/gh-565'
git switch 'github-bot/gh-565'

Merge

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