Shaders: zero missing channels on typed buffer loads #1370

Closed
fuzeofficlal wants to merge 1 commit from upstream-pr/1370 into main
fuzeofficlal commented 2026-11-24 17:38:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-24T17:38:28Z.


Addresses the missing-channel padding bug in #1060 (orthogonal to #1112 and #169).

Summary

  • Pad unwritten destination channels past a typed buffer format's component count with 0 (out.resize(channels as usize, self.s.m.i32(0))) instead of (0, 0, 0, 1), matching GFX10 buffer_load_format_* / tbuffer_load_format_* hardware behavior for 1-, 2-, and 3-channel formats.
  • Update the snorm16x2 expectation in diff_tests accordingly.

Verification

  • Added valu_tests::tbuffer_load_format_zero_pads_missing_channels covering 25 tbuffer_load_format_{xy,xyz,xyzw} cases across UNORM, SNORM, UINT, SINT, USCALED, SSCALED, and FLOAT 1/2/3/4-channel formats:
    • dxil.dll validation: passed
    • NVIDIA GeForce RTX 5090: passed
    • Microsoft D3D12 WARP: passed
  • cargo clippy --workspace --all-targets --all-features and cargo xtask policy: passed.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6587790009 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1370). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-24T17:38:28Z. --- Addresses the missing-channel padding bug in #1060 (orthogonal to #1112 and #169). ### Summary - Pad unwritten destination channels past a typed buffer format's component count with `0` (`out.resize(channels as usize, self.s.m.i32(0))`) instead of `(0, 0, 0, 1)`, matching GFX10 `buffer_load_format_*` / `tbuffer_load_format_*` hardware behavior for 1-, 2-, and 3-channel formats. - Update the `snorm16x2` expectation in `diff_tests` accordingly. ### Verification - Added `valu_tests::tbuffer_load_format_zero_pads_missing_channels` covering 25 `tbuffer_load_format_{xy,xyz,xyzw}` cases across `UNORM`, `SNORM`, `UINT`, `SINT`, `USCALED`, `SSCALED`, and `FLOAT` 1/2/3/4-channel formats: - `dxil.dll` validation: passed - **NVIDIA GeForce RTX 5090**: passed - **Microsoft D3D12 WARP**: passed - `cargo clippy --workspace --all-targets --all-features` and `cargo xtask policy`: passed.
catminou4 commented 2026-11-24 18:05:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T17:42:44Z.

Review: APPROVED


Typed buffer loads (tbuffer_load_format_*) now zero-fill channels past the format's read instead of padding with 0,0,0,1; diff_tests HLSL reference updated to match (uint4(..., 0, 0)). This is a semantic change to every typed load, so it needs the Windows diff/valu runs to confirm hardware really returns 0 (D3D typed loads traditionally pad w=1 — if this is GFX10 tbuffer behavior verified on hardware, great; the diff_tests update suggests it was). New valu coverage for _x/_xy/_xyz partial loads checks unloaded VGPRs are not clobbered. Local verification: macOS arm64, rustc 1.98.1, PR head merged into main ffe310e, cargo test -p <crate> --locked. Shader execution tests (valu_tests/host/diff_tests) are #[cfg(all(test, windows))], so macOS covers lowering/decode/unit tests only. 96 passed, 0 failed on macOS; execution tests are Windows-gated.

<!-- greyfinch-sync:Marvisak/VIctory:review:6044389095 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1370#pullrequestreview-6044389095). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T17:42:44Z. **Review:** APPROVED --- Typed buffer loads (tbuffer_load_format_*) now zero-fill channels past the format's read instead of padding with 0,0,0,1; diff_tests HLSL reference updated to match (uint4(..., 0, 0)). This is a semantic change to every typed load, so it needs the Windows diff/valu runs to confirm hardware really returns 0 (D3D typed loads traditionally pad w=1 — if this is GFX10 tbuffer behavior verified on hardware, great; the diff_tests update suggests it was). New valu coverage for _x/_xy/_xyz partial loads checks unloaded VGPRs are not clobbered. Local verification: macOS arm64, rustc 1.98.1, PR head merged into main ffe310e, `cargo test -p <crate> --locked`. Shader execution tests (valu_tests/host/diff_tests) are `#[cfg(all(test, windows))]`, so macOS covers lowering/decode/unit tests only. 96 passed, 0 failed on macOS; execution tests are Windows-gated.
catminou4 commented 2026-11-24 21:02:17 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T20:50:18Z.

