Skip to content

fix(shader): v_mov_b32 SDWA writes byte destinations - #499

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
MichonGoddijn231849:fix/vmov-sdwa-byte-destinations
Oct 4, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
MichonGoddijn231849:fix/vmov-sdwa-byte-destinations

Conversation

@MichonGoddijn231849

Copy link
Copy Markdown
Contributor

What

v_mov_b32 accepted SDWA destination selectors for the two words only. A byte destination (dst_sel BYTE_0..3) threw VOP1 SDWA destination selector is not supported. GTA V (PPSA04264) aborted during boot on such a move in one of its eboot compute shaders: v_mov_b32_sdwa with dst_sel:BYTE_0 dst_unused:UNUSED_PRESERVE src0_sel:DWORD. The compute recompile failure reached presentation, which terminates.

The write itself already handles byte destinations and every dst_unused mode (TranslationContext::writeRawU32, which other VOP1 conversions use for bytes). So the rule table now allows byte destinations for v_mov_b32 too, with the same source selectors as before. The error message now names the destination selector, dst_unused, the source selector, the opcode and the pc.

Tested

Windows 11 Pro, AMD Ryzen 5 7600, NVIDIA GeForce RTX 5080 (driver 32.0.16.1074), 32 GB DDR5-5600, MinGW-w64 GCC 15.2.0.

  • agc_driver_sdwa_destination now also runs v_mov_b32_sdwa with BYTE_0 and BYTE_2 under UNUSED_PRESERVE, and BYTE_1 under UNUSED_PAD, and checks each result byte. It passes on the GPU.
  • ctest: everything that passes on main here passes.
  • GTA V: the abort message above came from this build's clearer error. The boot crash is intermittent (that shader isn't dispatched on every boot), and I haven't yet re-run GTA with the fix.

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
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes. Written with Claude (Anthropic) under my direction; I reviewed and tested it.

🤖 Generated with Claude Code

v_mov_b32 accepted SDWA destination selectors for the words only; a byte
destination (dst_sel BYTE_0..3) threw 'VOP1 SDWA destination selector is not
supported'. The write itself already handles bytes and every dst_unused mode
(TranslationContext::writeRawU32). GTA V aborted during boot on such a move
(dst_sel BYTE_0, dst_unused UNUSED_PRESERVE) in one of its eboot compute
shaders. The error now names the selector, opcode and pc. The SDWA destination
execution test covers BYTE_0 and BYTE_2 with UNUSED_PRESERVE and BYTE_1 with
UNUSED_PAD.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@oneandonlydean

Copy link
Copy Markdown
Collaborator

Thanks, this is the right fix. Byte destinations already go through writeRawU32 (the f32 to int conversions use it with byte selectors today), so widening the v_mov_b32 rule is all that was missing. I checked the three new test instructions with llvm-mc (dst_sel:BYTE_0 and BYTE_2 with UNUSED_PRESERVE, BYTE_1 with UNUSED_PAD, all src0_sel:DWORD), and the expected values follow the SDWA rule: the low byte of the result lands in the selected byte, and the other bytes are kept or zeroed. The longer error message will make the next one of these quicker to find.

agc_driver_sdwa_destination passes on my machine at this head. With only the test file on main's code it fails with the old "VOP1 SDWA destination selector is not supported".

Optional, not blocking: with a byte destination, v_mov_b32 still refuses byte source selectors (partialDstSourceSelectors is words plus DWORD), and UNUSED_SEXT with a byte destination is accepted but not covered by a test row. If GTA V turns up a src0_sel:BYTE_n move next, that is the line to widen.

@oneandonlydean
oneandonlydean merged commit 037b905 into boykopovar:main Oct 4, 2026
4 of 5 checks passed
@MichonGoddijn231849
MichonGoddijn231849 deleted the fix/vmov-sdwa-byte-destinations branch October 9, 2026 20:05
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