Repository navigation
fix(agc): read indirect register lists when the command buffer is submitted - #1100
Merged
adriadam10 merged 1 commit intoOct 8, 2026
Conversation
This was referenced Oct 7, 2026
…mitted
The driver copies a submission's packets when it is submitted, but
SET_SH_REG_INDIRECT, SET_UCONFIG_REG_INDIRECT and SET_CONTEXT_REG_INDIRECT
read their (offset, value) lists from guest memory only when the queue
worker reaches the packet. A title that reuses its per-frame memory once
it expects the GPU to be done with it can rewrite a list in between, and
the worker then throws on the data it finds there ("extended register
semantics are not implemented (offset dword 0x3a888889)").
The lists are now read with the packets, after validation, in Submit and
for a rewind tail, and the worker writes the registers from that copy.
Pm4::Execute keeps reading the list itself for direct callers.
PPSA21402 (Balatro) keeps three frame slots and does not wait for the GPU
before reusing one: its slot labels start at 0xffffffff and the GPU only
ever writes 0xffffffff to them, so the poll before a slot is reused never
blocks. When the worker falls more than two frames behind, the title
writes per-draw constants over a SET_CONTEXT_REG_INDIRECT list the worker
has not read yet.
The console's PFP reads the list when it reaches the packet; the
difference is recorded in TechnicalDebt.md.
adriadam10
force-pushed
the
fix/agc-indirect-register-lists-at-submission
branch
from
October 8, 2026 06:45
0afd04f to
de651c6
Compare
Collaborator
|
Checked on Linux (RADV): build, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
SET_SH_REG_INDIRECT,SET_UCONFIG_REG_INDIRECTandSET_CONTEXT_REG_INDIRECTnow read their register list when the command buffer is submitted, together with the packets, instead of when the queue worker reaches the packet. The worker writes the registers from that copy.Pm4::Executestill reads the list itself for direct callers.The driver already copies a submission's packets at submit, so a title that reuses its command memory early does not break the worker. The register lists those packets point to were still read later from live guest memory. If the title rewrites a list in between, the worker throws on what it finds there:
This is the crash reported in #1034. To answer the question there about what the title waits on: PPSA21402 (Balatro) keeps three frame slots, and before it reuses a slot it busy-waits on that slot's label (
Balatro.elffile offset0x1014b8:while (*slot.label != slot.expected)). At startup it sets every label and every expected value to0xffffffff(0xff…bf28). The only other writer is each frame's last packet,RELEASE_MEMof the 64-bit value0xffffffffto0x280000000 + 0x20 * slot. Hardware watchpoints on the labels show no other CPU write, and no packet writes them. So the wait never blocks, on the console as well. The title's CPU side is held back only by submit blocking. When the queue worker falls behind (first use of the menu's pipelines), the title gets a frame slot ahead and writes per-draw constants over aSET_CONTEXT_REG_INDIRECTlist (85 pairs, first 72 bytes overwritten) that the worker has not read yet. The label is therefore not written early by the driver; the title has no effective fence.On the console the graphics PFP reads the list when it reaches the packet (PAL,
gfx9UniversalCmdBuffer.cpp: "The LOAD_CONTEXT_REG_INDEX packet does the load via PFP"). Reading it at submission differs from that for a list written after the submission, by the CPU or by GPU work ahead of the packet behindPFP_SYNC_ME. That case is recorded in TechnicalDebt.md.This fixes only the abort. Other per-frame data the title rewrites while the worker lags (its uniform constants) can still be read late, which is the flip queue depth question in #1034.
Tested
Pop!_OS 24.04 (kernel 7.1.5), GCC 13.3.0, CMake 3.28.3, Ninja, Release,
BUILD_TESTING=ON, SPIRV-Tools validation off, NVIDIA GeForce RTX 4050 Laptop GPU.libspackaging pass.ctest: 390 of 390 pass.agc_driver_pm4: a DCB waits on a CPU-written label, then runsSET_CONTEXT_REG_INDIRECTand aWRITE_DATA. After submitting, the test rewrites the list's offset to0x3a888889, then releases the label. With the worker reading the list at execution, the test fails withextended register semantics are not implemented (offset dword 0x3a888889). With this change it passes.main+ feat(libSceNgs2.native): implement sceNgs2ParseWaveformFile and parse 16-bit PCM waveforms #1020 (needed to load) + fix(guest-arena): place guest address space in the PS5 window on Linux #861 (without it the title segfaults in itslibc.prxallocator at startup here). Without this change it aborted with the error above about 8-10 s after start in every run (6 of 6). With it, the error did not occur in any of 10 runs. The next stop wasNGS2: waveform block 0 does not fit its data, which feat(libSceNgs2.native): stream 16-bit PCM waveforms through appended waveform blocks #1038 fixes. With feat(libSceNgs2.native): stream 16-bit PCM waveforms through appended waveform blocks #1038 added as well, 3 of 7 runs were still running after 120 s. The other 4 ended in a segfault inlibSceNgs2(in the core dump examined,Ngs2FindVoicecalled fromsceNgs2VoiceGetStatereads freed memory), which is unrelated to this change and left for another PR. No audio, input or gameplay claims.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)Refs #1034