shader: lower v_lerp_u8 #86
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!86
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-86"
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:14 UTC · original
lcg007xd-c:shader-lerp-u8→main· +85 −0 · 2 files · 1 commits · openWhat is broken
v_lerp_u8(VOP3 0x14D) decodes, but a program using it fails to translate withv_lerp_u8 is not supported. I found it by translating a one-instruction program for every VOP3 opcode the decoder names. It averages packed unsigned bytes, the usual way to blend two RGBA8 values.Semantics
AMD's RDNA2 ISA (§12.12, opcode 333) defines it as an "unsigned 8-bit pixel average on packed unsigned bytes":
D.u[8i+7:8i] = (S0.u[8i+7:8i] + S1.u[8i+7:8i] + S2.u[8i]) >> 1. Bit 0 of each byte of S2 is the rounding bit: set rounds a .5 up, clear truncates it.The change (
emit/lower.rs, ininteger)Per byte: extract both bytes, add them plus the rounding bit, shift right by one, and place the result back. No byte can carry into the next: the most is
(255 + 255 + 1) >> 1 = 255.Tests
emit::lower::tests::byte_average_translates(every host): the encoding decodes to the name, and a program that stores the result translates, with src2 a VGPR or an SGPR. Without thelower.rschange it fails:v_lerp_u8 [d54d0000, 040e0501]: GFX10 code at 0x24: v_lerp_u8 is not supported.valu_tests::v_lerp_u8_averages_bytes_rounding_by_s2(Windows/GPU): exact averages, .5 truncated and rounded up,0xFF+0xFFwith S2 bytes0xFE/0xFF(only bit 0 counts), and mixed bytes.lli. I compared against a Rust reference on 203 inputs (200 scrambled triples 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.
🤖 Generated with Claude Code
VOP3 0x14D decoded but failed to translate ("v_lerp_u8 is not supported"). AMD's RDNA2 ISA: each byte of the result is the average of S0's and S1's bytes, rounded up when bit 0 of S2's byte is set: (S0.u8 + S1.u8 + S2.u[8i]) >> 1. 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.