Skip to content

Shaders: decode GFX10 packed inline constants by operand type - #637

Merged
Marvisak merged 1 commit into
Marvisak:mainfrom
AlanQiang0418:codex/gfx10-packed-inline-constants
Nov 24, 2026
Merged

Marvisak merged 1 commit into
Marvisak:mainfrom
AlanQiang0418:codex/gfx10-packed-inline-constants

Conversation

@AlanQiang0418

Copy link
Copy Markdown
Contributor

A synthetic v_pk_add_f16 on main (d2a4bae) added the inline constant 1/(2π) to zero and returned 0x31183118 on the hardware adapter. GFX10's default half selectors should produce 0x00003118. 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 table

The 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.

Instruction Source halves selected Expected and observed after fix
v_pk_add_f16 Low, high 0x00003118
v_pk_add_f16 Low, low 0x31183118
v_pk_add_u16 Low, high 0x3e22f983

All 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-shader reported 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

Lyrnc commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

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.

Instruction Hardware Your expected
v_pk_add_f16 v, 1/(2π), 0 (default op_sel_hi) 0x00003118 0x00003118
v_pk_add_f16 v, 1/(2π), 0 op_sel_hi:[0,1] 0x31183118 0x31183118
v_pk_add_u16 v, 1/(2π), 0 0x3e22f983 0x3e22f983
v_pk_add_u16 v, 1/(2π), 0 op_sel_hi:[0,1] 0xf983f983
v_pk_add_u16 v, 1.0, 0 0x3f800000
v_pk_add_f16 v, 1.0, 0 0x00003c00
v_pk_add_u16 v, -1, 0 (integer inline) 0xffffffff
v_pk_add_u16 v, 1, 0 (integer inline) 0x00000001

So 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 new float argument gives.

The same kernel shape also shows v_fma_mix* and v_pack_b32_f16 see {0x0000, f16} (details on #78), which matches your f16_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

Copy link
Copy Markdown

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 with OP_SEL selecting 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 the GetModuleFileNameA one: the shared-site map only earns trust if the good news gets posted too.

@Marvisak
Marvisak merged commit cf0bb43 into Marvisak:main Nov 24, 2026
Yaekai pushed a commit to Yaekai/VIctory that referenced this pull request Nov 24, 2026
suirentakamura referenced this pull request in suirentakamura/victory-suiren Nov 24, 2026
…constants

Shaders: decode GFX10 packed inline constants by operand type
itsonlysimbo pushed a commit to itsonlysimbo/VIctory that referenced this pull request Nov 24, 2026
…-inline-constants

Shaders: decode GFX10 packed inline constants by operand type
geiyiliyabumo pushed a commit to geiyiliyabumo/VIctory that referenced this pull request Nov 25, 2026
…-share-440-111a

HLE: preserve LastError and share mode on dstorage open (Marvisak#440)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants