Skip to content

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

Closed
Sam-mon7 wants to merge 1 commit into
boykopovar:mainfrom
Sam-mon7:feat/agc-device-fault-report
Closed

Sam-mon7 wants to merge 1 commit into
boykopovar:mainfrom
Sam-mon7:feat/agc-device-fault-report

Conversation

@Sam-mon7

Copy link
Copy Markdown
Contributor

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 a0f5916.

  • 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 Demon's Souls (PPSA01341) #1283)
  • GPUs tested: NVIDIA GeForce RTX 4070, driver 596.21, Windows 11 Pro 26200
  • AI-assisted: yes

🤖 Generated with Claude Code

Enable VK_EXT_device_fault when the device supports its deviceFault
feature (APS5_NO_DEVICE_FAULT=1 leaves it off). When a recorder or
command batch submission or wait returns VK_ERROR_DEVICE_LOST, query
vkGetDeviceFaultInfoEXT once per device and write the description and
the faulting GPU addresses to stderr before the error is thrown.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

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

@Sam-mon7

Copy link
Copy Markdown
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant