Skip to content

feat(shader): implement v_dot2_f32_f16 - #576

Merged
oneandonlydean merged 2 commits into
boykopovar:mainfrom
CnRJay:feat/vop-legacy-fma-dot2
Oct 5, 2026
Merged

oneandonlydean merged 2 commits into
boykopovar:mainfrom
CnRJay:feat/vop-legacy-fma-dot2

Conversation

@CnRJay

@CnRJay CnRJay commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

What

v_dot2_f32_f16 (VOP3P 0x13) threw VOP3P opcode is not implemented.

It computes src0.lo * src1.lo + src0.hi * src1.hi + src2 as two f32 fmas in the same order as the existing v_dot2c_f32_f16. The f16 products are exact in f32, so only the two additions round.

  • op_sel/op_sel_hi select the halves of the packed sources, and neg_lo/neg_hi negate them.
  • neg negates the f32 accumulator, and clamp clamps the result.
  • op_sel and neg_hi on the accumulator throw in the decoder, since their meaning for the f32 operand is not known.

tools/progress.py: VOP3P 29/29.

Tested

Windows 11, MinGW GCC 15.2.0 r7, NVIDIA Vulkan, -DANYPS5_ENABLE_SPIRV_TOOLS=ON.

  • New agc_driver_float16_dot, 64 lanes. The inputs are 8 edge rows (signed zeros, infinities, inf * 0, NaN, f16 max with a large negative accumulator) plus random normal values. Each lane checks four forms against a CPU fma model:

    • the plain form;
    • op_sel swapping the halves of src0;
    • neg_lo/neg_hi with a negated accumulator;
    • clamp.

    The test also checks that the decoder refuses accumulator op_sel and neg_hi.

  • Full ctest: 213/214 pass. agc_shader_memory fails without this change too; fix(shader): splat the bindless table hit into a bool vector for SPIR-V 1.3 #574 fixes it.

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: none
  • AI-assisted: yes

🤖 Generated with Claude Code

VOP3P 0x13 threw "VOP3P opcode is not implemented". It computes
src0.lo * src1.lo + src0.hi * src1.hi + src2 like v_dot2c_f32_f16, with
the VOP3P op_sel/op_sel_hi and neg_lo/neg_hi modifiers on the packed f16
sources, neg on the f32 accumulator and clamp. op_sel and neg_hi on the
accumulator throw.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@oneandonlydean

Copy link
Copy Markdown
Collaborator

Thanks. The test shader disassembles (llvm-mc, gfx1030) to the four forms you describe, and the two refusal words are op_sel:[0,0,1] and neg_hi:[0,0,1]. The translation mirrors the existing v_dot2c_f32_f16 (two fmas, low half first), and op_sel/op_sel_hi/neg_lo/neg_hi on the packed sources go through readF16LaneAsF32 as for the other packed f16 ops.

One small change: the accumulator's op_sel_hi bit (word0 bit 14) is ignored. LLVM sets it by default (v_dot2_f32_f16 v1, v2, v3, v4 encodes 0xcc134001), and op_sel_hi:[1,1,0] (0xcc130001) is accepted here and treated the same. Its meaning for the f32 operand isn't known any more than op_sel or neg_hi, and main's integer dots already refuse anything but op_sel_hi all ones (applyVop3pIntegerDotModifiers). Could you refuse op_sel_hi[2] == 0 together with the other two, with a third CheckRefused row?

agc_driver_float16_dot passes here on NVIDIA and fails on main ("VOP3P opcode is not implemented").

A note, not a blocker: the expected values come from a CPU model of the same two fmas, so the test pins the order and rounding rather than checking them against hardware. That's the same assumption main already makes for v_dot2c_f32_f16. If you have hardware values for a few lanes where the order matters, they'd make it exact.

PPSA21564 doesn't use v_dot2_f32_f16, so this doesn't affect my runs. The CI run still needs approval.

@github-actions

github-actions Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Progress report (b57f722 → 4b5baea)

📈 GPU shader instructions: 83.96% (+0.08%, +1 implemented instructions)

✅ 1 implemented
Encoding Name
VOP3P V_DOT2_F32_F16

Its meaning for the f32 accumulator is not known, like op_sel and neg_hi,
and the integer dots already refuse anything but op_sel_hi set on every
source.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added shader core/shader agc libSceAgc* labels Oct 5, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

Thanks, that's the change I had in mind. I checked the three refused words with llvm-mc (gfx1030, since gfx1013 has no v_dot2_f32_f16): 0xcc13000a is op_sel_hi:[1,1,0], next to the existing op_sel and neg_hi rows, and the decoder reads op_sel_hi[2] from word0 bit 14 as the hardware does. agc_driver_float16_dot passes here and fails on main's code.

The new push needs workflow approval again before CI runs. Ready to merge from my side once it's green.

@oneandonlydean
oneandonlydean merged commit 13e0afc into boykopovar:main Oct 5, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants