Shaders: lower SOP2 s_pack_{ll,lh,hh}_b32_b16 (#815) #2361
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2361
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@fuzeofficlal on GitHub · 2026-11-25 11:53 UTC · original
fuzeofficlal:feat/shader-spack-b32-b16-815→main· +124 −0 · 3 files · 1 commits · openSummary
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
@welisonzika14-jpg on GitHub · 2026-11-25 12:25 UTC · original
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.
@Marvisak on GitHub · 2026-11-25 14:46 UTC · original · edited 2026-11-25 14:48 UTC
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
@catminou4 on GitHub · 2026-11-25 12:35 UTC · original · approved these changes
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).@Victorzinn704 on GitHub · 2026-11-26 18:08 UTC · original · reviewed
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.
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.