Shaders: preserve the unwritten high half of packed D16 image loads #1437

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

@⁠EatCodeSleep2 on GitHub · 2026-11-24 17:58 UTC · original
EatCodeSleep2:fix/preserve-d16-image-high-half-1242 → main · +49 −4 · 2 files · 1 commits · open

Addresses the destination register preservation part of VIC-BT-017 in #1242. An odd number of packed D16 image-load channels writes only the low half of the final destination VGPR. Merge that channel with the previous high half. Full channel pairs still overwrite both halves. The integer texel interpretation from the same audit finding is separate.

The synthetic GPU regression checks 1-, 2-, and 3-channel image loads against a 1x1 float texture. Upstream main returned 0x00003c00 instead of 0x5a5a3c00 for the one-channel case. The test passes with the fix. The expected high-half behavior is also recorded for GFX10 2D loads by the native hardware probe.

On Windows, 120 shader tests and strict shader Clippy passed. The existing v_med3_f32 host NaN test was excluded from the suite.

AI use: Codex wrote and tested the change.

**@⁠EatCodeSleep2** on GitHub · 2026-11-24 17:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/1437) `EatCodeSleep2:fix/preserve-d16-image-high-half-1242` → `main` · +49 −4 · 2 files · 1 commits · open Addresses the destination register preservation part of VIC-BT-017 in #1242. An odd number of packed D16 image-load channels writes only the low half of the final destination VGPR. Merge that channel with the previous high half. Full channel pairs still overwrite both halves. The integer texel interpretation from the same audit finding is separate. The synthetic GPU regression checks 1-, 2-, and 3-channel image loads against a 1x1 float texture. Upstream main returned 0x00003c00 instead of 0x5a5a3c00 for the one-channel case. The test passes with the fix. The expected high-half behavior is also recorded for GFX10 2D loads by the [native hardware probe](https://github.com/LeonidaReforge/Leonida/blob/main/tools/image_d16_probe.py). On Windows, 120 shader tests and strict shader Clippy passed. The existing v_med3_f32 host NaN test was excluded from the suite. AI use: Codex wrote and tested the change.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:31:43 +00:00
Author
Owner

@⁠marquezinii on GitHub · 2026-11-24 18:33 UTC · original

Ran on an RTX 5070 (desktop, driver 621.40, the only adapter), Windows 11 26300, Rust 1.98.1 at 4cfae26. cargo test -p victory-shader --lib -- --test-threads=1 --nocapture gives 121 passed, 0 failed, 1 ignored. packed_image_load_keeps_unwritten_high_half passes on the hardware adapter and WARP. The only skips are the four diff_tests that need the console compiler. This merges cleanly with #1441, and the shared test builder appears once.

**@⁠marquezinii** on GitHub · 2026-11-24 18:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/1437#issuecomment-7140817380) Ran on an RTX 5070 (desktop, driver 621.40, the only adapter), Windows 11 26300, Rust 1.98.1 at `4cfae26`. `cargo test -p victory-shader --lib -- --test-threads=1 --nocapture` gives 121 passed, 0 failed, 1 ignored. `packed_image_load_keeps_unwritten_high_half` passes on the hardware adapter and WARP. The only skips are the four `diff_tests` that need the console compiler. This merges cleanly with #1441, and the shared test builder appears once.
Author
Owner

@⁠AnoHunted on GitHub · 2026-11-24 18:38 UTC · original

Independent NVIDIA run. No game files were used.

Machine: Windows 11, NVIDIA GeForce RTX 5080, Rust 1.98.1, DXC dxil.dll 1.9.2609 (SDK 10.0.26100) validating.

cargo test -p victory-shader --features host -- --test-threads=1 with this PR:

  • 121 passed, 0 failed, 1 ignored (main: 120 / 0 / 1), including the added packed_image_load_keeps_unwritten_high_half.

Not tested: the in-game effect; AMD. (Sibling #1441, the buffer version, reported separately.)

**@⁠AnoHunted** on GitHub · 2026-11-24 18:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/1437#issuecomment-7140922591) Independent NVIDIA run. No game files were used. Machine: Windows 11, NVIDIA GeForce RTX 5080, Rust 1.98.1, DXC `dxil.dll` 1.9.2609 (SDK 10.0.26100) validating. `cargo test -p victory-shader --features host -- --test-threads=1` with this PR: - **121 passed, 0 failed, 1 ignored** (main: 120 / 0 / 1), including the added `packed_image_load_keeps_unwritten_high_half`. Not tested: the in-game effect; AMD. (Sibling #1441, the buffer version, reported separately.)
Author
Owner

@⁠sinan-cmyk on GitHub · 2026-11-24 20:43 UTC · original

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

Result: no count change against main.

Offline. I merged head 4cfae26 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).

**@⁠sinan-cmyk** on GitHub · 2026-11-24 20:43 UTC · [original](https://github.com/Marvisak/VIctory/pull/1437#issuecomment-7143981896) ### Offline measurement on a retail dump, and the shader tests on Ada **Result: no count change against `main`.** **Offline.** I merged head 4cfae26 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).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 03:27 UTC · original

Automated triage for the maintainers.

Needs work. For an odd number of packed D16 image_load channels, this keeps the last register's high half via low_half (crates/victory-shader/src/emit/lower.rs, image result packing, op == 66 only). CI passes. This changes emulation behaviour, but the only evidence is a link to a probe script in another project. Please put the measured result in the PR body: the GPU, and the register value before and after a 1- and 3-channel load. Please also say why sampled and gathered D16 results keep zeroing the high half when loads do not.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 03:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/1437#issuecomment-7151935893) <!-- victory-triage v1 head=4cfae26174f47ad2224c4697df178146a4b47c90 verdict=needs-work at=2026-11-25T03:29:00Z --> Automated triage for the maintainers. **Needs work.** For an odd number of packed D16 `image_load` channels, this keeps the last register's high half via `low_half` (`crates/victory-shader/src/emit/lower.rs`, image result packing, `op == 66` only). CI passes. This changes emulation behaviour, but the only evidence is a link to a probe script in another project. Please put the measured result in the PR body: the GPU, and the register value before and after a 1- and 3-channel load. Please also say why sampled and gathered D16 results keep zeroing the high half when loads do not. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/1437/head:github-bot/gh-1437'
git switch 'github-bot/gh-1437'

Merge

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