feat(agc): report VK_EXT_device_fault details on device loss #5460

Closed
Sam-mon7 wants to merge 1 commit from upstream-pr/5460 into main
Sam-mon7 commented 2026-10-13 20:14:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Sam-mon7 on 2026-10-13T20:14:50Z.


What

When the Vulkan device is lost, AnyPS5 currently prints only the failing call and Vulkan result -4. Nothing says what the GPU was doing or which address faulted, and the driver's own record of the fault is gone once the process exits.

This enables VK_EXT_device_fault when the device supports its deviceFault feature. When a recorder or command batch submission or wait returns VK_ERROR_DEVICE_LOST, vkGetDeviceFaultInfoEXT is queried once per device. The driver's description and the faulting GPU addresses, with their access type and precision, go to stderr before the unchanged error is thrown:

[gpu-fault] device lost at vkQueueSubmit recorder; no driver description; addresses 1/1, vendor entries 0/0
[gpu-fault] address write-invalid 0x7f3660000, precision 0x1000
  • Context::CheckResult reports, then calls Check as before. It replaces Check at the six recorder sites (vkQueueSubmit recorder, vkWaitSemaphoresKHR recorder x3, vkWaitForFences recorder, vkDeviceWaitIdle after recorder fence failure) and the two CommandBatch sites (vkQueueSubmit graphics, vkWaitForFences graphics).
  • A healthy device is never queried. A device without the feature, or with APS5_NO_DEVICE_FAULT=1, behaves exactly as before.
  • Address and vendor entries are bounded to 256 each. The vendor binary dump is not requested. Query failures and exceptions are reported and contained, so the original device-loss error is always the one thrown.
  • Documented in docs/user/USAGE.md (GPU fault reports). The limits are in the libSceAgcDriver debt file: the presentation path is not covered, and a device reports only once.

Tested

Windows 11 Pro 26200, MinGW-w64 GCC 15.2.0 (WinLibs UCRT r7), Release, on main a0f5916a2.

  • New agc_driver_device_fault (CPU, mock vkGetDeviceFaultInfoEXT): passed. It covers:
    • only VK_ERROR_DEVICE_LOST queries, and a second loss is not reported again;
    • two-call protocol, with counts bounded to 256 and null pointers for empty arrays;
    • incomplete, empty and description-less reports;
    • count and data query failures, and a throwing query;
    • Context::CheckResult still throws the original Vulkan result -4, with or without a reporter.
  • agc_driver and agc_driver_graphics (RTX 4070), which submit and wait through the changed recorder and command batch paths: passed.
  • On the RTX 4070 both test devices log Vulkan device fault reporting enabled. With APS5_NO_DEVICE_FAULT=1 the line is absent and the extension is not enabled.
  • tools/check_conventions.py --base upstream/main with this description: passed.

Demon's Souls (PPSA01341 v1.07), RTX 4070 (driver 596.21), on a local branch that is not main: an earlier, opt-in version of this report (same query and output format, behind APS5_GPU_CHECKPOINTS) reported three natural device losses at character creation as write-invalid addresses with 4 KiB precision. Matched against a separate local binding history, each address was the last 64 KiB of a 2.25 MiB buffer that had already been freed: about 100 and 120 s earlier in the two runs that recorded the time. Before the report, the logs had only Vulkan result -4. The address is what narrowed the investigation to a GPU copy writing through a stale address. This PR alone does not move any title further. It makes a device loss diagnosable from a log.

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
  • Unblocks: none (diagnostics; device losses seen in PPSA01341 #1283)
  • GPUs tested: NVIDIA GeForce RTX 4070, driver 596.21, Windows 11 Pro 26200
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4848911377 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5460). Originally posted by [Sam-mon7](https://github.com/Sam-mon7) on 2026-10-13T20:14:50Z. --- ### What When the Vulkan device is lost, AnyPS5 currently prints only the failing call and `Vulkan result -4`. Nothing says what the GPU was doing or which address faulted, and the driver's own record of the fault is gone once the process exits. This enables `VK_EXT_device_fault` when the device supports its `deviceFault` feature. When a recorder or command batch submission or wait returns `VK_ERROR_DEVICE_LOST`, `vkGetDeviceFaultInfoEXT` is queried once per device. The driver's description and the faulting GPU addresses, with their access type and precision, go to stderr before the unchanged error is thrown: ``` [gpu-fault] device lost at vkQueueSubmit recorder; no driver description; addresses 1/1, vendor entries 0/0 [gpu-fault] address write-invalid 0x7f3660000, precision 0x1000 ``` - `Context::CheckResult` reports, then calls `Check` as before. It replaces `Check` at the six recorder sites (`vkQueueSubmit recorder`, `vkWaitSemaphoresKHR recorder` x3, `vkWaitForFences recorder`, `vkDeviceWaitIdle after recorder fence failure`) and the two `CommandBatch` sites (`vkQueueSubmit graphics`, `vkWaitForFences graphics`). - A healthy device is never queried. A device without the feature, or with `APS5_NO_DEVICE_FAULT=1`, behaves exactly as before. - Address and vendor entries are bounded to 256 each. The vendor binary dump is not requested. Query failures and exceptions are reported and contained, so the original device-loss error is always the one thrown. - Documented in `docs/user/USAGE.md` (GPU fault reports). The limits are in the libSceAgcDriver debt file: the presentation path is not covered, and a device reports only once. ### Tested Windows 11 Pro 26200, MinGW-w64 GCC 15.2.0 (WinLibs UCRT r7), Release, on `main` a0f5916a2. - New `agc_driver_device_fault` (CPU, mock `vkGetDeviceFaultInfoEXT`): passed. It covers: - only `VK_ERROR_DEVICE_LOST` queries, and a second loss is not reported again; - two-call protocol, with counts bounded to 256 and null pointers for empty arrays; - incomplete, empty and description-less reports; - count and data query failures, and a throwing query; - `Context::CheckResult` still throws the original `Vulkan result -4`, with or without a reporter. - `agc_driver` and `agc_driver_graphics` (RTX 4070), which submit and wait through the changed recorder and command batch paths: passed. - On the RTX 4070 both test devices log `Vulkan device fault reporting enabled`. With `APS5_NO_DEVICE_FAULT=1` the line is absent and the extension is not enabled. - `tools/check_conventions.py --base upstream/main` with this description: passed. Demon's Souls (PPSA01341 v1.07), RTX 4070 (driver 596.21), on a local branch that is not `main`: an earlier, opt-in version of this report (same query and output format, behind `APS5_GPU_CHECKPOINTS`) reported three natural device losses at character creation as `write-invalid` addresses with 4 KiB precision. Matched against a separate local binding history, each address was the last 64 KiB of a 2.25 MiB buffer that had already been freed: about 100 and 120 s earlier in the two runs that recorded the time. Before the report, the logs had only `Vulkan result -4`. The address is what narrowed the investigation to a GPU copy writing through a stale address. This PR alone does not move any title further. It makes a device loss diagnosable from a log. ### 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 - [x] Unblocks: none (diagnostics; device losses seen in PPSA01341 #1283) - [x] GPUs tested: NVIDIA GeForce RTX 4070, driver 596.21, Windows 11 Pro 26200 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-13 20:32:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T20:32:20Z.


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
#4795 core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp L178
#5309 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp L1633, L3123-3124
#5324 docs/user/USAGE.md L160
#5390 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp L1633, L3123-3124
#5408 core/libs/prx/libSceAgcDriver/CMakeLists.txt L347
#5431 core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp L3182-3191
#5453 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp L1633
core/libs/prx/libSceAgcDriver/tests/DeviceFault.cpp
core/libs/prx/libSceAgcDriver/tests/DeviceFault.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6154624432 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5460#issuecomment-6154624432). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-13T20:32:20Z. --- <!-- 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 | |---|---|---|---| | #4795 | `core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp` [L178](https://github.com/boykopovar/AnyPS5/blob/0aa4cb1c2f2f8936f3985f905697b0070f1f7305/core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp#L178) | | | | #5309 | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` [L1633](https://github.com/boykopovar/AnyPS5/blob/0aa4cb1c2f2f8936f3985f905697b0070f1f7305/core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp#L1633), [L3123-3124](https://github.com/boykopovar/AnyPS5/blob/0aa4cb1c2f2f8936f3985f905697b0070f1f7305/core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp#L3123-L3124) | | | | #5324 | `docs/user/USAGE.md` [L160](https://github.com/boykopovar/AnyPS5/blob/0aa4cb1c2f2f8936f3985f905697b0070f1f7305/docs/user/USAGE.md#L160) | | | | #5390 | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` [L1633](https://github.com/boykopovar/AnyPS5/blob/0aa4cb1c2f2f8936f3985f905697b0070f1f7305/core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp#L1633), [L3123-3124](https://github.com/boykopovar/AnyPS5/blob/0aa4cb1c2f2f8936f3985f905697b0070f1f7305/core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp#L3123-L3124) | | | | #5408 | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` [L347](https://github.com/boykopovar/AnyPS5/blob/0aa4cb1c2f2f8936f3985f905697b0070f1f7305/core/libs/prx/libSceAgcDriver/CMakeLists.txt#L347) | | | | #5431 | `core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp` [L3182-3191](https://github.com/boykopovar/AnyPS5/blob/0aa4cb1c2f2f8936f3985f905697b0070f1f7305/core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp#L3182-L3191) | | | | #5453 | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` [L1633](https://github.com/boykopovar/AnyPS5/blob/0aa4cb1c2f2f8936f3985f905697b0070f1f7305/core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp#L1633)<br>`core/libs/prx/libSceAgcDriver/tests/DeviceFault.cpp` | | `core/libs/prx/libSceAgcDriver/tests/DeviceFault.cpp` |
Sam-mon7 commented 2026-10-13 20:39:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Sam-mon7 on 2026-10-13T20:39:46Z.


Closing in favour of #5453, which was opened first, covers more call sites (the global Check, the present path, and NVIDIA checkpoints) and implements the same report. I'll test #5453 on Windows with an RTX 4070 and post the results there, along with what this report showed on real device losses in PPSA01341.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6154753315 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5460#issuecomment-6154753315). Originally posted by [Sam-mon7](https://github.com/Sam-mon7) on 2026-10-13T20:39:46Z. --- Closing in favour of #5453, which was opened first, covers more call sites (the global `Check`, the present path, and NVIDIA checkpoints) and implements the same report. I'll test #5453 on Windows with an RTX 4070 and post the results there, along with what this report showed on real device losses in PPSA01341. AI-assisted: yes

Pull request closed

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!5460
No description provided.