fix(agc): name preparation-failure shader dumps apart from dispatch captures #6134

Merged
fdfawef324 merged 1 commit from upstream-pr/6134 into main 2026-10-18 21:26:43 +00:00
fdfawef324 commented 2026-10-14 23:02:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-14T23:02:24Z.


What

With APS5_DUMP_SHADERS set, a shader whose preparation fails is dumped by PrepareShaderWithDiagnostics under the same shader_<address>.req name that dispatch and draw captures use. The two kinds of file need different replays:

  • A preparation-failure request has no captured resources. The one written after registration (PrepareRegistered) also carries placeholder user data (all zero) and only the code and shader-header memory.
  • Replaying such a file as a dispatch capture (the default recompile path of agc_shader_replay, or --materialize from #5959) follows the zero user-data pointer into the SRT. The table-base read then misses the request memory and SrtWalker::EvaluateDescriptorSource throws, so the replay reports a walker failure that never happens in the game, where dispatch uses the real user data. --prepare succeeds on the same files.
  • Driver::dumpRequest de-duplicated by address. Once a preparation failure had been dumped, a later dispatch or draw dump of the same shader was dropped, so the request that would have shown the real capture was never written.

Changes:

  • Driver::dumpRequest takes an optional file-name suffix. PrepareShaderWithDiagnostics passes .prepare, so preparation failures are written as shader_<address>.prepare.req. Dispatch and draw dumps keep their shader_<address>.req name.
  • De-duplication is keyed by file name instead of by address, so the later dispatch dump of a shader is still written after its preparation dump.
  • The agc_shader_replay usage text says that a .prepare.req holds a request whose preparation failed before any resource capture, and that it should be replayed with --prepare.
  • FailureCapture in tests/execution/PreparedShaders.cpp expects the .prepare.req name and no plain .req from a preparation failure. It then dumps a dispatch request for the same address and requires shader_<address>.req to be written with the serialized request.

Known limit: a registration-time .prepare dump still suppresses a later at-use .prepare dump of the same address, which would carry real user data. Both replay only with --prepare, so this PR leaves it as is.

Tested

Windows Server 2025 (10.0.26100), NVIDIA GeForce RTX 3060 12 GB, driver 591.86, Vulkan 1.4.325. WinLibs MinGW-w64 GCC 15.2.0, Ninja, Release, BUILD_TESTING=ON. Built agc_driver_prepared_shaders_tests, libSceAgcDriver and agc_shader_replay. Based on main 6239ceffc.

ctest -R '^agc_driver_prepared_shaders' (9 variants; FailureCapture runs in agc_driver_prepared_shaders, _indirect, _uncached and _debug):

  • Red, with the new test and main's driver: those 4 variants fail with "enabled shader capture changed the diagnosed failure", because the failure names shader_12345cafe.req. The other 5 pass.
  • Red, with the new name but the old address-keyed de-duplication: the same 4 fail with "an earlier preparation failure dump suppressed the dispatch request dump".
  • Green, with this change: 9 of 9 pass, in 3 of 3 runs on main 80ccb9fb1 and again after rebasing onto 6239ceffc.
  • agc_shader_replay with no arguments prints the new usage text.

The bug was found while replaying a corpus of dumps from a title: every request that failed in SrtWalker was a registration-time preparation dump with zero user data and only code and header memory, and each one passed with --prepare. Those dumps are not attached or included.

Not tested: Linux, macOS, a title run with this change.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none. It complements #5959, whose --materialize replays dispatch captures; with this change a .prepare.req can be told apart and replayed with --prepare only. #5959 and #4048 change the same agc_shader_replay usage line, so whichever lands second rebases that one line.
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 3060 12 GB, driver 591.86 (32.0.15.9186), Vulkan 1.4.325, Windows Server 2025 10.0.26100
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4865728318 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6134). Originally posted by [fdfawef324](https://github.com/fdfawef324) on 2026-10-14T23:02:24Z. --- ### What With `APS5_DUMP_SHADERS` set, a shader whose preparation fails is dumped by `PrepareShaderWithDiagnostics` under the same `shader_<address>.req` name that dispatch and draw captures use. The two kinds of file need different replays: - A preparation-failure request has no captured resources. The one written after registration (`PrepareRegistered`) also carries placeholder user data (all zero) and only the code and shader-header memory. - Replaying such a file as a dispatch capture (the default recompile path of `agc_shader_replay`, or `--materialize` from #5959) follows the zero user-data pointer into the SRT. The table-base read then misses the request memory and `SrtWalker::EvaluateDescriptorSource` throws, so the replay reports a walker failure that never happens in the game, where dispatch uses the real user data. `--prepare` succeeds on the same files. - `Driver::dumpRequest` de-duplicated by address. Once a preparation failure had been dumped, a later dispatch or draw dump of the same shader was dropped, so the request that would have shown the real capture was never written. Changes: - `Driver::dumpRequest` takes an optional file-name suffix. `PrepareShaderWithDiagnostics` passes `.prepare`, so preparation failures are written as `shader_<address>.prepare.req`. Dispatch and draw dumps keep their `shader_<address>.req` name. - De-duplication is keyed by file name instead of by address, so the later dispatch dump of a shader is still written after its preparation dump. - The `agc_shader_replay` usage text says that a `.prepare.req` holds a request whose preparation failed before any resource capture, and that it should be replayed with `--prepare`. - `FailureCapture` in `tests/execution/PreparedShaders.cpp` expects the `.prepare.req` name and no plain `.req` from a preparation failure. It then dumps a dispatch request for the same address and requires `shader_<address>.req` to be written with the serialized request. Known limit: a registration-time `.prepare` dump still suppresses a later at-use `.prepare` dump of the same address, which would carry real user data. Both replay only with `--prepare`, so this PR leaves it as is. ### Tested Windows Server 2025 (10.0.26100), NVIDIA GeForce RTX 3060 12 GB, driver 591.86, Vulkan 1.4.325. WinLibs MinGW-w64 GCC 15.2.0, Ninja, Release, `BUILD_TESTING=ON`. Built `agc_driver_prepared_shaders_tests`, `libSceAgcDriver` and `agc_shader_replay`. Based on `main` 6239ceffc. `ctest -R '^agc_driver_prepared_shaders'` (9 variants; `FailureCapture` runs in `agc_driver_prepared_shaders`, `_indirect`, `_uncached` and `_debug`): - Red, with the new test and `main`'s driver: those 4 variants fail with "enabled shader capture changed the diagnosed failure", because the failure names `shader_12345cafe.req`. The other 5 pass. - Red, with the new name but the old address-keyed de-duplication: the same 4 fail with "an earlier preparation failure dump suppressed the dispatch request dump". - Green, with this change: 9 of 9 pass, in 3 of 3 runs on `main` 80ccb9fb1 and again after rebasing onto 6239ceffc. - `agc_shader_replay` with no arguments prints the new usage text. The bug was found while replaying a corpus of dumps from a title: every request that failed in `SrtWalker` was a registration-time preparation dump with zero user data and only code and header memory, and each one passed with `--prepare`. Those dumps are not attached or included. Not tested: Linux, macOS, a title run with this change. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none. It complements #5959, whose `--materialize` replays dispatch captures; with this change a `.prepare.req` can be told apart and replayed with `--prepare` only. #5959 and #4048 change the same `agc_shader_replay` usage line, so whichever lands second rebases that one line. - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce RTX 3060 12 GB, driver 591.86 (32.0.15.9186), Vulkan 1.4.325, Windows Server 2025 10.0.26100 - [x] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-15 11:31:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T11:31:30Z.


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.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 6454 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp L69-70
PR 6856 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp L70
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderDiagnostics.cpp L52, L54-56, L58

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.

Pull request Shared files not compared
PR 4650 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 5115 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
core/libs/prx/libSceAgcDriver/tests/execution/PreparedShaders.cpp
PR 5404 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 5609 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 5925 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 6188 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 6292 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderDiagnostics.cpp
PR 6501 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 6539 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 6615 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderDiagnostics.cpp
PR 6867 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
core/libs/prx/libSceAgcDriver/tests/execution/PreparedShaders.cpp
PR 6941 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 6946 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 6947 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 6963 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 6977 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
core/libs/prx/libSceAgcDriver/tools/ShaderReplay.cpp
PR 7332 3rdparty/SPIRV-Headers
3rdparty/SPIRV-Tools
PR 7642 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6191036028 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6134#issuecomment-6191036028). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-15T11:31:30Z. --- <!-- pr-overlap --> 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**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | [PR 6454](https://www.github.com/boykopovar/AnyPS5/pull/6454) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp` [L69-70](https://github.com/boykopovar/AnyPS5/blob/967f0b95c52322f4d81682c7d929d34741d8008d/core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp#L69-L70) | | | | [PR 6856](https://www.github.com/boykopovar/AnyPS5/pull/6856) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp` [L70](https://github.com/boykopovar/AnyPS5/blob/967f0b95c52322f4d81682c7d929d34741d8008d/core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp#L70)<br>`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderDiagnostics.cpp` [L52](https://github.com/boykopovar/AnyPS5/blob/967f0b95c52322f4d81682c7d929d34741d8008d/core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderDiagnostics.cpp#L52), [L54-56](https://github.com/boykopovar/AnyPS5/blob/967f0b95c52322f4d81682c7d929d34741d8008d/core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderDiagnostics.cpp#L54-L56), [L58](https://github.com/boykopovar/AnyPS5/blob/967f0b95c52322f4d81682c7d929d34741d8008d/core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderDiagnostics.cpp#L58) | | | 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. | Pull request | Shared files not compared | |---|---| | [PR 4650](https://www.github.com/boykopovar/AnyPS5/pull/4650) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp` | | [PR 5115](https://www.github.com/boykopovar/AnyPS5/pull/5115) | `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/execution/PreparedShaders.cpp` | | [PR 5404](https://www.github.com/boykopovar/AnyPS5/pull/5404) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp` | | [PR 5609](https://www.github.com/boykopovar/AnyPS5/pull/5609) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp` | | [PR 5925](https://www.github.com/boykopovar/AnyPS5/pull/5925) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp` | | [PR 6188](https://www.github.com/boykopovar/AnyPS5/pull/6188) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp`<br>`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp` | | [PR 6292](https://www.github.com/boykopovar/AnyPS5/pull/6292) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp`<br>`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderDiagnostics.cpp` | | [PR 6501](https://www.github.com/boykopovar/AnyPS5/pull/6501) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp` | | [PR 6539](https://www.github.com/boykopovar/AnyPS5/pull/6539) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp` | | [PR 6615](https://www.github.com/boykopovar/AnyPS5/pull/6615) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp`<br>`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderDiagnostics.cpp` | | [PR 6867](https://www.github.com/boykopovar/AnyPS5/pull/6867) | `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/execution/PreparedShaders.cpp` | | [PR 6941](https://www.github.com/boykopovar/AnyPS5/pull/6941) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp` | | [PR 6946](https://www.github.com/boykopovar/AnyPS5/pull/6946) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp`<br>`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp` | | [PR 6947](https://www.github.com/boykopovar/AnyPS5/pull/6947) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp`<br>`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp` | | [PR 6963](https://www.github.com/boykopovar/AnyPS5/pull/6963) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp` | | [PR 6977](https://www.github.com/boykopovar/AnyPS5/pull/6977) | `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp`<br>`core/libs/prx/libSceAgcDriver/tools/ShaderReplay.cpp` | | [PR 7332](https://www.github.com/boykopovar/AnyPS5/pull/7332) | `3rdparty/SPIRV-Headers`<br>`3rdparty/SPIRV-Tools` | | [PR 7642](https://www.github.com/boykopovar/AnyPS5/pull/7642) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp`<br>`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp` |
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!6134
No description provided.