fix(agc): dump a failing shader capture's own request #6856
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6856"
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 milescoviello on 2026-10-16T14:19:47Z.
What
With
APS5_DUMP_SHADERS=1, a dispatch or draw stage whose capture or recompile fails names a request file in its error. Crimson Desert, for example, stops withcompute shader 0x2154440100 (shader_2154440100.req): SrtWalker::EvaluateRuntimeSources failed to evaluate runtime sources: descriptor source 2 dword 0: ....That file is not the failing call's request.
shader_<address>.reqis written once per shader address, by the first dispatch or draw that captures the shader. So when a later call of the same shader fails, the file holds an earlier call's user data and memory. When the capture itself throws, the failing capture's memory was never part of the dumped request at all. Replaying Crimson Desert's file withagc_shader_replaygivesrecompiled: 116609 SPIR-V words, so the stop cannot be reproduced from it.A failure now writes
shader_<address>_failed.req, once per address, and names it in the error. It holds the failing call's request together with the memory its capture read (ShaderMemory::Regions(); for a draw stage that fails after its capture, the request's own memory). The dump of a successful capture is unchanged. Registration failures (PrepareShaderWithDiagnostics) are written asshader_<address>.prepare.reqsincemain's1db31b9c9e, and this PR leaves them alone. It uses that change's name suffix for its own dumps (_failed).Tested
Ubuntu 24.04, GCC 13.3, RTX 4070 Ti (NVIDIA 595.99).
agc_driver_failed_capture_dump: a compute shader loads its V# through a user-data pointer and stores through it. The first dispatch goes through a valid V#. The second goes through a pointer to a type 2 V# and fails withbuffer descriptor uses an unsupported type. The error must nameshader_<address>_failed.req; that file must hold the second dispatch's user data and replay to the same refusal, whileshader_<address>.reqholds the first dispatch's user data and replays cleanly. Withmain's four sources the test fails 3 of 3, for example withcompute shader 0x59360d7c4400 (shader_59360d7c4400.req): buffer descriptor uses an unsupported type (...). With the change it passes 3 of 3.^agc_driver_|^agc_vertex_barrier|recompiler|shader_cache|request_serializer|spirv|^agc_shader|bda|journal|preparedpass exceptagc_driver_graphics(#6792, fixed by #6789) andagc_driver_store_over_untracked(#6385), which fail onmaintoo.std::random_devicevalue to the folder name. With it, the test passes 3 of 3 alone and 12 of 12 in each of two rounds of 12 at once. @Dextroid17 reran their setup on 8eb318073 (Release, GCC 16.2.1, lavapipe): 72 of 72 pass, against 6 of 72 before (comment).@LeandroLP23 ran it on Windows 11 with an AMD Radeon 860M (RDNA 3.5, driver 32.0.13058.8001) (comment), in one build of
main6efb7261bwith this PR and six other pull requests:agc_driver_failed_capture_dump,agc_driver_graphicsandagc_driver_store_over_untrackedpass 3 runs of 3.Not checked: macOS, Intel.
main0c25997a5a(79874b9c6d), onto 1db31b9c9e's suffix-baseddumpRequest. The 595 tests matching the regex above pass, exceptagc_driver_bda_device, which fails onmainhere too (#7571).VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest -R '^agc_' -Vonmaine2a2914aa1and onmain+ this PR (79874b9c6d, a local merge).main: 815 of 815 pass; with this PR: 816 of 816 pass. Neither log reports the layer missing. VUIDs onmain:VUID-VkImageViewCreateInfo-usage-02275×6,VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605×18,VUID-vkCmdCopyBuffer-srcBuffer-00118×2,VUID-vkCmdDraw-multisampledRenderToSingleSampled-07285×2,VUID-vkCmdWaitEvents-srcStageMask-01158×2,VUID-vkSetEvent-event-09543×2; with this PR:VUID-VkImageViewCreateInfo-usage-02275×6,VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605×18,VUID-vkCmdCopyBuffer-srcBuffer-00118×2,VUID-vkCmdDraw-multisampledRenderToSingleSampled-07285×2,VUID-vkCmdWaitEvents-srcStageMask-01158×2,VUID-vkSetEvent-event-09543×2. None is new with this PR.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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-16T14:40:10Z.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCapture.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCapture.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCapture.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCapture.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCapture.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCapture.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCapture.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCapture.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCapture.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtImported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-17T13:28:32Z.
Rebased onto
mainaf1e3ae904(bb24f2e504). The only conflict was inlibSceAgcDriver/CMakeLists.txt, wheremain(#6641) added theagc_driver_shutdown_threads_testsinclude line next to this PR'sagc_driver_failed_capture_dump_testsline. I kept both. No other change.On Ubuntu 24.04 (GCC 13.3, Release, RTX 4070 Ti),
agc_driver_failed_capture_dumppasses 3 of 3, andctest -R '^agc_driver_'passes 498 of 498.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-17T14:32:31Z.
I ran the new test binary directly (not through
ctest), 12 copies at once. It passes when it runs alone, but most copies fail when they run together, because every copy uses the same working folder. A normalctestrun starts this test only once, so this is a small issue (scope below).Setup: head
bb24f2e50(merge-base withmainaf1e3ae90),BUILD_TESTING=ON,CMAKE_BUILD_TYPE=Release, Ninja, CachyOS (kernel 7.2.9), i9-11900K, GCC 16.2.1, lavapipe. I startedagc_driver_failed_capture_dump_testsunderenv -i(onlyHOME,PATH, the lavapipe ICD and itsLD_LIBRARY_PATH), and gave each run its own emptyANYPS5_SHADER_CACHE_DIR,MESA_SHADER_CACHE_DIRandXDG_CACHE_HOME./tmp: 66 of 72 fail. 65 of them end withAGC graphics: shader request shader_<address>.req was not written, and 1 withfilesystem error: cannot set current path: No such file or directory. The other 6 pass.TMPDIR: 36 of 36 pass./tmp, withgetpid()added to the folder name (a local edit, not pushed): 72 of 72 pass.Cause:
main()intests/execution/FailedCaptureDump.cpp(line 117) uses the fixed pathtemp_directory_path() / "agc_failed_capture_dump". Each copy runsremove_allandcreate_directorieson that path at the start, moves into it, and runsremove_allon it again at the end. When copies overlap, one deletes the folder another is writing its captures into. In the 65 runs theRead()at line 105 finds no.reqfile. The one other run fitscurrent_pathat line 125 finding the folder already gone, but I inferred that from the message. With their ownTMPDIR, or withgetpid()in the folder name, the copies do not fail.If you want to change it, a unique folder name works. Other tests already do this:
tests/execution/PipelineJournal.cpp:402,tests/Graphics.cpp:7712andtests/Recorder.cpp:7432addstd::random_device{}()(from<random>, which this file does not include yet), andtests/Pm4.cpp:1268addsgetpid(). I tested thegetpid()version on Linux only. It would need a Windows branch, like the onePm4.cpphas at line 1262, because this test also builds on Windows.std::random_deviceworks on both.Scope:
ctestregisters and starts this test once per run, so a normalctest -jrun will not hit this. It shows up only when two or more copies of this test run at the same time with the same temp folder, for example two build directories tested at once, or two jobs on one shared runner. So it is a small fix, not a blocker.Not checked: Windows, macOS, a real GPU, PS5 hardware, and a retail title. I did not review the capture and replay code itself. These runs only cover the test's working folder.
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-17T14:34:46Z.
Thanks @Dextroid17, that's right. 8eb3180735 names the folder
agc_failed_capture_dump-<std::random_device value>, asPipelineJournal.cppdoes, so it also works on Windows. Run alone, it passes 3 of 3. With 12 copies started at once and sharing/tmp, which is your failing case, 12 of 12 passed in each of two rounds (Ubuntu 24.04, GCC 13.3, Release, RTX 4070 Ti).AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-17T20:35:09Z.
Thanks @milescoviello,
8eb318073fixes it here too. I used the same script and setup as my earlier run (Release, GCC 16.2.1, lavapipe,env -i, separate empty shader caches). With 12 copies started at once sharing/tmp, all 72 of 72 runs now pass. Onbb24f2e50, only 6 of 72 passed. So the failure I reported no longer reproduces on Linux with lavapipe. I did not run the Windows build.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-18T17:10:46Z.
AMD on Windows run. Radeon 860M (RDNA 3.5, driver 32.0.13058.8001), Windows 11 26300, WinLibs GCC 15.2.0 r7, Release,
BUILD_TESTING=ON. Build:main6efb7261bwith #7524, #7006, #6612, #6929, #7119, #6896 and #6856 merged together (each merge clean, built once).agc_driver_failed_capture_dump,agc_driver_graphicsandagc_driver_store_over_untrackedpass 3 runs of 3.agc_shader_replayis not a ctest name in this build, so I did not run a replay.AI-assisted
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-18T18:46:05Z.
Thanks @LeandroLP23 for the AMD run on Windows. I added it to the description.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-19T01:34:37Z.
Rebased onto
main0c25997a5a(79874b9c6d). In the meantimemaintook1db31b9c9e, which names preparation-failure dumpsshader_<address>.prepare.reqand givesdumpRequesta name suffix, with de-duplication by file name. This PR now uses that API: a failing dispatch or draw capture is dumped with the suffix_failed, so the file is stillshader_<address>_failed.req, and its ownfailedflag and pair-keyed set are gone. The rest is unchanged: the failing call's request together with the memory its capture read, and the newagc_driver_failed_capture_dumptest. The 595 tests matching^agc_driver_|^agc_vertex_barrier|recompiler|shader_cache|request_serializer|spirv|^agc_shader|bda|journal|preparedpass, exceptagc_driver_bda_device, which fails onmainhere too (#7571).AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-20T09:16:02Z.
Re-checked against current main: it merges cleanly, the
_faileddump paths inDispatch.cppandDrawCapture.cppstill usedumpRequestwith the same signature, and the new test still pins both calls' user data and the replayed refusal; merged.