fix(agc): read indirect register lists when the command buffer is submitted #1100
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1100"
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 gookie-dev on 2026-10-07T11:10:33Z.
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+ #1020 (needed to load) + #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 #1038 fixes. With #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
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T06:45:07Z.
Checked on Linux (RADV): build,
libsand full ctest green, andagc_driver_pm4fails when the non-test changes are reverted. The packet-offset keying ofregisterListsmatchesDriver::execute, and the rewind tail reads its lists too. Rebased onto currentmain(only conflict: theTechnicalDebt.mdline next to the COND_INDIRECT_BUFFER one, both kept); rebuilt and ctest green (419/419). Merging once CI is green on the rebased head.