Shaders: odd-address two-byte typed buffer loads read zero #3572

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

@⁠Moon0755 on GitHub · 2026-11-27 18:42 UTC · original
Moon0755:fix/typed-load-odd-align → main · +50 −8 · 2 files · 1 commits · open

On RDNA2 (gfx1036, measured natively in wave32 and wave64 across all two-byte buffer format codes 7..=19 in Leonida docs/design.md), two-byte MUBUF/MTBUF typed format loads at an odd effective byte address behave as out-of-bounds and return 0 for fetched channels while constant-1 descriptor selectors keep 1. On main, Lower::format_load still shifted out the enclosing dword at odd byte offsets.

Changes

  • crates/victory-shader/src/emit/lower.rs (Lower::format_load, 521,074 bytes / +511 vs main, 3,214 bytes below the 524,288 limit):
    • When total == 16, select 0 for the fetched word when (off & 1) != 0, keeping (0, 0, 0, 1) for channels beyond the format.
  • crates/victory-shader/src/emit/valu_tests.rs:
    • Added two_byte_tbuffer_loads_at_odd_byte_offsets_read_zero covering tbuffer_load_format_x (16_UINT, format 11) at byte offsets 0..=3 (MTBUF encoding verified with llvm-mc -triple=amdgcn -mcpu=gfx1013, LLVM 23.1.5).

Verification

  • Fork CI control (test only on main): https://github.com/Moon0755/VIctory/actions/runs/46049529068 (failure — 302 passed, 1 failed solely on two_byte_tbuffer_loads_at_odd_byte_offsets_read_zero: warp: 16_UINT at byte 1 = 0x00003456, want 0x00000000)
  • Fork CI fix (devin/ci-typed-load-align): https://github.com/Moon0755/VIctory/actions/runs/46049700459 (success — 303 passed / 0 failed, Clippy + diagnostics Clippy clean, asset policy: 191 files ok)
  • Local verification (5c71be8): two_byte_tbuffer_loads_at_odd_byte_offsets_read_zero (1/1) and tbuffer (2/2) pass on hardware + WARP; both Clippy configs and cargo xtask policy (191 files ok) clean.
  • Not tested: MUBUF typed offen, idxen, dynamic offsets, odd V# base parity, formats other than 16_UINT in the synthetic test, DST_SEL/sNaN, dxil.dll 1.7, game files. Synthetic tests only (AI-assisted).

— Devin & Neon

**@⁠Moon0755** on GitHub · 2026-11-27 18:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/3572) `Moon0755:fix/typed-load-odd-align` → `main` · +50 −8 · 2 files · 1 commits · open On RDNA2 (`gfx1036`, measured natively in wave32 and wave64 across all two-byte buffer format codes `7..=19` in Leonida `docs/design.md`), two-byte MUBUF/MTBUF typed format loads at an odd effective byte address behave as out-of-bounds and return `0` for fetched channels while constant-1 descriptor selectors keep `1`. On `main`, `Lower::format_load` still shifted out the enclosing dword at odd byte offsets. ### Changes - **`crates/victory-shader/src/emit/lower.rs`** (`Lower::format_load`, `521,074` bytes / `+511` vs `main`, `3,214` bytes below the `524,288` limit): - When `total == 16`, select `0` for the fetched word when `(off & 1) != 0`, keeping `(0, 0, 0, 1)` for channels beyond the format. - **`crates/victory-shader/src/emit/valu_tests.rs`**: - Added `two_byte_tbuffer_loads_at_odd_byte_offsets_read_zero` covering `tbuffer_load_format_x` (`16_UINT`, format `11`) at byte offsets `0..=3` (MTBUF encoding verified with `llvm-mc -triple=amdgcn -mcpu=gfx1013`, LLVM `23.1.5`). ### Verification - **Fork CI control** (test only on `main`): https://github.com/Moon0755/VIctory/actions/runs/46049529068 (`failure` — 302 passed, 1 failed solely on `two_byte_tbuffer_loads_at_odd_byte_offsets_read_zero`: `warp: 16_UINT at byte 1 = 0x00003456, want 0x00000000`) - **Fork CI fix** (`devin/ci-typed-load-align`): https://github.com/Moon0755/VIctory/actions/runs/46049700459 (`success` — 303 passed / 0 failed, Clippy + diagnostics Clippy clean, `asset policy: 191 files ok`) - **Local verification** (`5c71be8`): `two_byte_tbuffer_loads_at_odd_byte_offsets_read_zero` (`1/1`) and `tbuffer` (`2/2`) pass on hardware + WARP; both Clippy configs and `cargo xtask policy` (`191 files ok`) clean. - **Not tested**: MUBUF typed `offen`, `idxen`, dynamic offsets, odd V# base parity, formats other than `16_UINT` in the synthetic test, `DST_SEL`/`sNaN`, `dxil.dll` 1.7, game files. Synthetic tests only (AI-assisted). — Devin & Neon
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 18:43:46 +00:00
Author
Owner

