fix(agc): accept four GCN packet forms in a PS4 title's command buffers #20127
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/20127"
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 adam25136 on 2026-11-14T17:10:20Z.
What
In a PS4 title (
ShaderRecompiler::GcnGuestShaders(), the gate thatDATA_SEL 4inRELEASE_MEMalready uses), AGC's packet check (Pm4::Validate) accepts four GCN packet forms:0x6875xxxx), whose payload GNM already sets to 0 at the top level. A flip reservation still throws: a 64-dword marker NOP (the size of GNM's reservation), or the markers0x68750777and0x68750778;RELEASE_MEM.Execute,ReleaseMemValueandDecodeLabelWriteread dwords 0 to 6, andEopReleasetakes only eight-dword releases. Two cases throw in the check: an interrupt (INT_SELother than 0 or 3, the valuesreleaseInterrupttreats as none), since the GCN form has no interrupt context dword; and dword 1 bits beyond the event type and index (0xf3f, what GNM keeps when it lowersEVENT_WRITE_EOP), so no GCN cache bit is read with the PS5 layout;ACQUIRE_MEMcontrol word, gfx7'sTC_VOL_ACTION_ENA(gfx_7_2_sh_mask.h,CP_COHER_CNTL__TC_VOL_ACTION_ENA_MASK 0x10000). AGC reads that word only in this check (and inUsesGpuCacheBarrier, which only tests call), so the bit changes nothing it does.GNM rewrites only the top-level packets of a PS4 submission (
Lower()inlibSceGnmDriver/Export.cpp). AGC copies the buffers that anINDIRECT_BUFFERcalls when the submission arrives (copySegmentinDriver/Queues/Submission.cpp), and its check is the one that meets them. PS5 titles are unchanged. DealPotato reported these forms in Second Son (CUSA00004) on 2026-10-18, with a local workaround in GNM.inFAMOUS Second Son (CUSA00223) meets all four in a 324-dword buffer that its compute queue ring calls: DWORD 263 (
c0041000 68754000 00000000 00000000 00000000 00000000), DWORD 269 (c0054902 0000062f 23000000 4be84430 00000002 00000001 00000000, header bit 1) and DWORD 303 (c0055800 00c58000 00000000 00000000 00000000 00000000 0000000a). Without this change, local runs on 2026-11-11, each with local compute-queue code and the earlier forms accepted by local edits, stopped at each of the three in turn. Withmainc7102526b5, #18546 and this commit (f7885117b6, the same changed lines as the head) merged locally, plus four uncommitted local changes for earlier stops (in the relinker, libSceSysmodule, libSceDiscMap and libSceVideoOut; none in AGC or GNM), 3 of 3 starts log no rejected submission. Their failure reports list that buffer and a second compute submission of 68 dwords with the same forms, and each start stops later, in the shader recompiler:GCN MTBUF opcode 3 at program counter 8 is not implemented.testGcnCalledBufferPacketFormsintests/Pm4.cppchecks that each form is refused without a PS4 title and accepted with one, and that the cases above still throw. It also submits a called buffer with packets in the three inFAMOUS forms on queue 0x20 and checks the release's write. The debt entry "PS4 command buffers that an INDIRECT_BUFFER calls" lists what still throws in such buffers.Overlap:
tools/pr_overlap.py --branch(in a full clone, this head merged ontomain87d51b0307): 141 of 1,529 open pull requests share a file with this branch. Of the 80 it could compare, only #18956 (mjnhbg3) shares lines: it adds checks under theRELEASE_MEMsize line that this change replaces, so whichever merges second needs a rebase there. It could not compare 61 that conflict withmain. In GitHub's patches of these, 54 share only the debt file, with no edit next to this entry. Of the 7 that changePm4.cppor its test, only #18914 (atinseau) changes the same checks. From reading its patch (not run): its new fast path refuses the marker NOP before the general check, so with both merged the PS4 gate has to go there too, or this test's first accept in a PS4 title fails. None of the open pull requests that share a file, nor #6977 (a draft) or #18546, accepts these forms.Tested
Windows 10 Pro 22H2 (19045), i9-12900KF, NVIDIA GeForce RTX 5080 (
10de:2c02, driver 621.14), WinLibs GCC 15.2.0 r7, Release,BUILD_TESTING=ON,ANYPS5_ENABLE_SPIRV_TOOLS=OFFunless stated. Head2ff14e29d3onmainf1822f7a84, rebased from2ab6987cc4onbacd553166with the same changed lines; on it,agc_driver_pm4passes 3 of 3 runs and all 29agc_driver_pm4*tests pass. The results below are from2ab6987cc4, except the selected tests, the validation runs and the layer check, which ran onfae9636a97(it differs only in one error message, the test's copy of it and the debt entry's wording) merged ontomain3e63c9f68f.agc_driver_pm4passes in 3 of 3 runs, and all 29agc_driver_pm4*tests pass. The 29 also pass in one run in a build withANYPS5_ENABLE_SPIRV_TOOLS=ON(as the Linux CI job builds).Pm4.cppfrommain(the test kept),agc_driver_pm4fails withtyped user-data and legacy flip markers are not implemented. With each part of the change reverted on its own (restored afterwards):typed user-data and legacy flip markers are not implementedexpected PM4 rejection(a flip marker is accepted)expected PM4 rejection(a 64-dword marker NOP is accepted)PM4 header flags 0x2 are not implementedRELEASE_MEMinvalid packet sizeexpected PM4 rejection(bit 17 of dword 1 is accepted)expected PM4 rejection(INT_SEL1 is accepted)ACQUIRE_MEMbit 16unsupported ACQUIRE_MEM control flagstools/select_tests.pypicks 2,876 tests for the changed files. Withfae9636a97merged ontomain(select_tests.py ctest build --parallel 4 --timeout 120,ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1), 2,857 pass and 19 do not run, the same 19 that do not run inmain's full suite on this machine (5,562 tests). One of them,agc_driver_upload_cache_read_only_flush, has a test program that does not build on Windows (setenv, open #19899); both sides were built with ninja's-k 0, and it was the only target that failed.main's full suite also failedagc_driver_dumped_constant_captureonce; it then passed 5 of 5 runs on thatmainand 5 of 5 withfae9636a97merged.^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu, 1,732 of the selection and 1,824 inmain's run, throughctest -V --parallel 4withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(1.4.367) andVK_LOADER_LAYERS_DISABLE=~implicit~: all pass, and both logs have the same 61 messages in the same 14 tests, with no newVUID-ID and no "was not found but was requested by env var VK_INSTANCE_LAYERS" line. WithVK_LOADER_DEBUG=layeradded, on thatmainand withfae9636a97merged:agc_driver_alpha_to_coverageshows the loader inserting the layer on both sides, and the 29agc_driver_pm4*tests pass on both sides with no loader line, since they do not open Vulkan.python tools/check_conventions.py --base origin/mainwith this title and description: "All conventions checks passed."Not covered: AMD and Intel GPUs, Linux, a PS5 or PS4.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)10de:2c02), driver 621.14, Windows 10 Pro 22H2🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T17:31:38Z.
Review: COMMENTED
Reviewed — no blocking findings
The changed code and all three changed files were read at head
2ff14e29d3731ee1c69e7cdf578e4cfd6b75cad5; no checks were run during this review, so I cannot recommend a formal approval.What I ran
No commands or tests were run. I read
description.md,commits.md,manifest.json,diff.patch, and the changed lines in all three changed files throughrepo_read.py. The author reports tests and validation in the PR description; those results were not rerun here.Results
Negative control
Could not run a negative control because no tests were run during this review.
Findings
Blocking
None identified in the code read.
Non-blocking
None.
Sources
Not verified
I did not rerun the reported test suite, validation runs, conventions check, or title launches. The report describes author-run tests, including GPU and operating-system limits; these were not independently verified. The changed files were
core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp,core/libs/prx/libSceAgcDriver/tests/Pm4.cpp, anddocs/dev/debt/libSceAgcDriver.md; no changed files were excluded from the prepared review artifacts.To get this to a good state
Nothing is required. The PR description reports extensive test and validation results, but they were not rerun in this review.