feat(agc): record GPU checkpoints through VK_AMD_buffer_marker #7920

Merged
hugodearaujo merged 1 commit from upstream-pr/7920 into main 2026-10-23 08:20:58 +00:00
hugodearaujo commented 2026-10-19 14:02:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hugodearaujo on 2026-10-19T14:02:53Z.


What

APS5_GPU_CHECKPOINTS records a VK_NV_device_diagnostic_checkpoints marker with the program address before each compute dispatch, and on the first VK_ERROR_DEVICE_LOST the report lists the last ones the GPU reached. Only NVIDIA exposes that extension, so on AMD the variable does nothing, and RADV's VK_EXT_device_fault says 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:

  • each compute dispatch takes a number, and its program address is kept under that number in a 4096-entry log;
  • before the dispatch, a TOP_OF_PIPE marker writes the number into the first word of an 8-byte host-visible, host-coherent buffer; after it, a BOTTOM_OF_PIPE marker writes it into the second word;
  • on device loss, the report reads both words before the VK_EXT_device_fault lines 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_CHECKPOINTS put the last checkpoint right before compute program 0x1004276f00 (#7302). On an RX 9070 XT with RADV the variable did nothing: an earlier run there lost the device to a page fault, and VK_EXT_device_fault gave only the faulting address (#7302).

With this PR, on main a373e85e5 with #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 logged ring gfx_0.0.0 timeout, with no page fault this time, and the report named the same program:

radv/amdgpu: The CS has been cancelled because the context is lost. This context is innocent.
[device-fault] last dispatch reached: marker 426660, program 0x1004276f00
[device-fault] last dispatch finished: marker 426660, program 0x1004276f00
[device-fault] result 0: 

That dispatch had also finished, so the hang came after it, in work the markers do not cover.

Tested

  • agc_device_fault checks 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 logged ring gfx_0.0.0 timeout and reset the ring, and the next submission got VK_ERROR_DEVICE_LOST and printed:

    radv/amdgpu: The CS has been cancelled because the context is lost. This context is guilty of a hard recovery.
    [device-fault] last dispatch reached: marker 1, program 0x55d281eff200
    [device-fault] no dispatch finished
    [device-fault] unfinished dispatch: marker 1, program 0x55d281eff200
    [device-fault] result 0: 
    

    0x55d281eff200 is 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 main 97d5d7a52: full CTest with -j8, 1588 of 1592 pass; the four failures also fail on main on this machine: agc_driver_tessellation (#5444, a Mesa bug), agc_driver_bda_device (#7584), agc_driver_guest_memory_lifetime (#7784) and agc_driver_image_table_vouched_lookups (#7766).

  • Windows Server 2025 VM, WinLibs GCC 15.2, Release, BUILD_TESTING=ON, on main a373e85e5 (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 main 352dbe751 (comment): the driver exposes VK_AMD_buffer_marker, agc_device_fault passes, and in three of three runs of Indiana Jones and the Staff of Kings (PPSA14388) the report named the same unfinished dispatch, the one VK_LAYER_LUNARG_crash_diagnostic also points to (#8627).

  • tools/check_conventions.py passes.

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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: AMD Radeon RX 9070 XT, RADV (Mesa 26.2.5), Arch Linux; AMD Radeon RX 9070 XT, AMD driver 26.10.1, Windows 11 (by @BunnyFl)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4922173478 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7920). Originally posted by [hugodearaujo](https://github.com/hugodearaujo) on 2026-10-19T14:02:53Z. --- ### What `APS5_GPU_CHECKPOINTS` records a `VK_NV_device_diagnostic_checkpoints` marker with the program address before each compute dispatch, and on the first `VK_ERROR_DEVICE_LOST` the report lists the last ones the GPU reached. Only NVIDIA exposes that extension, so on AMD the variable does nothing, and RADV's `VK_EXT_device_fault` says 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: - each compute dispatch takes a number, and its program address is kept under that number in a 4096-entry log; - before the dispatch, a `TOP_OF_PIPE` marker writes the number into the first word of an 8-byte host-visible, host-coherent buffer; after it, a `BOTTOM_OF_PIPE` marker writes it into the second word; - on device loss, the report reads both words before the `VK_EXT_device_fault` lines 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_CHECKPOINTS` put the last checkpoint right before compute program `0x1004276f00` ([#7302](https://github.com/boykopovar/AnyPS5/discussions/7302)). On an RX 9070 XT with RADV the variable did nothing: an earlier run there lost the device to a page fault, and `VK_EXT_device_fault` gave only the faulting address (#7302). With this PR, on `main` a373e85e5 with #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 logged `ring gfx_0.0.0 timeout`, with no page fault this time, and the report named the same program: ``` radv/amdgpu: The CS has been cancelled because the context is lost. This context is innocent. [device-fault] last dispatch reached: marker 426660, program 0x1004276f00 [device-fault] last dispatch finished: marker 426660, program 0x1004276f00 [device-fault] result 0: ``` That dispatch had also finished, so the hang came after it, in work the markers do not cover. ### Tested - `agc_device_fault` checks 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 logged `ring gfx_0.0.0 timeout` and reset the ring, and the next submission got `VK_ERROR_DEVICE_LOST` and printed: ``` radv/amdgpu: The CS has been cancelled because the context is lost. This context is guilty of a hard recovery. [device-fault] last dispatch reached: marker 1, program 0x55d281eff200 [device-fault] no dispatch finished [device-fault] unfinished dispatch: marker 1, program 0x55d281eff200 [device-fault] result 0: ``` `0x55d281eff200` is 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 `main` 97d5d7a52: full CTest with `-j8`, 1588 of 1592 pass; the four failures also fail on `main` on this machine: `agc_driver_tessellation` (#5444, a Mesa bug), `agc_driver_bda_device` (#7584), `agc_driver_guest_memory_lifetime` (#7784) and `agc_driver_image_table_vouched_lookups` (#7766). - Windows Server 2025 VM, WinLibs GCC 15.2, Release, `BUILD_TESTING=ON`, on `main` a373e85e5 (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 `main` 352dbe751 ([comment](https://github.com/boykopovar/AnyPS5/pull/7920#issuecomment-6298758472)): the driver exposes `VK_AMD_buffer_marker`, `agc_device_fault` passes, and in three of three runs of Indiana Jones and the Staff of Kings (PPSA14388) the report named the same unfinished dispatch, the one `VK_LAYER_LUNARG_crash_diagnostic` also points to (#8627). - `tools/check_conventions.py` passes. ### 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] Fixes: none - [x] Unblocks: none - [x] GPUs tested: AMD Radeon RX 9070 XT, RADV (Mesa 26.2.5), Arch Linux; AMD Radeon RX 9070 XT, AMD driver 26.10.1, Windows 11 (by @BunnyFl) - [x] AI-assisted: yes
BunnyFl commented 2026-10-20 18:57:18 +00:00 (Migrated from github.com)

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 main 352dbe751: the driver exposes VK_AMD_buffer_marker, and agc_device_fault passes. With APS5_GPU_CHECKPOINTS=1, Indiana Jones and the Staff of Kings (PPSA14388) lost the device the same way in three of three runs:

[device-fault] last dispatch reached: marker 493, program 0x140c8a000
[device-fault] last dispatch finished: marker 492, program 0x140cb8200
[device-fault] unfinished dispatch: marker 493, program 0x140c8a000
[device-fault] result 0: Device lost detected

Without the PR the report was only result 0: Device lost detected. Details: https://github.com/boykopovar/AnyPS5/discussions/8627

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6298758472 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7920#issuecomment-6298758472). Originally posted by [BunnyFl](https://github.com/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 `main` 352dbe751: the driver exposes `VK_AMD_buffer_marker`, and `agc_device_fault` passes. With `APS5_GPU_CHECKPOINTS=1`, Indiana Jones and the Staff of Kings (PPSA14388) lost the device the same way in three of three runs: ``` [device-fault] last dispatch reached: marker 493, program 0x140c8a000 [device-fault] last dispatch finished: marker 492, program 0x140cb8200 [device-fault] unfinished dispatch: marker 493, program 0x140c8a000 [device-fault] result 0: Device lost detected ``` Without the PR the report was only `result 0: Device lost detected`. Details: https://github.com/boykopovar/AnyPS5/discussions/8627
hugodearaujo commented 2026-10-20 18:59:56 +00:00 (Migrated from github.com)

Imported 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_diagnostic showed you in #8627.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6298808669 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7920#issuecomment-6298808669). Originally posted by [hugodearaujo](https://github.com/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_diagnostic` showed you in #8627.
JJenkx commented 2026-10-21 09:33:05 +00:00 (Migrated from github.com)

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_marker is 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, with TOP_OF_PIPE and BOTTOM_OF_PIPE around recordDrawCommands. The reports then named the mesh draw consistently:

[device-fault] last dispatch reached: marker 317, program 0xc000000002000001
[device-fault] last dispatch finished: marker 316, program 0x160061bc00
[device-fault] unfinished dispatch: marker 317, program 0xc000000002000001

(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:

  • Draws would need a program address the log can name. recordDrawCommands doesn't have one at hand, so the hook would need to come from where the draw's programs are known.
  • With an async-compute queue writing the same two words, I saw one report where both words came from the compute queue while the mesh draw was presumably still running. That's the multi-queue limit your description already states. Per-queue marker words would avoid it.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6312741188 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7920#issuecomment-6312741188). Originally posted by [JJenkx](https://github.com/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_marker` is 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`, with `TOP_OF_PIPE` and `BOTTOM_OF_PIPE` around `recordDrawCommands`. The reports then named the mesh draw consistently: ``` [device-fault] last dispatch reached: marker 317, program 0xc000000002000001 [device-fault] last dispatch finished: marker 316, program 0x160061bc00 [device-fault] unfinished dispatch: marker 317, program 0xc000000002000001 ``` (`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: - Draws would need a program address the log can name. `recordDrawCommands` doesn't have one at hand, so the hook would need to come from where the draw's programs are known. - With an async-compute queue writing the same two words, I saw one report where both words came from the compute queue while the mesh draw was presumably still running. That's the multi-queue limit your description already states. Per-queue marker words would avoid it. AI-assisted: yes (Claude Code)
oneandonlydean commented 2026-10-21 10:09:30 +00:00 (Migrated from github.com)

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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6313422539 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7920#issuecomment-6313422539). Originally posted by [oneandonlydean](https://github.com/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.
hugodearaujo commented 2026-10-21 12:23:04 +00:00 (Migrated from github.com)

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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6315799988 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7920#issuecomment-6315799988). Originally posted by [hugodearaujo](https://github.com/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.
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!7920
No description provided.