@⁠oni-swr on GitHub · 2026-11-27 19:29 UTC · original

Verification of #3572 (head 5c71be8260), independent, WARP only.

Environment: Windows 11 Pro 10.0.26200, WARP d3d10warp.dll 10.0.26100.9818 (VICTORY_WARP=1 and VICTORY_D3D12_WARP=1, no physical GPU used), dxil.dll 1.8.2502.11 (SDK 10.0.26100.0), rustc 1.98.1. Base origin/main 63bcca43c6.
Command: cargo test -p victory-shader --lib --locked -j 4 -- --test-threads=1.
Baseline: on base, 298 passed / 4 failed / 3 ignored. The 4 failures are WARP lane-emulation tests in synthetic_tests (a_mask_joined_with_data_at_a_uniform_loop_is_its_number, gathers_at_a_level_match_the_hardware, permutes_mask_high_address_bits_and_divergent_branches, permutes_read_the_lane_named_and_zero_from_lanes_left_out). They fail identically on base, each head and the merge, so they are not caused by either PR.

  • Control: base plus only this PR's valu_tests.rs hunk: two_byte_tbuffer_loads_at_odd_byte_offsets_read_zero FAILS (16_UINT at byte 1 read 0x3456, want 0) as the PR claims.
  • Head: 299 passed / 4 failed (the same 4) / 3 ignored; the new test passes.
  • Merge of #3572 + #3576 onto base: merges cleanly; 301 passed / 4 failed (same 4) / 3 ignored. Merged lower.rs is 522,289 bytes (limit 524,288; about 2 KB headroom). Standalone lower.rs: 521,074.
  • cargo clippy -p victory-shader --all-targets --locked -- -D warnings: clean (I did not run the whole workspace).
  • Review: the change is only in the sub-dword branch of Lower::format_load (total < 32), selecting 0 when total == 16 and the byte address is odd. Correct for what the test asserts. It applies to every 16-bit-total format (16_UINT and also 8_8), and the behaviour is invariant of wave size. Finding (not a blocker): the "console reads zero at an odd address" claim cannot be confirmed without console or hardware reference data; WARP only checks our lowering matches the PR's stated expectation. Note also the test's backend label says "hardware" even when WARP is forced.
  • Textual overlap: no conflict with #2208 (git merge-tree clean).

Verdict: no defect found. AI use: this check was run by Claude Code (Claude Sonnet 5.5).

