feat(shader): decode halt, trap return, code end, GWS and ordered count instructions #1253
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1253"
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 popcoder565 on 2026-10-07T19:55:14Z.
What
Decodes the 11 instructions from
tools/rdna_isa.txtthat the decoder did not recognize and that no open pull request covers. Shader instructions: 1139/1166 -> 1150/1166. The other 16 are in #697, #895, #1198, #1217, #1049 and #1053.s_sethalt(SOPP 0x0d): with SIMM16[0] clear it is a no-op; with it set it throws at translation, as the wave would halt until a debugger resumes it.s_sendmsghalt(SOPP 0x11) ands_rfe_b64(SOP1 0x22) throw at translation: the first halts the wave, the second returns from a trap handler, which recompiled shaders do not run in.s_code_end(SOPP 0x1f) throws if it is reached. Linear decoding stops at it like ats_endpgmwhen no branch targets past it, so a program whose last instruction is a backward branch followed bys_code_endpadding decodes; it failed withunsupported SOPP opcode 31before.ds_gws_init,ds_gws_sema_v,ds_gws_sema_br,ds_gws_sema_p,ds_gws_sema_release_all,ds_gws_barrier(DS 0x19, 0x1a, 0x1b, 0x1c, 0x18, 0x1d) andds_ordered_count(DS 0x3f) decode with their operands (the GWS data VGPR is in the ADDR field, no VGPR destination) and throw at translation: GWS barriers and semaphores shared by waves of different workgroups, and GDS counters updated in wave launch order, are not modeled.Sources:
llvm/lib/Target/AMDGPU/SOPInstructions.tdandllvm/lib/Target/AMDGPU/DSInstructions.td(has_gws_data0: "data0 is encoded as addr"), checked againstllvm/test/MC/AMDGPU/gfx10_asm_sop.sandllvm/test/MC/AMDGPU/gfx10_asm_ds.s.s_code_endas end-of-code padding:AMDGPUTargetAsmStreamer::EmitCodeEndinllvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp.int_amdgcn_ds_gws_initandint_amdgcn_ds_gws_barrierinllvm/include/llvm/IR/IntrinsicsAMDGPU.td.s_sethalt: RDNA 2 ISA guide, SOPP opcode table (SIMM16[0] = 1 halts the wave, 0 resumes it). The no-op for 0 is not measured on hardware and is recorded in TechnicalDebt.Tested
Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, NVIDIA GeForce RTX 3060 Laptop GPU.
agc_wave_control_decode: decodes every new opcode and checks its operands, checks the message each refused case throws, and recompiles a program padded withs_code_endafter its last branch.agc_driver_scalar_sethalt: runss_sethalt 0and ans_code_end-padded program on the GPU and checks the stored results.guest_system_font, which fails the same way onmainon Windows (#1172).No title or homebrew tested; not run on AMD hardware.
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-08T01:02:22Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/shader/recompiler/RdnaDecoder/include/RdnaDecoder/RdnaOpcode.hppL1044core/shader/recompiler/RdnaDecoder/src/RdnaScalarOpDecoder.cppL41core/shader/recompiler/RdnaDecoder/include/RdnaDecoder/RdnaOpcode.hppL1044Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-08T09:49:12Z.
Progress report (
3069680→2e0b7bb)📈 GPU shader instructions: 98.03% (+0.95%, +11 implemented instructions)
✅ 11 implemented
DS_GWS_BARRIERDS_GWS_INITDS_GWS_SEMA_BRDS_GWS_SEMA_PDS_GWS_SEMA_RELEASE_ALLDS_GWS_SEMA_VDS_ORDERED_COUNTS_RFE_B64S_CODE_ENDS_SENDMSGHALTS_SETHALTImported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T10:01:17Z.
Checked the decoder tables, the translation throws and both new tests against
main: the decode test doesn't compile without the change andagc_driver_scalar_sethaltneeds it to decode. Measureds_sethalt 0on the HW oracle (gfx1035): the wave continues and the next VALU op gives the normal result, so the no-op is right. Full ctest green after the rebase.Added on top of your branch (rebased onto current
main, two conflicts in theagcTestlist, resolved by keepingmain's list since your later commit registers the test separately):s_sethaltline now records the measurement instead of "not measured on hardware".Merging once CI is green on the rebased head (the first runs were waiting for approval).