feat(agc): record GPU checkpoints through VK_AMD_buffer_marker #7920
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7920"
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 hugodearaujo on 2026-10-19T14:02:53Z.
What
APS5_GPU_CHECKPOINTSrecords aVK_NV_device_diagnostic_checkpointsmarker with the program address before each compute dispatch, and on the firstVK_ERROR_DEVICE_LOSTthe report lists the last ones the GPU reached. Only NVIDIA exposes that extension, so on AMD the variable does nothing, and RADV'sVK_EXT_device_faultsays nothing about a hang that is not a page fault: the report is[device-fault] result 0:with an empty description.On a device without the NV extension but with
VK_AMD_buffer_marker(RADV and AMD's own drivers), this PR records the same checkpoints with buffer markers:TOP_OF_PIPEmarker writes the number into the first word of an 8-byte host-visible, host-coherent buffer; after it, aBOTTOM_OF_PIPEmarker writes it into the second word;VK_EXT_device_faultlines and names the program of the last dispatch reached, of the last one finished (or says that none finished), and of up to eight dispatches between them.Without the variable nothing changes, and the NV path is unchanged. As in the NV path, only compute dispatches are marked. The numbers are taken when a dispatch is recorded, so with command buffers submitted in another order than they were recorded, the two words are only the last numbers the GPU wrote; when the finished number is ahead of the reached one, the report lists nothing between them.
Title
CONTROL Resonant (PPSA34547) loses the GPU after New Game. On NVIDIA, @ps54all's runs with
APS5_GPU_CHECKPOINTSput the last checkpoint right before compute program0x1004276f00(#7302). On an RX 9070 XT with RADV the variable did nothing: an earlier run there lost the device to a page fault, andVK_EXT_device_faultgave only the faulting address (#7302).With this PR, on
maina373e85e5with #7064, #7254 and a local change that treats the title's fast-launch input as a point list (the guess from #7302), about 30 s after New Game amdgpu loggedring gfx_0.0.0 timeout, with no page fault this time, and the report named the same program:That dispatch had also finished, so the hang came after it, in work the markers do not cover.
Tested
agc_device_faultchecks the report: numbering from 1, the reached, finished and unfinished lines, nothing finished, a finished queue, a finished number ahead of the reached one, a log slot that was overwritten, and a long unfinished run cut to eight lines and counted.A device loss on RADV, forced by a local test that is not part of this PR, with
APS5_GPU_CHECKPOINTS=1: amdgpu loggedring gfx_0.0.0 timeoutand reset the ring, and the next submission gotVK_ERROR_DEVICE_LOSTand printed:0x55d281eff200is the address of the test's program.Linux (Arch, kernel 7.2.11, GCC 16.2.1, Release, AMD Radeon RX 9070 XT with RADV, Mesa 26.2.5), on
main97d5d7a52: full CTest with-j8, 1588 of 1592 pass; the four failures also fail onmainon this machine:agc_driver_tessellation(#5444, a Mesa bug),agc_driver_bda_device(#7584),agc_driver_guest_memory_lifetime(#7784) andagc_driver_image_table_vouched_lookups(#7766).Windows Server 2025 VM, WinLibs GCC 15.2, Release,
BUILD_TESTING=ON, onmaina373e85e5(the same change before the rebase). The VM has no GPU, so the GPU tests do not run there: of 1548 tests, 975 pass, 573 are skipped, nearly all of them GPU tests, and none fails.Windows 11 with AMD's own driver (RX 9070 XT, 26.10.1), by @BunnyFl with this PR merged onto
main352dbe751(comment): the driver exposesVK_AMD_buffer_marker,agc_device_faultpasses, and in three of three runs of Indiana Jones and the Staff of Kings (PPSA14388) the report named the same unfinished dispatch, the oneVK_LAYER_LUNARG_crash_diagnosticalso points to (#8627).tools/check_conventions.pypasses.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 BunnyFl on 2026-10-20T18:57:18Z.
Tested on Windows 11 with AMD's own driver (RX 9070 XT, 26.10.1 LLPC), merged onto
main352dbe751: the driver exposesVK_AMD_buffer_marker, andagc_device_faultpasses. WithAPS5_GPU_CHECKPOINTS=1, Indiana Jones and the Staff of Kings (PPSA14388) lost the device the same way in three of three runs:Without the PR the report was only
result 0: Device lost detected. Details: https://github.com/boykopovar/AnyPS5/discussions/8627Imported from boykopovar/AnyPS5. Originally posted by hugodearaujo on 2026-10-20T18:59:56Z.
Thanks, @BunnyFl. That is the first run on AMD's own driver; I only had RADV. It is also the first game hang where the report names an unfinished dispatch (in Control the last dispatch reached had finished too), and it agrees with what
VK_LAYER_LUNARG_crash_diagnosticshowed you in #8627.Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-21T09:33:05Z.
Another AMD-driver data point: Windows 11, RX 6700 XT, 26.10.1, with this PR applied on main
71401e331.VK_AMD_buffer_markeris exposed and the report works.It also shows a case the dispatch-only markers can't attribute. Code Violet (PPSA26528) loses the device inside a draw, the title's first mesh draw. With dispatch markers only, the report would name the last dispatch before it, which had finished.
To check, I added a local hook (not part of this PR) that gives every recorded draw a marker number in the same
BufferMarkerLog, withTOP_OF_PIPEandBOTTOM_OF_PIPEaroundrecordDrawCommands. The reports then named the mesh draw consistently:(
0xc0…is my local tag for "mesh draw, 2 groups × 1 instance", standing in for a program address.) Details are in #6256.Two notes in case they're useful:
recordDrawCommandsdoesn't have one at hand, so the hook would need to come from where the draw's programs are known.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-21T10:09:30Z.
@JJenkx thanks, that's a useful second AMD-driver confirmation, and the draw case is a real gap. This PR only marks dispatches, so a device loss inside a draw is reported against the last dispatch, as you saw.
Draw markers and per-queue marker words both look like good follow-ups, but separate ones, after this lands. As you say, the draw hook needs a program address from where the draw's programs are known, not from
recordDrawCommands. If you open a PR for either, link #6256 and this one.Imported from boykopovar/AnyPS5. Originally posted by hugodearaujo on 2026-10-21T12:23:04Z.
@JJenkx Thanks for the second AMD-driver run, and for checking the draw case on Code Violet. As @oneandonlydean said, draw markers and per-queue marker words fit better as follow-ups once this lands.