Review: APPROVED


Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (ffe310e), cargo test -p victory-shader --locked → 96 passed, 0 failed. Hardware/valu tests are #[cfg(all(test, windows))] and only run on Windows; macOS covers structure/lowering unit tests.

Typed buffer loads (tbuffer_load_format) zero-pad missing channels: new const encoders for s_load_dwordx4/buffer_store_dwordx4/tbuffer_load_format and tbuffer_load_format_zero_pads_missing_channels across formats.

<!-- greyfinch-sync:Marvisak/VIctory:review:6047177130 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1370#pullrequestreview-6047177130). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T20:50:18Z. **Review:** APPROVED --- Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (ffe310e), cargo test -p victory-shader --locked → 96 passed, 0 failed. Hardware/valu tests are #[cfg(all(test, windows))] and only run on Windows; macOS covers structure/lowering unit tests. Typed buffer loads (tbuffer_load_format) zero-pad missing channels: new const encoders for s_load_dwordx4/buffer_store_dwordx4/tbuffer_load_format and tbuffer_load_format_zero_pads_missing_channels across formats.
upstream-sync closed this pull request 2026-11-25 01:06:22 +00:00
Marvisak commented 2026-11-25 01:08:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:38:51Z.


Automated triage for the maintainers. Closing because another open pull request covers the same change.

See #1516. Missing channels of typed buffer loads read 0 instead of (0, 0, 0, 1). The lowering change is line for line the one in #1516, which merges clean. Either one contradicts main's stated rule (lower.rs:4428) and rewrites the console-vs-PC differential case to fit; it rests on the measurement in issue #1060, so decide it on #1516.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148730300 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1370#issuecomment-7148730300). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:38:51Z. --- Automated triage for the maintainers. Closing because another open pull request covers the same change. See #1516. Missing channels of typed buffer loads read 0 instead of (0, 0, 0, 1). The lowering change is line for line the one in #1516, which merges clean. Either one contradicts main's stated rule (lower.rs:4428) and rewrites the console-vs-PC differential case to fit; it rests on the measurement in issue #1060, so decide it on #1516. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.
sinan-cmyk commented 2026-11-25 02:06:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-25T01:48:26Z.


Offline measurement on a retail dump, and the shader tests on Ada

Result: no count change against main.

Offline. I merged head 44d9c2d onto main ffe310e (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 21,724 on main, 21,724 with this PR.

No program changes its failure reason either. That is the expected result for a fix whose instructions sit behind the earlier failures on main. The count shows that the change rejects nothing. It does not show whether the output is right.

Tests: with the same merge, cargo test --locked -p victory-shader --lib passed 121, failed 0. The bitcode benchmark is ignored, as on main, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, with VICTORY_WARP unset.

No shader names or data are included, per the asset policy. AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149978783 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1370#issuecomment-7149978783). Originally posted by [sinan-cmyk](https://github.com/sinan-cmyk) on 2026-11-25T01:48:26Z. --- ### Offline measurement on a retail dump, and the shader tests on Ada **Result: no count change against `main`.** **Offline.** I merged head 44d9c2d onto `main` ffe310e (clean merge) and ran `victory translate --validate --list` on `shaders.rpf` (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with `main` program by program (25,889 programs). Validated: 21,724 on `main`, 21,724 with this PR. No program changes its failure reason either. That is the expected result for a fix whose instructions sit behind the earlier failures on `main`. The count shows that the change rejects nothing. It does not show whether the output is right. **Tests:** with the same merge, `cargo test --locked -p victory-shader --lib` passed 121, failed 0. The bitcode benchmark is ignored, as on `main`, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, with `VICTORY_WARP` unset. No shader names or data are included, per the asset policy. AI-assisted (Claude Code).

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!1370
No description provided.