feat(agc): report device losses with VK_EXT_device_fault and dispatch checkpoints #5453
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5453"
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 overlordxrz-source on 2026-10-13T20:07:39Z.
What
Port of @MichonGoddijn231849's
011e7c70from hisgta-v/testingbranch, with him as the commit author. He okayed this port in #1203: "mainhas no device-loss reporting yet. On NVIDIA the fault info mostly gives instruction pointers it can't map to a shader, so the checkpoints are the useful part: which dispatch or draw was last started and which had finished."VK_EXT_device_faultand itsdeviceFaultfeature, the driver enables the extension. The firstVK_ERROR_DEVICE_LOSTthatGraphics::Checkor the device's ownchecksees then prints the fault description, each faulting address with its kind and precision, and the vendor fault codes as[device-fault]lines. The vendor binary is not requested.APS5_GPU_CHECKPOINTS=1, on a device withVK_NV_device_diagnostic_checkpoints, records a checkpoint with the program address before each compute dispatch. The report then lists the last checkpoints the GPU reached, which names the dispatch that hung.Port notes against Michon's commit (the hunks no longer applied after #639):
VulkanDevice::State, sincerecordDispatchis a member now. The device-lost hook is astd::functionthat captures the device, the queue and the two entry points.~Stateclears it.check(present path) reports a loss too.Execution/include/DeviceFault.hppso it can be tested. It bounds unterminated driver descriptions and the counts the second query returns.APS5_GPU_CHECKPOINTSis documented indocs/dev/BUILD.md.Why: Michon used this to diagnose the GPU hang in GTA V's ray tracing modes (#1203, open issue A). A device loss on
maintoday only throwsVulkan result -4, with nothing about where it happened.New test
agc_device_fault(tests/DeviceFault.cpp) drives the report through mockvkGetDeviceFaultInfoEXTandvkGetQueueCheckpointDataNV. It covers:Tested
agc_device_faultpasses.VulkanDevice.cpp,Resources.cpp(throughContext.hpp) and the test compile for x86_64-linux-gnu and x86_64-windows-gnu. The test also links for x86_64-linux-gnu (not run, the host is aarch64).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)Imported from boykopovar/AnyPS5. Originally posted by Sam-mon7 on 2026-10-13T20:49:45Z.
Tested on Windows x86_64, which this PR hasn't run yet: Windows 11 Pro 26200, MinGW-w64 GCC 15.2.0 (WinLibs UCRT r7), Release, NVIDIA RTX 4070 (driver 596.21), head
ab478107f.The test doesn't link on Windows:
undefined reference to '__gxx_personality_v0'. Like the other agc test executables, it needs the project'slibcandlibkernel. On Windows it also needs libc's directory onPATH: with the link fixed but noPATH, the executable exits 127. With both changes it builds and passes:With that change,
agc_device_fault,agc_driverandagc_driver_graphicspass on the RTX 4070.What the fault info gives on real device losses. Demon's Souls (PPSA01341), RTX 4070, on a local branch (not
main) with a similarVK_EXT_device_faultreport: the same two-call query, no vendor binary. It covered three natural device losses at character creation. The report on this driver:The description was empty and no vendor entries came back. The address was a data write (
WRITE_INVALID) with 4 KiB precision, not an instruction pointer. Matched against a binding history, it was the last 64 KiB of a buffer that had been freed about two minutes earlier, which pointed at a GPU copy writing through a stale address. Aftermath decoded the same loss as a Copy Engine DMA page fault at that address. So on Ada, at least for this kind of fault, the fault info alone was enough to localize it, alongside what the checkpoints give.One design point:
DeviceLostHook()is one hook for the whole process. This title creates two devices, a windowless one first and then the windowed one that renders. The second overwrites the first's hook, so a loss on the first device would query the other device's fault info.~Stateof either device also clears the hook for both. Here the rendering device is created last, so its losses would be reported, but if the windowless device were destroyed first, the hook would be gone. Clearing the hook only when it still belongs to this device, or keeping one hook perVkDevice, would avoid both problems.I closed my #5460 (the same report, fewer call sites) in favour of this one.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T03:05:46Z.
Two things before this can go in:
agc_device_fault_testsdoesn't link on Windows; it needslibcandlibkerneland libc's directory onPATH, as the other agc tests have (Sam-mon7's CMake above).DeviceLostHook()is one hook for the process: a second device overwrites the first's, and~Stateof either device clears it for both. Please keep the hook perVkDevice, or clear it only when it still belongs to the device being destroyed.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T12:02:38Z.
Rebased onto current
main(the conflict was only adjacency inVulkanDevice.cpp) and added the two points raised above, in the same commit:agc_device_fault_testsnow linkslibc libkernel, and theagc_device_faulttest prepends libc's directory toPATHon Windows, as in @Sam-mon7's snippet.~StatewhenGraphics::DeviceLostOwner()is still that device, so destroying a windowless device no longer removes the rendering device's hook.Built and ran the scoped tests (libSceAgcDriver, libkernel, relinker):
agc_device_faultpasses;agc_driver_tessellation(RADV segfault) andguest_current_cpu(load flake) fail the same way without this PR. Merging once the Windows build is green.