Skip to content

feat(shader): decode the s_endpgm variants, s_round_mode and SMEM probe/discard - #436

Merged
oneandonlydean merged 2 commits into
boykopovar:mainfrom
adriadam10:feat/sopp-smem-misc
Oct 5, 2026
Merged

oneandonlydean merged 2 commits into
boykopovar:mainfrom
adriadam10:feat/sopp-smem-misc

Conversation

@adriadam10

Copy link
Copy Markdown
Collaborator

What

Seven scalar opcodes threw at decode ("unsupported SOPP opcode", "SMEM opcode is not supported"). Found by the ISA
coverage sweep.

  • s_endpgm_saved (SOPP 0x1b) and s_endpgm_ordered_ps_done (SOPP 0x1e) decode to SEndpgm, so the decoder and
    the control flow graph treat them as program ends. Checked on an RDNA2 GPU: a store placed after either one never runs.
  • s_atc_probe, s_atc_probe_buffer, s_dcache_discard, s_dcache_discard_x2 (SMEM 0x26-0x29) go through the
    same path as s_dcache_inv/s_dcache_wb and translate to no-ops. On hardware the probes do nothing visible to
    the following code (the RDNA2 iGPU used here does not have the discards). The discards only drop dirty scalar
    cache lines, and scalar stores are not supported, so there is nothing to drop.
  • s_round_mode (SOPP 0x24) is a no-op like the s_setreg_b32 MODE writes on main, and is listed in
    TechnicalDebt. On hardware it does change float rounding (s_round_mode 0x3 makes 1.0 + 0x1.8p-24 give
    1.0 instead of 0x1.000002p+0). SPIR-V only has per-entry-point rounding modes, so it can't be followed
    at runtime.

Left out on purpose: s_setkill ends the wave on hardware even with 0, s_sethalt 1 halts it for a debugger,
and s_code_end hangs the wave if it runs (it is padding after the program end). These are debugger and padding
encodings that game code doesn't run.

Tested

  • New execution tests ScalarProgramEnd and ScalarProgramEndSaved (32 lanes). Each one runs all four SMEM ops
    and s_round_mode, then stores in + 1 and hits one of the two end variants. Two never-taken branches put a
    block right after the end that would overwrite the result, and another one past it; both must stay unwritten.
  • Both fail on main (decode throws). They pass on Linux with RADV and lavapipe.
  • Negative checks: decoding either end variant as s_nop fails ("store before the end is 0x00000bad"). Removing
    the s_atc_probe or s_dcache_discard_x2 decode, or the s_round_mode translation, fails at recompile.
  • Full Release build + ctest: 127/127.

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

@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Progress report (ebf29f8 → 36c2fa4)

📈 GPU shader instructions: 87.56% (+0.25%, +3 implemented instructions)

✅ 3 implemented
Encoding Name
SMEM S_ATC_PROBE
SMEM S_ATC_PROBE_BUFFER
SOPP S_ROUND_MODE

@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed shader core/shader docs agc libSceAgc* labels Oct 3, 2026
@adriadam10
adriadam10 force-pushed the feat/sopp-smem-misc branch from 292aea7 to 05ba96d 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

Copy link
Copy Markdown
Collaborator

Thanks, the two end variants and the four SMEM ops look right to me (encodings checked with llvm-mc for gfx1013, and since scalar stores aren't supported the discards really have nothing to drop).

The one part I can't merge as is: s_round_mode becomes a silent no-op for every mode and is listed under silent stubs. CONTRIBUTING keeps silent stubs to UI-only behaviour that unblocks a title, and your own measurement shows mode 3 changes results. Mode 0 is round to nearest even everywhere, which is what the recompiler already assumes, so could it translate s_round_mode 0 as a no-op and throw for any other immediate? Then the TechnicalDebt line isn't needed.

@adriadam10

Copy link
Copy Markdown
Collaborator Author

Thanks for checking the encodings. Done, rebased onto main:

  • s_round_mode 0 is a no-op and any other immediate throws, so the TechnicalDebt line is gone.
  • The two program-end tests no longer use s_round_mode 3 (it is now s_nop 0, same word count), and ScalarProgramEnd checks that s_round_mode 3 is refused. That check fails if the guard is removed.

Both pass on RADV and lavapipe.

@adriadam10
adriadam10 force-pushed the feat/sopp-smem-misc branch from 05ba96d to 2deefce Compare October 4, 2026 06:30
@oneandonlydean

Copy link
Copy Markdown
Collaborator

Thanks. s_round_mode 0 (round to nearest even for both f32 and f16/f64) as a no-op and a throw for any other immediate is what I had in mind, and with the TechnicalDebt line gone and ScalarProgramEnd checking that s_round_mode 3 is refused, the guard is covered. agc_driver_scalar_program_end and agc_driver_scalar_program_end_saved pass on my NVIDIA machine on current main, and fail on main's code.

Small heads-up: #264 adds s_denorm_mode (SOPP 0x25) right next to s_round_mode (0x24) in RdnaScalarOpDecoder.cpp and ScalarInstructions.cpp, so whichever of the two lands second needs a one-line rebase. Otherwise ready to merge from my side.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 4, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

#264 is on main now, so this needs the small rebase I mentioned: s_denorm_mode (0x25) sits right next to s_round_mode (0x24) in RdnaScalarOpDecoder.cpp (the opcode table and the SOPP list) and in ScalarInstructions.cpp, and keeping both sides in all three spots works. Ready to merge from my side after that.

adriadam10 and others added 2 commits October 5, 2026 03:34
…be/discard

s_endpgm_saved and s_endpgm_ordered_ps_done end the wave like s_endpgm
(checked on an RDNA2 GPU: nothing after them runs), so they decode to
SEndpgm and the control flow graph treats them as terminators.
s_atc_probe, s_atc_probe_buffer and s_dcache_discard(_x2) have no visible
effect and translate to no-ops like the other scalar cache controls.
s_round_mode is ignored like s_setreg MODE writes; listed in TechnicalDebt.

Co-Authored-By: Claude <noreply@anthropic.com>
Any other mode throws instead of being a silent no-op.

Co-Authored-By: Claude <noreply@anthropic.com>
@adriadam10

Copy link
Copy Markdown
Collaborator Author

Rebased on current main as you described: s_round_mode (0x24) and #264's s_denorm_mode (0x25) both kept in the SOPP opcode table, the SOPP wait list and ScalarInstructions.cpp. Both commits otherwise unchanged; agc_driver_scalar_program_end{,_saved} and the full ctest pass on RADV (only the known agc_driver_pixel_helper_lanes).

@adriadam10
adriadam10 force-pushed the feat/sopp-smem-misc branch from 2deefce to 36c2fa4 Compare October 5, 2026 01:35
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 5, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

Thanks, the rebase is right: s_round_mode (0x24) and s_denorm_mode (0x25) are both in the SOPP table and the wait list, and in ScalarInstructions.cpp s_round_mode still accepts only round to nearest even while s_denorm_mode keeps main's throw. Both commits are otherwise unchanged. agc_driver_scalar_program_end and agc_driver_scalar_program_end_saved pass here on the merged branch, and PPSA21564 has none of these instructions. Ready to merge from my side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* docs shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants