shader: lower v_sat_pk_u8_i16 #85
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/uiliannn--VItoriaBr!85
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-85"
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?
@lcg007xd-c on GitHub · 2026-11-25 22:12 UTC · original
lcg007xd-c:shader-sat-pk-u8→main· +78 −0 · 2 files · 1 commits · openWhat is broken
v_sat_pk_u8_i16(VOP1 0x62, VOP3 0x1E2) decodes, but a program using it fails to translate withv_sat_pk_u8_i16 is not supported. I found it by translating a one-instruction program for every opcode the decoder names. It packs two signed 16-bit values into two bytes. Mesa's ACO also lists it for gfx10 (aco_opcodes.py,gfx10=0x62).Semantics
AMD's RDNA2 ISA (§12.8, opcode 98) defines it as
D.u32 = {16'b0, sat8(S0[31:16]), sat8(S0[15:0])}. Each half is a signed 16-bit value clamped to [0, 255]. The low half goes to byte 0, the high half to byte 1, and the top 16 bits are 0.The change (
emit/lower.rs, ininteger)Each half is sign-extended, clamped to [0, 255] and placed in its byte.
Tests
emit::lower::tests::saturating_byte_pack_translates(every host): the VOP1 and VOP3 forms decode to the name, and a program that stores the result translates. Without thelower.rschange it fails:v_sat_pk_u8_i16 [7e00c501, 7e000000]: GFX10 code at 0x24: v_sat_pk_u8_i16 is not supported.valu_tests::v_sat_pk_u8_i16_clamps_each_signed_half_to_a_byte(Windows/GPU): in-range halves, 255/256, −32768/−1, and 32767/128.lli. I compared both encodings against Rust'si16::clampon 306 inputs (300 scrambled patterns plus edges). All match.Run here (Linux, Rust 1.98.1):
cargo test -p victory-shader --lib --locked: 188 passed, 0 failed, 2 ignored.CARGO_FEATURE_PURE=1 cargo clippy -p victory-shader --all-targets --target x86_64-pc-windows-msvc -- -D warnings: clean.Not run here: the GPU case, since I have no Windows machine. The top 16 bits follow the ISA's
16'b0. I could not check on RDNA2 hardware whether it keeps the destination's high half instead, as some 16-bit results do on GFX10.🤖 Generated with Claude Code
VOP1 0x62 (VOP3 0x1E2) decoded but failed to translate ("v_sat_pk_u8_i16 is not supported"). AMD's RDNA2 ISA: D.u32 = {16'b0, sat8(S0[31:16]), sat8(S0[15:0])}, each half a signed 16-bit value clamped to [0, 255]. Co-Authored-By: Claude Opus 5.5 <[email protected]>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.