feat(shader): decode the s_endpgm variants, s_round_mode and SMEM probe/discard #436
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/436"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-03T07:01:47Z.
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) ands_endpgm_ordered_ps_done(SOPP 0x1e) decode toSEndpgm, so the decoder andthe 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 thesame path as
s_dcache_inv/s_dcache_wband translate to no-ops. On hardware the probes do nothing visible tothe 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 thes_setreg_b32MODE writes onmain, and is listed inTechnicalDebt. On hardware it does change float rounding (
s_round_mode 0x3makes1.0 + 0x1.8p-24give1.0instead of0x1.000002p+0). SPIR-V only has per-entry-point rounding modes, so it can't be followedat runtime.
Left out on purpose:
s_setkillends the wave on hardware even with 0,s_sethalt 1halts it for a debugger,and
s_code_endhangs the wave if it runs (it is padding after the program end). These are debugger and paddingencodings that game code doesn't run.
Tested
ScalarProgramEndandScalarProgramEndSaved(32 lanes). Each one runs all four SMEM opsand
s_round_mode, then storesin + 1and hits one of the two end variants. Two never-taken branches put ablock right after the end that would overwrite the result, and another one past it; both must stay unwritten.
main(decode throws). They pass on Linux with RADV and lavapipe.s_nopfails ("store before the end is 0x00000bad"). Removingthe
s_atc_probeors_dcache_discard_x2decode, or thes_round_modetranslation, fails at recompile.ctest: 127/127.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-03T07:02:10Z.
Progress report (
ebf29f8→36c2fa4)📈 GPU shader instructions: 87.56% (+0.25%, +3 implemented instructions)
✅ 3 implemented
S_ATC_PROBES_ATC_PROBE_BUFFERS_ROUND_MODEImported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-04T05:44:44Z.
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_modebecomes 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 translates_round_mode 0as a no-op and throw for any other immediate? Then the TechnicalDebt line isn't needed.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-04T06:30:32Z.
Thanks for checking the encodings. Done, rebased onto main:
s_round_mode 0is a no-op and any other immediate throws, so the TechnicalDebt line is gone.s_round_mode 3(it is nows_nop 0, same word count), andScalarProgramEndchecks thats_round_mode 3is refused. That check fails if the guard is removed.Both pass on RADV and lavapipe.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-04T22:38:02Z.
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 andScalarProgramEndchecking thats_round_mode 3is refused, the guard is covered.agc_driver_scalar_program_endandagc_driver_scalar_program_end_savedpass 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 tos_round_mode(0x24) inRdnaScalarOpDecoder.cppandScalarInstructions.cpp, so whichever of the two lands second needs a one-line rebase. Otherwise ready to merge from my side.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-05T01:18:07Z.
#264 is on main now, so this needs the small rebase I mentioned:
s_denorm_mode(0x25) sits right next tos_round_mode(0x24) inRdnaScalarOpDecoder.cpp(the opcode table and the SOPP list) and inScalarInstructions.cpp, and keeping both sides in all three spots works. Ready to merge from my side after that.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-05T01:35:32Z.
Rebased on current main as you described:
s_round_mode(0x24) and #264'ss_denorm_mode(0x25) both kept in the SOPP opcode table, the SOPP wait list andScalarInstructions.cpp. Both commits otherwise unchanged;agc_driver_scalar_program_end{,_saved}and the full ctest pass on RADV (only the knownagc_driver_pixel_helper_lanes).Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-05T02:47:02Z.
Thanks, the rebase is right:
s_round_mode(0x24) ands_denorm_mode(0x25) are both in the SOPP table and the wait list, and inScalarInstructions.cpps_round_modestill accepts only round to nearest even whiles_denorm_modekeeps main's throw. Both commits are otherwise unchanged.agc_driver_scalar_program_endandagc_driver_scalar_program_end_savedpass here on the merged branch, and PPSA21564 has none of these instructions. Ready to merge from my side.