shader: handle dword-straddling 16-bit typed buffer loads at byte offset 3 #1669

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

@⁠geiyiliyabumo on GitHub · 2026-11-24 20:36 UTC · original
geiyiliyabumo:fix/shader-tbuffer-16bit-straddle → main · +180 −2 · 2 files · 1 commits · open

Summary

  • Fixes 16-bit typed buffer format loads (total == 16: 16_* and 8_8_* families) in Lower::format_load (crates/victory-shader/src/emit/lower.rs) when the byte offset satisfies off & 3 == 3.
  • Previously format_load aligned at = off & !3, loaded a single dword, and shifted right by (off & 3) * 8, which left bits [15:8] zeroed whenever a 16-bit element straddled into dword at + 4.
  • Now total == 16 loads the second dword at select(byte == 3, at + 4, at) and merges (w0 >> 24) | (w1 << 8) when byte == 3. Re-reading at when byte != 3 ensures loads at buffer_end - 2 never touch past the buffer end; 8-bit formats (total == 8) remain single-dword loads.
  • Intentionally scoped only to 16-bit dword straddling (does not overlap with #1642's float sNaN widening or #1516/#1370's missing-channel filling).

Verification

  • cargo test -p victory-shader --lib: 121 passed, 0 failed, 1 ignored on both AMD Radeon RX 9060 XT (D3D12 hardware) and Microsoft Basic Render Driver (WARP), including tbuffer_16bit_format_loads_handle_dword_straddling_and_tail_bounds covering 16_UINT across all byte offsets 0..=6 (including straddling offset 3 and tail offset buffer_end - 2 on both 8-byte and 4-byte buffers), 16_SINT negative sign extension at offset 3, 16_FLOAT at offset 3, and 2-channel 8_8_UINT (tbuffer_load_format_xy) at offset 3.
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: pass (154 files).

AI-assisted; synthetic tests only, no game files.

**@⁠geiyiliyabumo** on GitHub · 2026-11-24 20:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/1669) `geiyiliyabumo:fix/shader-tbuffer-16bit-straddle` → `main` · +180 −2 · 2 files · 1 commits · open ## Summary - Fixes 16-bit typed buffer format loads (`total == 16`: `16_*` and `8_8_*` families) in `Lower::format_load` (`crates/victory-shader/src/emit/lower.rs`) when the byte offset satisfies `off & 3 == 3`. - Previously `format_load` aligned `at = off & !3`, loaded a single dword, and shifted right by `(off & 3) * 8`, which left bits `[15:8]` zeroed whenever a 16-bit element straddled into dword `at + 4`. - Now `total == 16` loads the second dword at `select(byte == 3, at + 4, at)` and merges `(w0 >> 24) | (w1 << 8)` when `byte == 3`. Re-reading `at` when `byte != 3` ensures loads at `buffer_end - 2` never touch past the buffer end; 8-bit formats (`total == 8`) remain single-dword loads. - Intentionally scoped only to 16-bit dword straddling (does not overlap with #1642's float sNaN widening or #1516/#1370's missing-channel filling). ## Verification - `cargo test -p victory-shader --lib`: **121 passed, 0 failed, 1 ignored** on both **AMD Radeon RX 9060 XT (D3D12 hardware)** and **Microsoft Basic Render Driver (WARP)**, including `tbuffer_16bit_format_loads_handle_dword_straddling_and_tail_bounds` covering `16_UINT` across all byte offsets `0..=6` (including straddling offset 3 and tail offset `buffer_end - 2` on both 8-byte and 4-byte buffers), `16_SINT` negative sign extension at offset 3, `16_FLOAT` at offset 3, and 2-channel `8_8_UINT` (`tbuffer_load_format_xy`) at offset 3. - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. - `cargo xtask policy`: pass (154 files). *AI-assisted; synthetic tests only, no game files.*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:40:57 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:34 UTC · original · edited 2026-11-25 22:17 UTC

Automated triage for the maintainers.

Needs rebase. This PR no longer merges cleanly into main (conflict in crates/victory-shader/src/emit/valu_tests.rs). It will be reviewed again once it is rebased.

From the earlier needs-work note, still open: evidence (console capture or a title program) that 16-bit format loads at byte offset 3 straddle two dwords on the console.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/1669#issuecomment-7149696738) · edited 2026-11-25 22:17 UTC <!-- victory-triage v1 head=7607291d5b8a55ddca4e5272fdb17ff3faaaa36a verdict=needs-rebase at=2026-11-25T22:20:35Z --> Automated triage for the maintainers. **Needs rebase.** This PR no longer merges cleanly into `main` (conflict in `crates/victory-shader/src/emit/valu_tests.rs`). It will be reviewed again once it is rebased. From the earlier needs-work note, still open: evidence (console capture or a title program) that 16-bit format loads at byte offset 3 straddle two dwords on the console. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠Headache3318 on GitHub · 2026-11-25 01:36 UTC · original

Tested on Linux (Arch, kernel 7.3.5, 3× RTX 4090 driver 620.73.04), Rust 1.98.1 (pinned). PR head 70d3a82 applied cleanly onto current main ccfb029.

  • cargo test -p victory-shader --locked: 96 passed, 0 failed, 1 ignored. All tests pass.
  • cargo clippy -p victory-shader --all-targets -- -D warnings: 2 unused-import errors in test code — these are pre-existing on main (ccfb029 fails identically). The PR introduces no new clippy warnings.

Not tested: Windows MSVC build, the title itself. AI-assisted.

**@⁠Headache3318** on GitHub · 2026-11-25 01:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/1669#issuecomment-7149737293) Tested on Linux (Arch, kernel 7.3.5, 3× RTX 4090 driver 620.73.04), Rust 1.98.1 (pinned). PR head `70d3a82` applied cleanly onto current `main` `ccfb029`. - `cargo test -p victory-shader --locked`: 96 passed, 0 failed, 1 ignored. All tests pass. - `cargo clippy -p victory-shader --all-targets -- -D warnings`: 2 unused-import errors in test code — these are pre-existing on main (`ccfb029` fails identically). The PR introduces no new clippy warnings. Not tested: Windows MSVC build, the title itself. AI-assisted.
Author
Owner

@⁠geiyiliyabumo on GitHub · 2026-11-25 02:25 UTC · original

Rebased cleanly onto \main\ (\ccfb029). \cargo test -p victory-shader --locked tbuffer\ (verified on physical AMD RX 9060 XT + WARP + Microsoft \dxil.dll), \cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings, and \cargo xtask policy\ all pass.

**@⁠geiyiliyabumo** on GitHub · 2026-11-25 02:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/1669#issuecomment-7150711802) Rebased cleanly onto \main\ (\ccfb029\). \cargo test -p victory-shader --locked tbuffer\ (verified on physical AMD RX 9060 XT + WARP + Microsoft \dxil.dll\), \cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings\, and \cargo xtask policy\ all pass.
This pull request has changes conflicting with the target branch.
  • crates/victory-shader/src/emit/valu_tests.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/1669/head:github-bot/gh-1669'
git switch 'github-bot/gh-1669'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1669'
git switch 'github-bot/gh-1669'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1669'
git switch 'github-bot/gh-1669'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1669'
git switch 'main'
git merge --squash 'github-bot/gh-1669'
git switch 'main'
git merge --ff-only 'github-bot/gh-1669'
git switch 'main'
git merge 'github-bot/gh-1669'
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!1669
No description provided.