Skip to content

feat(shader): VOP3 v_add/sub_nc_i32 (clamp), v_mul_lo_u16, 16-bit mads, v_ashrrev_i64 - #257

Merged
boykopovar merged 2 commits into
boykopovar:mainfrom
adriadam10:feat/vop3-integer-gaps
Oct 2, 2026
Merged

boykopovar merged 2 commits into
boykopovar:mainfrom
adriadam10:feat/vop3-integer-gaps

Conversation

@adriadam10

Copy link
Copy Markdown
Collaborator

What

These VOP3 opcodes threw "VOP3 opcode is not implemented":

  • v_add_nc_i32, v_sub_nc_i32 (0x37f, 0x376), including clamp: these are what compilers emit for signed saturating add/sub (sadd.sat/ssub.sat), so clamp saturates to [INT32_MIN, INT32_MAX] (overflow from the sign bits, result (a >> 31) ^ 0x7fffffff). Other modifiers stay rejected.
  • v_mul_lo_u16 (0x305): integer16Binary(IMul32), op_sel on sources like the other 16-bit binaries.
  • v_mad_u16, v_mad_i16 (0x340, 0x35e): 16-bit result, op_sel on all three sources and the destination half.
  • v_mad_u32_u16, v_mad_i32_i16 (0x373, 0x375): 16x16 product plus a 32-bit addend, 32-bit result. They share the I16 ternary decode path but applyNativeVop3I16TernarySelectors no longer sets the 16-bit destination select or src2 op_sel for them (with it the result was truncated to 16 bits; the test caught that).
  • v_ashrrev_i64 (0x301): next to the existing v_lshrrev_b64.

Found with an ISA sweep (every gfx1013 opcode from llvm-mc through DecodeRdnaInstruction + TranslateInstruction).

Test agc_driver_vop3_integer: hand-assembled compute shader (words from llvm-mc -mcpu=gfx1013), 64 lanes with edge inputs (INT32_MIN/MAX overflow pairs, -1, 0x8000 halves, shift counts 0/31/32/63/64) and pseudo-random ones, 14 results per lane checked against a C++ model, including the clamp and op_sel forms. 16-bit results are checked on the written half only. No cross-lane ops, so it runs on lavapipe in CI.

Tested

Linux: passes on RADV (Radeon 660M) and lavapipe; without the change it fails with "VOP3 opcode is not implemented". Full ctest (99) passes.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: ci: run the shader execution tests on lavapipe #251 (test harness); review only the last commit
  • AI-assisted: yes

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Progress report (709d7fe → e144f43)

📈 GPU shader instructions: 53.34% (+0.68%, +8 implemented instructions)

✅ 8 implemented
Encoding Name
VOP3 V_ADD_NC_I32
VOP3 V_ASHRREV_I64
VOP3 V_MAD_I16
VOP3 V_MAD_I32_I16
VOP3 V_MAD_U16
VOP3 V_MAD_U32_U16
VOP3 V_MUL_LO_U16
VOP3 V_SUB_NC_I32

adriadam10 and others added 2 commits October 1, 2026 22:45
MixPrecision and SdwaDestination dispatch hand-assembled RDNA through the
recompiler and compare every lane with a CPU model, but were never in ctest.
Move them to tests/execution/, which is globbed into one test per file with
the same target names, so new execution tests add a file and no CMake lines.
They exit 77 (skipped) when the host has no Vulkan device; the Linux runner
installs lavapipe and sets ANYPS5_REQUIRE_VULKAN=1 so they cannot skip there.

Co-Authored-By: Claude <noreply@anthropic.com>
…6, v_mad_u16/i16/u32_u16/i32_i16, v_ashrrev_i64

These VOP3 opcodes threw in the decoder. v_add_nc_i32 and v_sub_nc_i32 are
what compilers emit for signed saturating add/sub, so their clamp saturates
to the int32 range. The 16-bit mads honour op_sel on their 16-bit sources;
the u32_u16/i32_i16 forms take a 32-bit addend and write all 32 bits, so
they do not get the 16-bit destination select.

Co-Authored-By: Claude <noreply@anthropic.com>
@adriadam10
adriadam10 force-pushed the feat/vop3-integer-gaps branch from 224c723 to e144f43 Compare October 1, 2026 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* build ci .github shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants