shader: lower v_cvt_off_f32_i4 #84
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!84
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-84"
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:09 UTC · original
lcg007xd-c:shader-cvt-off-f32-i4→main· +64 −0 · 2 files · 1 commits · openWhat is broken
v_cvt_off_f32_i4(VOP1 0x0E, VOP3 0x18E) decodes, but a program using it fails to translate withv_cvt_off_f32_i4 is not supported. I found it by translating a one-instruction program for every opcode the decoder names. AMD's ISA describes it as "used for interpolation in shader": it turns a 4-bit sample offset into a float.Semantics
AMD's RDNA2 ISA (§12.8, opcode 14) gives a table.
S0[3:0], read as a signed nibble, maps to nibble/16:1000→ −0.5,1111→ −0.0625,0000→ 0, and0111→ 0.4375. The other bits of S0 do not count.The change (
emit/lower.rs, invalu_op)omodand clamp apply throughwrite_f, as for any f32 result.Tests
emit::lower::tests::nibble_offset_conversion_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 withv_cvt_off_f32_i4 is not supported.valu_tests::v_cvt_off_f32_i4_matches_the_isa_table(Windows/GPU): all 16 nibbles, with junk in bits 31:4.lli. I checked both encodings, plusomod ×4(0.4375 → 1.75) and clamp (−0.5 → 0). 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.
🤖 Generated with Claude Code
VOP1 0x0E (VOP3 0x18E) decoded but failed to translate ("v_cvt_off_f32_i4 is not supported"). AMD's RDNA2 ISA gives it as a table: S0[3:0] read as a signed nibble, over 16 (1000 -> -0.5, 0111 -> 0.4375), "used for interpolation". It lowers as the sign-extended nibble converted to f32 times 1/16, which is exact; omod and clamp apply as for any f32 result. 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.