Shaders: lower SOP2 s_pack_{ll,lh,hh}_b32_b16 (#815) #2359
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2361"
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 fuzeofficlal on 2026-11-25T11:53:17Z.
Summary
Lowers the three RDNA2 SOP2 scalar 16-bit half-word pack instructions in
Lower::sop(crates/victory-shader/src/emit/lower.rs):s_pack_ll_b32_b16(0x32):(S0.u32 & 0xFFFF) | (S1.u32 << 16)s_pack_lh_b32_b16(0x33):(S0.u32 & 0xFFFF) | (S1.u32 & 0xFFFF_0000)s_pack_hh_b32_b16(0x34):(S0.u32 >> 16) | (S1.u32 & 0xFFFF_0000)In the native compute pipeline measurements reported in #815 (
#issuecommentworld run breakdown),s_pack_ll_b32_b16(104 distinct programs) ands_pack_hh_b32_b16(48 distinct programs) account for 152 refused compute programs.ISA Semantics
gfx10/opcodes.rs(0x32..=0x34) andgfx10/fields.rs(salu_dwords) already decode all three opcodes as 32-bit SOP2 instructions.SCCwrite: Per the AMD RDNA2 ISA Reference Guide (SOP2S_PACK_*_B32_B16), none of the three variants reads or modifiesSCC.ir::writes_sccalready leavesSCCuntouched (write(Reg::Scc) == None), andLower::sopreturnsNonefor theSCCflag.SSrc_b32operands, so inline float constants (240..=248) expand to their 32-bitf32bit patterns viasrc32(self.operand->resource::inline), e.g.1.0(242) =0x3F80_0000(lo16 = 0x0000,hi16 = 0x3F80).Verification
ir::tests::scalar_pack_does_not_clobber_scc: verifies IR SSA wiring leavesSCClive acrosss_cmp_eq_u32 -> s_pack_{ll,lh,hh}_b32_b16 -> s_cselect_b32.emit::valu_tests::scalar_pack_b16_halves_and_preserves_scc: validates emitted DXIL withdxil.dlland executes on both hardware (AMD Radeon(TM) GraphicsRDNA2) andWARP, covering SGPRs, inline signed/unsigned integers,NULL, 32-bit literals, inline float1.0(242), andSCCpreservation.cargo clippy -p victory-shader --lib --tests --all-features --locked -- -D warnings&cargo xtask policypass.Refs #815
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T12:35:52Z.
Review: APPROVED
Tested locally: merged into main
940d32f69b,cargo test -p victory-shader --lockedon macOS arm64 — 145 passed, 0 failed, 2 ignored (Windows-gated hardware execution tests not run here). Approving — SOP2 s_pack_{ll,lh,hh}_b32_b16 lowered (#815).Imported from Marvisak/VIctory. Originally posted by welisonzika14-jpg on 2026-11-25T12:25:17Z.
First run on NVIDIA hardware here, as far as I can see. RTX 5070 (Blackwell, driver 621.24), Ryzen 7 5700X, Windows 11, Rust 1.98.1 MSVC, no game files. Head
58727a2merged ontomain940d32f,cargo test -p victory-gpu -p victory-shader --lib --no-fail-fast.The PR's new test(s) pass on this card:
emit::valu_tests::scalar_pack_b16_halves_and_preserves_scc,ir::tests::scalar_pack_does_not_clobber_scc. The rest is the same asmainon this card: the 5 known NVIDIA failures from #1744 (2 view heap cap tests invictory-gpu, 3 invictory-shader), nothing new.One run, unit tests only, title not run.
Written with AI help (Claude/Kiro); the numbers are from runs on my machine.
upstream-sync referenced this pull request2026-11-25 13:02:56 +00:00
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T14:46:33Z.
Automated triage for the maintainers.
Merge candidate. Adds
s_pack_ll/lh/hh_b32_b16to the SOP2 lowering incrates/victory-shader/src/emit/lower.rs; the opcodes were already decoded (gfx10/opcodes.rs0x32-0x34) but not lowered. I checked the three formulas against the public RDNA2 ISA description of the instructions, and thatir::writes_scc(stempacknot in its list) already leaves SCC untouched, which the new IR test pins down; the GPU test covers SGPRs, inline integers and floats, literals and SCC preservation.CI:
checkpassing. A contributor also reports the new tests passing on an RTX 5070.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by Victorzinn704 on 2026-11-26T18:08:19Z.
Review: COMMENTED
Independent graphics-stage check for this SOP2 lowering. I exercised
s_pack_ll_b32_b16,s_pack_lh_b32_b16, ands_pack_hh_b32_b16in three synthetic pixel shaders with runtime root constants. On main63bcca43c6a0the new test stops atUnsupported { what: "s_pack_ll_b32_b16", … }. With the shader changes from58727a25d005applied, all 12 RGBA pixels matched the RDNA2 ISA expectations on each of RTX 5060 Ti (616.92) and WARP. The SDK DXIL validator accepted the VS and all three PS modules.This complements the existing compute and SCC tests by going through D3D12 graphics pipeline creation, drawing, and reading back the render target. The patch applies to the PR head. To verify it on Windows, run
cargo test --locked -p victory-shader --lib scalar_pack -- --nocapture --test-threads=1.Optional pixel shader regression patch
Save the diff as a patch file and use
git applyon the PR branch.AI-assisted. The results are from local runs with synthetic shaders.
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T21:49:03Z.
Review: APPROVED
LGTM — verified on RTX 5090 and
VICTORY_WARP=1(Windows / D3D12) againstorigin/main(63bcca4).s_pack_{ll,lh,hh}_b32_b16while preserving SCC matches RDNA2 hardware behavior cleanly on both RTX 5090 and WARP.cargo test -p victory-shader --lib emit::valu_tests::scalar_pack_b16_halves_and_preserves_scc -- --test-threads=1: passed on RTX 5090 andVICTORY_WARP=1.cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
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.