**@⁠oni-swr** on GitHub · 2026-11-27 19:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/3572#issuecomment-7226581598) **Verification of #3572** (head 5c71be8260f52b6f5950b5b5e54a95c9a078e47e), independent, WARP only. Environment: Windows 11 Pro 10.0.26200, WARP d3d10warp.dll 10.0.26100.9818 (VICTORY_WARP=1 and VICTORY_D3D12_WARP=1, no physical GPU used), dxil.dll 1.8.2502.11 (SDK 10.0.26100.0), rustc 1.98.1. Base origin/main 63bcca43c6a00a758510398fa43096ce7e4f7df0. Command: `cargo test -p victory-shader --lib --locked -j 4 -- --test-threads=1`. Baseline: on base, 298 passed / 4 failed / 3 ignored. The 4 failures are WARP lane-emulation tests in `synthetic_tests` (a_mask_joined_with_data_at_a_uniform_loop_is_its_number, gathers_at_a_level_match_the_hardware, permutes_mask_high_address_bits_and_divergent_branches, permutes_read_the_lane_named_and_zero_from_lanes_left_out). They fail identically on base, each head and the merge, so they are not caused by either PR. - Control: base plus only this PR's `valu_tests.rs` hunk: `two_byte_tbuffer_loads_at_odd_byte_offsets_read_zero` FAILS (16_UINT at byte 1 read 0x3456, want 0) as the PR claims. - Head: 299 passed / 4 failed (the same 4) / 3 ignored; the new test passes. - Merge of #3572 + #3576 onto base: merges cleanly; 301 passed / 4 failed (same 4) / 3 ignored. Merged lower.rs is 522,289 bytes (limit 524,288; about 2 KB headroom). Standalone lower.rs: 521,074. - `cargo clippy -p victory-shader --all-targets --locked -- -D warnings`: clean (I did not run the whole workspace). - Review: the change is only in the sub-dword branch of `Lower::format_load` (total < 32), selecting 0 when `total == 16` and the byte address is odd. Correct for what the test asserts. It applies to every 16-bit-total format (16_UINT and also 8_8), and the behaviour is invariant of wave size. Finding (not a blocker): the "console reads zero at an odd address" claim cannot be confirmed without console or hardware reference data; WARP only checks our lowering matches the PR's stated expectation. Note also the test's backend label says "hardware" even when WARP is forced. - Textual overlap: no conflict with #2208 (git merge-tree clean). Verdict: no defect found. AI use: this check was run by Claude Code (Claude Sonnet 5.5).
Author
Owner

@⁠kilolimaVI on GitHub · 2026-11-27 19:36 UTC · original

Hardware run, head 5c71be8: Windows 11, Radeon 780M (RDNA3 iGPU), toolchain 1.98.1.

  • two_byte_tbuffer_loads_at_odd_byte_offsets_read_zero: passes, 0/5 failures over 5 runs.
  • cargo test -p victory-shader on the 780M: 303 passed, 0 failed.

AI-assisted (Claude).

**@⁠kilolimaVI** on GitHub · 2026-11-27 19:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/3572#issuecomment-7226699417) Hardware run, head 5c71be8: Windows 11, Radeon 780M (RDNA3 iGPU), toolchain 1.98.1. - `two_byte_tbuffer_loads_at_odd_byte_offsets_read_zero`: passes, 0/5 failures over 5 runs. - `cargo test -p victory-shader` on the 780M: 303 passed, 0 failed. AI-assisted (Claude).
Author
Owner

@⁠kilolimaVI on GitHub · 2026-11-27 19:57 UTC · original

Before/after on the same 780M: with this PR's test file on main 63bcca4, two_byte_tbuffer_loads_at_odd_byte_offsets_read_zero fails on hardware (16_UINT at byte 1 = 0x00003456, want 0x00000000); with the PR it passes (0/5 failures above). So the bug is real on RDNA3 and this fixes it.

AI-assisted (Claude).

**@⁠kilolimaVI** on GitHub · 2026-11-27 19:57 UTC · [original](https://github.com/Marvisak/VIctory/pull/3572#issuecomment-7227040938) Before/after on the same 780M: with this PR's test file on main 63bcca4, `two_byte_tbuffer_loads_at_odd_byte_offsets_read_zero` fails on hardware (`16_UINT at byte 1 = 0x00003456, want 0x00000000`); with the PR it passes (0/5 failures above). So the bug is real on RDNA3 and this fixes it. AI-assisted (Claude).
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/3572/head:github-bot/gh-3572'
git switch 'github-bot/gh-3572'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3572'
git switch 'github-bot/gh-3572'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3572'
git switch 'github-bot/gh-3572'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3572'
git switch 'main'
git merge --squash 'github-bot/gh-3572'
git switch 'main'
git merge --ff-only 'github-bot/gh-3572'
git switch 'main'
git merge 'github-bot/gh-3572'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!3572
No description provided.