Shaders: preserve the unwritten high half of packed D16 image loads #1436
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1437"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by EatCodeSleep2 on 2026-11-24T17:58:31Z.
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.
Imported from Marvisak/VIctory. Originally posted by marquezinii on 2026-11-24T18:33:44Z.
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 --nocapturegives 121 passed, 0 failed, 1 ignored.packed_image_load_keeps_unwritten_high_halfpasses on the hardware adapter and WARP. The only skips are the fourdiff_teststhat need the console compiler. This merges cleanly with #1441, and the shared test builder appears once.Imported from Marvisak/VIctory. Originally posted by AnoHunted on 2026-11-24T18:38:11Z.
Independent NVIDIA run. No game files were used.
Machine: Windows 11, NVIDIA GeForce RTX 5080, Rust 1.98.1, DXC
dxil.dll1.9.2609 (SDK 10.0.26100) validating.cargo test -p victory-shader --features host -- --test-threads=1with this PR:packed_image_load_keeps_unwritten_high_half.Not tested: the in-game effect; AMD. (Sibling #1441, the buffer version, reported separately.)
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T19:25:00Z.
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. GPU/valu execution tests are Windows-gated and were not run here.Packed D16 image loads with an odd channel count now preserve the destination register's unwritten high half (
low_half) instead of zeroing it — e.g. dmask 1 keeps the seed's high 16 bits. Three waterfall cases (dmask 1/3/7) assert the exact packed result on hardware+WARP (Windows-only); macOS 96 green.Note: pairs with #1441 (same fix for buffer loads) — both refactor
waterfall_tests.rs::buildintobuild_with_handle_countidentically, so they conflict there; the lower.rs hunks are in different functions and merge cleanly.Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-24T20:43:56Z.
Offline measurement on a retail dump, and the shader tests on Ada
Result: no count change against
main.Offline. I merged head
4cfae26ontomainffe310e(clean merge) and ranvictory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result withmainprogram by program (25,889 programs). Validated: 21,724 onmain, 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 --libpassed 121, failed 0. The bitcode benchmark is ignored, as onmain, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, withVICTORY_WARPunset.No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T22:49:51Z.
Review: APPROVED
Tested
4cfae26on Windows 11, RTX 5070, MSVC: builds,cargo test --workspace --no-fail-fast644 passed, 0 failed (on our fork main), with victory-shader single-threaded.packed_image_load_keeps_unwritten_high_halfpasses on the hardware device for 1, 2 and 3 channels.low_half(the old register's high half kept) matches that, and full pairs still overwrite both halves.textureLoad(DXIL op 66) keeps the change to the case the probe covered. Sampled D16 results still zero the high half as before. That's worth a follow-up once it's probed the same way.low_halffalls back to 0 when the old value isn't tracked, so the worst case is the previous behaviour.Merged into our fork's main.
AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T03:27:45Z.
Automated triage for the maintainers.
Needs work. For an odd number of packed D16
image_loadchannels, this keeps the last register's high half vialow_half(crates/victory-shader/src/emit/lower.rs, image result packing,op == 66only). 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
Imported from Marvisak/VIctory. Originally posted by ColorMeBoom on 2026-11-27T05:37:19Z.
RDNA1 run (AMD RX 5700 XT, Navi 10, driver 32.0.21045.29003, Windows 11 26200; from the batch in #3410). Head
4cfae26merged onto main63bcca4.The merge is textually clean, but it doesn't build on current main any more:
#2159 (
fc0c736, merged after this PR's last CI run) removedLower::low_half, which was unused on main by then. This PR's packed D16image_loadpath calls it. Putting the helper back, unchanged from before #2159, next tohalf_modifiersfixes the build:With it, the full
victory-shader --libsuite passes on the RX 5700 XT and WARP: 303 passed, 0 failed, 3 ignored. That includespacked_image_load_keeps_unwritten_high_half. Clippy-D warningsis clean, andlower.rsstays under the 512 KiB limit (521,332 bytes).AI use: Claude Code (Claude Opus 5.5).
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-27T08:40:10Z.
@EatCodeSleep2 I reproduced the build failure from @ColorMeBoom's report after merging
4cfae26onto63bcca4. The ready branch preserves your original commit. 64a1ae0 restores the upstreamlow_halfimplementation removed by #2159, as ColorMeBoom suggested.With the same fixture forced to WARP, main returns
0x00003c00in all 32 lanes for the one-channel case. The patched tree returns the expected0x5a5a3c00. The two-channel0x40003c00and three-channel0xdead4200checks also passed, alongside all six waterfall tests. Strict all-features shader Clippy and asset policy passed. The separate review request for before/after measurements of the native RDNA instruction is still open.You can take the branch as is. Please retain the Git author and ColorMeBoom co-author trailer if moving the helper commit. If you fold it into another commit, please also add:
Co-authored-by: andrewpozdnakov7-jpg [email protected]
AI-assisted with Codex. Synthetic texture and shader only.
Imported from Marvisak/VIctory. Originally posted by ColorMeBoom on 2026-11-27T23:06:30Z.
@andrewpozdnakov7-jpg @EatCodeSleep2 Ran the ready branch
64a1ae0on the RX 5700 XT (Navi 10, driver 32.0.21045.29003, Windows 11 26200). The fixture runs the hardware adapter and WARP in turn, and neither was skipped:packed_image_load_keeps_unwritten_high_halfpasses on both:0x5a5a3c00(one channel),0x40003c00(two) and0xdead4200(three) in all 32 lanes.waterfall_testspass.victory-shader --lib --features host: 303 passed, 0 failed, 3 ignored.This doesn't cover the open request for before/after measurements of the native RDNA instruction.
AI use: Claude Code (Claude Opus 5.5).
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-27T23:10:07Z.
Thanks @ColorMeBoom for testing the ready branch on the RX 5700 XT. That run confirms the translated 1-, 2- and 3-channel fixtures on both adapters. RDNA1 and WARP results on
64a1ae0For the native evidence requested in review, Leonida reports a separate gfx1036 wave32 run. The one-channel integer
image_loadandimage_load_miptests seeded the upper half with0x5a5a. It remained0x5a5aon 1D, 2D, 2D-array and 3D images. The report covers one- and two-channel masks. A native before/after word for the three-channel mask is still needed to complete the review request. The translated three-channel fixture's0xdead4200belongs in the host verification results. Pinned native test reportThe patch gates the merge on the
textureLoadpath, which is the scope of the available native evidence. Sampled and gathered results keep their current behavior pending measurements of those opcode families.AI-assisted with Codex.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.