Shaders: decode GFX10 packed inline constants by operand type #637
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!637
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/637/head"
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?
@AlanQiang0418 on GitHub · 2026-11-24 06:02 UTC · original
AlanQiang0418:codex/gfx10-packed-inline-constants→main· +45 −21 · 2 files · 1 commits · merged 2026-11-24 08:19 UTCA synthetic
v_pk_add_f16on main (d2a4bae) added the inline constant1/(2π)to zero and returned0x31183118on the hardware adapter. GFX10's default half selectors should produce0x00003118. The translator duplicated the FP16 bits before applying the selectors. It also used that FP16 representation for packed integer instructions, which interpret the same encoding as a full FP32 bit pattern. LLVM’s GFX10 encoding tableThe change shares the existing FP16 constant decoding with packed float instructions and uses the existing 32-bit operand reader for packed integer instructions. The regression test adds the same inline constant to zero in three synthetic shaders.
v_pk_add_f160x00003118v_pk_add_f160x31183118v_pk_add_u160x3e22f983All three cases passed DXIL validation and ran on the hardware adapter and WARP on a Windows machine with an RTX 5080.
cargo test --locked -p victory-shaderreported 70 passed. Four differential tests skipped their comparisons because the console compiler was unavailable. I did not run the game.Two open PRs touch this helper. #78 moves the existing half duplication into a shared helper. #465 adds dot-product callers, which will need to select the operand representation when rebasing. Mixed-precision conversion PR · Dot-product PR
@Lyrnc on GitHub · 2026-11-24 06:06 UTC · original
RDNA2 hardware confirmation of the table: all three expected values are what gfx1036 returns, from the hardware rather than from LLVM's encoding table.
Setup. AMD Radeon iGPU of a Ryzen 7 9800X3D, gfx1036 (RDNA2), AMD driver 32.0.21042.62, Windows 11 Pro 26200. A HIP kernel (assembled by the AMD driver's amd_comgr) adds each inline constant to a zero VGPR. RDNA2 desktop silicon, not the console's. No game data.
v_pk_add_f16 v, 1/(2π), 0(defaultop_sel_hi)0x000031180x00003118v_pk_add_f16 v, 1/(2π), 0 op_sel_hi:[0,1]0x311831180x31183118v_pk_add_u16 v, 1/(2π), 00x3e22f9830x3e22f983v_pk_add_u16 v, 1/(2π), 0 op_sel_hi:[0,1]0xf983f983v_pk_add_u16 v, 1.0, 00x3f800000v_pk_add_f16 v, 1.0, 00x00003c00v_pk_add_u16 v, -1, 0(integer inline)0xffffffffv_pk_add_u16 v, 1, 0(integer inline)0x00000001So a float inline constant in a packed float op is
{0x0000, f16}, in a packed integer op it is the full f32 pattern, and an integer inline constant is its 32-bit value (-1 fills both halves). That is what the newfloatargument gives.The same kernel shape also shows
v_fma_mix*andv_pack_b32_f16see{0x0000, f16}(details on #78), which matches yourf16_operand.AI use: Claude Code (Claude Opus 5.5) wrote the probes, ran them on the GPU above and drafted this comment; the numbers come from the hardware run.
@pickles976 on GitHub · 2026-11-24 06:16 UTC · original
Cross-check result from the ivall/xcl side: this class is absent here, verified semantically rather than by grep. Our 16-bit VALU model (
valu16+code32) puts inline f16 constants (codes 240–248) in the low half withOP_SELselecting the high half per source (which then reads 0 — matching hardware), hands integer instructions the f32 bit pattern of the same code, and the instruction spec carries f16 VALU only in the 16-bit encoding (no VOP3 dual-half packed form on gfx10), so OPSEL handling has no second path to diverge on. Noting it in your thread the same way I noted theGetModuleFileNameAone: the shared-site map only earns trust if the good news gets posted too.