Skip to content

Shaders: decode and lower v_dot8_i32_i4 - #22

Merged
DesertGamer merged 1 commit into
DesertGamer:mainfrom
lcg007xd-c:shader/v-dot8-i32-i4
Nov 25, 2026
Merged

DesertGamer merged 1 commit into
DesertGamer:mainfrom
lcg007xd-c:shader/v-dot8-i32-i4

Conversation

@lcg007xd-c

@lcg007xd-c lcg007xd-c commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

VOP3P opcode 0x18, v_dot8_i32_i4, is missing from gfx10/opcodes.rs (0x17 v_dot4_u32_u8 and 0x19 v_dot8_u32_u4 are there). A program that uses it fails to decode, so the whole shader is lost. LLVM's gfx1030 disassembler and the RDNA2 ISA both list it:

$ echo "0x01,0x40,0x18,0xcc,0x00,0x01,0x02,0x1c" | llvm-mc --disassemble -triple=amdgcn -mcpu=gfx1030
	v_dot8_i32_i4 v1, v0, v0, v0

The change:

  • gfx10/opcodes.rs: adds (0x018, "v_dot8_i32_i4").
  • emit/lower.rs: lowers it in the v_dot4_i32_i8 arm, so it gets the same operand handling (op_sel / op_sel_hi, folded inline constants). The result is eight signed nibble products plus the accumulator, wrapping. Each nibble is shifted to the top and arithmetic-shifted back by 28 to extend its sign. As with v_dot4_i32_i8, clamp and neg_hi are refused (an Unsupported error) rather than computed wrongly.
  • Tests:
    • emit::lower::tests::signed_nibble_dot_products_decode_and_lower: decodes the encoding above, lowers it with the result stored to LDS, and checks that the clamp form is refused. This runs on any host.
    • emit::semantics_tests::nibble_dot_products_match_the_hardware: a hardware probe next to byte_dot_products_match_the_hardware, against a CPU model of the instruction. nibble_dot_model_follows_the_isa checks that model on hand-worked cases (all -8 nibbles, -1 × 7, a single pair, a wrapping sum). Both are Windows/D3D12 only, like the rest of that file.

This ports the same change I sent upstream (Marvisak/VIctory#2768, not merged there yet). It was merged in uiliannn/VItoriaBr#44.

Checked

  • No game data of any kind (files, extracts, screenshots, dumps, saves): see docs/asset-policy.md
  • No binary files or archives
  • No new dependency, build.rs, git hook, .cargo config, CI change or script (or an issue explains why)
  • No download, no started program, no network connection added (or an issue explains why)
  • cargo test --workspace passes (only viport-shader --lib on Linux, see below)
  • cargo clippy --workspace --all-targets --locked -- -D warnings passes (for viport-shader, with CI: clear the clippy errors that keep main red since a3e7f17 #21 applied, see below)
  • The code I wrote is formatted with rustfmt; I did not reformat lines I did not change

What I ran

On Linux, Rust 1.98.1 (pinned):

Not run: the Windows/D3D12 tests in semantics_tests.rs, including the new hardware probe. I have no Windows machine or GPU, so the lowering has not been executed on a device. Its arithmetic is plain 32-bit integer shifts, multiplies and adds, and nibble_dot_products_match_the_hardware will check it against the model on WARP and the host GPU.

Overlaps

#21 (CI clippy fix) also edits lower.rs, but in other functions. The two merge cleanly in either order; I checked that locally. #27 moves the lower.rs unit tests into emit/lower_tests.rs. If it lands first, the new signed_nibble_dot_products_decode_and_lower test has to move with them; I will rebase this PR if so. No other open PR touches the dot-product lowering or the VOP3P table.

🤖 Generated with Claude Code

VOP3P opcode 0x18 was missing from the decoder, so any program using it
failed to decode. It is lowered as eight signed nibble products plus the
accumulator, wrapping, like the RDNA2 ISA; clamp is refused, as for
v_dot4_i32_i8.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DesertGamer
DesertGamer merged commit 50d6bae into DesertGamer:main Nov 25, 2026
1 check failed
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.

2 participants