Shaders: preserve the unwritten high half of packed D16 buffer loads #1440
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1441"
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-24T18:01:46Z.
Addresses the destination register preservation part of VIC-BT-015 in #1242. For buffer_load_format_d16_x/xyz, merge the last channel into the low half of the final VGPR. A full pair still replaces the whole VGPR. Integer format interpretation is separate.
The synthetic typed-buffer regression covers x, xy and xyz. The one-channel case on main read back 0x00003c00 instead of 0x5a5a3c00. The native D16 buffer probe also checks that the x form preserves the original high half. This PR shares the small test builder extension from #1437 and can land independently.
120 shader tests and strict shader Clippy passed on Windows. The shader suite excluded the existing v_med3_f32 host NaN failure.
AI use: Codex wrote and tested the change.
DXGI_ERROR_DEVICE_HUNG/0x887A0004/0x887A0006#1439Imported from Marvisak/VIctory. Originally posted by marquezinii on 2026-11-24T18:33:42Z.
Ran on an RTX 5070 (desktop, driver 621.40, the only adapter), Windows 11 26300, Rust 1.98.1 at
60bf416.cargo test -p victory-shader --lib -- --test-threads=1 --nocapturegives 121 passed, 0 failed, 1 ignored.packed_buffer_load_keeps_unwritten_high_halfpasses on the hardware adapter and WARP, and nothing on the hardware adapter was skipped. The only skips are the fourdiff_teststhat need the console compiler.I also merged this with #1437 locally:
build_with_handle_countcomes out once and both merge cleanly in either order, so they really can land independently.Imported from Marvisak/VIctory. Originally posted by AnoHunted on 2026-11-24T18:38:12Z.
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_buffer_load_keeps_unwritten_high_half.Not tested: the in-game effect; AMD. (Sibling #1437, the image version, reported separately.)
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T19:25:01Z.
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.Same unwritten-high-half fix as #1437 but for packed D16 buffer loads: the last odd channel goes through
low_halfso the high half of the destination VGPR survives. Three waterfall cases across 1/2/3-channelbuffer_load_format_d16_*(Windows-only); macOS 96 green.Note: conflicts with #1437 in
waterfall_tests.rs(identicalbuild_with_handle_countrefactor); complementary inlower.rs— land one, rebase the other.Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-24T20:43:55Z.
Offline measurement on a retail dump, and the shader tests on Ada
Result: no count change against
main.Offline. I merged head
60bf416ontomainffe310e(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 upipibi on 2026-11-25T00:30:32Z.
A related measured rule for the same function (
d16_channels), in case it's worth folding in here or in a follow-up. Not run here; it comes from reading plus two hardware measurements.min(x, 0xffff)and SINT toclamp(x, -32768, 32767). For example, a 32_UINT 70000 (0x11170) loads as0xffff, where& 0xFFFFgives0x1170. This was measured forbuffer_load_format_d16_*on gfx1031 (cited in xcl-dev/xcl#1488 item XCL-BT-020, which xcl-dev/xcl#1977 now implements). It was also measured for D16 image reads on gfx1036 in boykopovar/AnyPS5#22750. 8- and 16-bit formats never leave that range, so they're unaffected. (Now #1927, which merges cleanly with this PR.)32-bit float texels round toward zero …Correction: on D3D12 the legacy f32→f16 conversion already rounds toward zero. I measured it in XCL's equivalent path on an RTX 3070 (616.56) and on WARP:legacyF32ToF16rounds to nearest.1 + 3·2⁻¹¹→0x3c01, 70000 →0x7bff. That matches RDNA2, so only the integer saturation above applies here. AnyPS5's float case came from Vulkan'spackHalf2x16.#1437 has the image-side counterpart, if the image D16 path packs the same way.
AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T03:27:53Z.
Automated triage for the maintainers.
This pull request no longer merges cleanly into
main(conflicts incrates/victory-shader/src/emit/lower.rs). It will be reviewed once it is rebased onto the currentmain. The earlier verdict (needs-work) was for an older state ofmain.Generated by Claude Code
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.