Skip to content

feat(shader): implement v_movrelsd_b32, v_movrelsd_2_b32, v_swap_b32 and v_swaprel_b32 - #325

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
adriadam10:feat/relative-indexing
Oct 4, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
adriadam10:feat/relative-indexing

Conversation

@adriadam10

Copy link
Copy Markdown
Collaborator

What

Four VOP1 relative-move/swap opcodes threw VOP1 opcode is not supported. The ISA sweep found them. This PR implements them:

Opcode Semantics (measured on an RDNA2 GPU)
v_movrelsd_b32 (VOP1/VOP3 0x44) VGPR[D + M0] = VGPR[S0 + M0]
v_movrelsd_2_b32 (VOP1/VOP3 0x48) VGPR[D + M0[25:16]] = VGPR[S0 + M0[9:0]]
v_swaprel_b32 (VOP1 0x68) swap VGPR[D + M0[25:16]] and VGPR[S0 + M0[9:0]]
v_swap_b32 (VOP1 0x65) swap VGPR[D] and VGPR[S0]

The split forms use 10-bit fields: with M0 = 0xfc03fc02 the offsets are 3 and 2. A plain v_movrelsd uses the whole M0, so with M0 = 0x00020002 it writes nothing.

The lowering is the existing one from v_movrels/v_movreld: a select over every VGPR the program references at or past the base. It is now factored into readRelativeVector/writeRelativeVector and shared by the six opcodes. The embedded-vertex-fetch scan treats the new relative writes like v_movreld (it forgets every tracked lane), and treats v_swap_b32 as writing both registers.

Not changed: an out-of-range relative read returns 0 on hardware (past the allocated VGPRs). Here it keeps the base register's value, as v_movrels already does. That depends on the VGPR allocation, which the recompiler doesn't model.

Test agc_driver_relative_indexing: 11 results × 32 lanes, captured on the RDNA2 GPU (ROCm HSA, raw kernels). It covers each opcode, high M0 bits ignored by the split forms, an out-of-range full-M0 write, v_swaprel with both offsets on the same register, and the VOP3 form.

Tested

Linux, full ctest (99) passes.

  • RADV (Radeon 660M) and lavapipe: the test passes.
  • Using the whole M0 as the source offset of the split forms fails: swapped_2 is 0x00001000, expected 0x00001002.

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 2, 2026 •

Copy link
Copy Markdown

Progress report (d3ec1f1 → 1b7e0e4)

📈 GPU shader instructions: 71.36% (+0.35%, +4 implemented instructions)

✅ 4 implemented
Encoding Name
VOP1 V_MOVRELSD_2_B32
VOP1 V_MOVRELSD_B32
VOP1 V_SWAPREL_B32
VOP1 V_SWAP_B32

This was referenced Oct 2, 2026
@github-actions github-actions Bot added build shader core/shader labels Oct 2, 2026
@github-actions github-actions Bot added agc libSceAgc* ci .github needs rebase Conflicts with main, rebase needed labels Oct 2, 2026
…and v_swaprel_b32

v_movrelsd moves VGPR[src + M0] to VGPR[dst + M0]. The _2 form and
v_swaprel take the source offset from M0[9:0] and the destination
offset from M0[25:16]; v_swaprel and v_swap exchange the two registers.
They reuse the select-over-registers lowering of v_movrels/v_movreld,
now shared as readRelativeVector/writeRelativeVector.

Co-Authored-By: Claude <noreply@anthropic.com>
@adriadam10
adriadam10 force-pushed the feat/relative-indexing branch from acb82e7 to 1b7e0e4 Compare October 3, 2026 09:44
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 3, 2026
@oneandonlydean
oneandonlydean merged commit 13cbbfa into boykopovar:main Oct 4, 2026
3 checks passed
@adriadam10
adriadam10 deleted the feat/relative-indexing branch October 5, 2026 06:47
SP4C3B4R-8 pushed a commit to SP4C3B4R-8/AnyPS5 that referenced this pull request Oct 6, 2026
Takes the 13 gate-batch PRs that merged upstream (boykopovar#319 boykopovar#329 boykopovar#330 boykopovar#331 boykopovar#325
boykopovar#435 boykopovar#471 boykopovar#294 boykopovar#376 boykopovar#404 boykopovar#394 boykopovar#401 boykopovar#446) in place of astrobot's local
versions, as integ/gate-batch cab0eab had them: boykopovar#294 and boykopovar#376 in
astrobot's depth model (DepthTarget, state.depth), boykopovar#394 with the thick mip
tails, boykopovar#401 over astrobot's slab pool, boykopovar#471 keeping the settled single-lane
path. Also takes the rest of main since a818bee (boykopovar#532 boykopovar#340 boykopovar#486 boykopovar#484 boykopovar#316
boykopovar#243 boykopovar#334 boykopovar#434 boykopovar#437 boykopovar#470 boykopovar#373 boykopovar#452 boykopovar#455 and our upstreamed PRs, where
astrobot keeps its later revisions and env switches).

Resolution notes: relinker converter/matcher/tests are upstream's (boykopovar#432
decoder covers VEX RIP-relative followers); RecompileResult gains boykopovar#316's
hostSubgroupSize (set from request.target.subgroupSize); shader disk cache
format 9; boykopovar#452's scissor message; upstream's later live-stack and
memory-copy decode tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Mgp3oZvembQziVNE2xARQK
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