[PR #1028] [MERGED] vulkan: print the driver's fault report when the device is lost (RT-DEVICE-FAULT-INFO) #1065

Closed
opened 2026-11-26 20:19:58 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1028
Author: @quartz-heron-58
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @aslan2142

Base: main ← Head: device-fault


📝 Commits (6)

  • da74b96 vulkan: print the driver's fault report when the device is lost (RT-DEVICE-FAULT-INFO)
  • 35e38ba vulkan: a loss the driver shows only as a counter of UINT64_MAX is recorded
  • ef0cc42 Merge main (6261ca91) into device-fault
  • 3bc03ba Merge main (4a50cafc) into device-fault
  • cf4f434 Merge main (82f033512) into device-fault; keep only the fence-counter loss
  • 427abf2 vulkan_backend: name only the driver versions the counter loss was seen on

📊 Changes

3 files changed (+146 additions, -0 deletions)

View changed files

📝 runtime/CMakeLists.txt (+16 -0)
📝 runtime/src/vulkan_backend.h (+16 -0)
➕ runtime/test/vk_fence_lost_by_counter_test.cpp (+114 -0)

📄 Description

Claimed in the coordination issue as: RT-DEVICE-FAULT-INFO (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7137960817)

Depends on: #980 (RT-DEVICE-LOST-LOG). This branch is #980's commit 5c1f77e1 plus two of mine, so until #980 merges the diff here shows its commit too. It builds on set_device_lost and changes none of #980's lines apart from using its return value.

What and why

#980 makes the layer say once that its Vulkan device was lost. This adds why, as far as the driver will tell, and fixes one way the loss was never noticed at all.

1. The driver's fault report. Where the device has VK_EXT_device_fault (feature deviceFault), the extension is enabled at device creation and, the first time the device is lost, vkGetDeviceFaultInfoEXT is queried and its report printed after #980's line: the description, each address fault (type, address, precision) and each vendor fault (description, code, data). At most 16 of each are printed, then a count of the rest. The vendor binary is not requested and deviceFaultVendorBinary stays off. Without the extension the entry point is null and nothing is printed or changed. runtime/src/vulkan_device_fault.h builds the lines from a callable, so a test can stand in for the driver.

2. A loss the driver shows only through a counter. VulkanFence::completed() returned whatever vkGetSemaphoreCounterValue wrote when the call succeeded. On NVIDIA 621.24 (RTX 4080) a lost device is first visible there as VK_SUCCESS with a counter of UINT64_MAX; vkWaitSemaphores on that semaphore with timeout 0 also returns VK_SUCCESS. The value went to the title through the fence slot 12 mirror, the title took its device-removed path, and the layer's lost flag was never set. With #980 applied on its own, that run prints no "device was lost" line. completed() now treats UINT64_MAX as a question, not proof: it calls vkDeviceWaitIdle under the submit lock and records the loss only on VK_ERROR_DEVICE_LOST. Measured on the same driver: vkGetDeviceFaultInfoEXT returns VK_ERROR_UNKNOWN (-13) before a call has returned VK_ERROR_DEVICE_LOST, and answers after vkDeviceWaitIdle has.

Open point for review: vkDeviceWaitIdle under submit_mutex() inside completed(). Its callers (GetCompletedValue, Signal, SetEventOnCompletion in d3d12_com.cpp) do not hold that lock, and the call returns at once on a lost device, but a counter that really is UINT64_MAX on a live device would wait for the queues. No fence of the layer is signalled to that value.

Where this came from

@DadaCap's boot-prototype (9173e790) with LEONIDA_LAZY_PSO=1 and LEONIDA_GPU_REGION_MB=10240, own 1.0.2.1 copy, RTX 4080, driver 621.24, Windows 11 26300: the retail run reaches the first-run menus and stops 70 to 95 s in, right after they are accepted, at the title's device-removed int3 (the one #980 describes), 12 runs of 12. The Windows event log has nvlddmkm event 153 at the same second each time. Not memory (same with 12 GB free), not the OBS capture layer (same with it disabled), and the Khronos validation layer reports no error before it apart from one SYNC-HAZARD-WRITE-AFTER-WRITE on two small vkCmdCopyBuffer writes to the arena buffer.

With this branch cherry-picked onto the prototype the log reads:

[rt] vulkan: the device was lost (a fence's counter read UINT64_MAX and vkDeviceWaitIdle then returned VK_ERROR_DEVICE_LOST); its fences now read UINT64_MAX and device calls return DXGI_ERROR_DEVICE_REMOVED
[rt] vulkan: the driver's fault report (VK_EXT_device_fault): no description
[rt] vulkan:   address fault 0: instruction pointer, cause unknown, address 0x2000af700, precision 0x10
[rt] vulkan:   address fault 1: instruction pointer, cause unknown, address 0x2000af6f0, precision 0x10

Three runs gave two or three faults, all INSTRUCTION_POINTER_UNKNOWN, at addresses within 0x300 of each other (0x2000af410 to 0x2000af700). No read or write of an invalid address is reported, so the cause is still open; the addresses are GPU addresses from the driver, not title addresses. The driver also offers a 166,156-byte vendor binary, which this change does not collect.

Tested

Native Windows 11, MSVC 14.44, Ninja, RelWithDebInfo, branch on main 1504c1af + #980, RTX 4080 (driver 621.24), Vulkan SDK 1.4.363:

  • New vk_device_fault_test (no GPU, a stand-in driver): the lines for a report with address and vendor faults; the two-call shape with the vendor binary size set to 0; a failed count query and a failed report query; an empty report; an unterminated description; more faults than the print limit; counts written back larger than the room given; an unknown address type; and report_device_fault with a null entry point printing nothing. Passes.
  • New vk_fence_lost_by_counter_test (driver functions interposed on a real device, skips with 77 without one): UINT64_MAX with vkDeviceWaitIdle returning VK_ERROR_DEVICE_LOST marks the context lost, says the loss once and prints one fault report; a second read and a later mark_device_lost() say nothing more; UINT64_MAX with vkDeviceWaitIdle returning VK_SUCCESS records no loss; an ordinary value never reaches vkDeviceWaitIdle. Passes.
  • ctest -R 'vk_device_fault|vk_fence|d3d12_fence|d3d12_cross_device_validation|vk_queue': 11 of 11 pass, #980's vk_fence_dispatcher_sync and d3d12_fence_device_lost_counter among them.
  • gta6rt builds with no new warning in the changed files. The full ctest suite was not run.
  • The retail lines above are from the prototype with these two commits and #980 cherry-picked; that tree is not this branch.
  • Not run: Linux, Wine, AMD, Intel, and a device without VK_EXT_device_fault.

GPUs tested: NVIDIA GeForce RTX 4080, driver 621.24, Windows 11 26300 (the tests above and the retail run).

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (No translator change.)

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1028 **Author:** [@quartz-heron-58](https://github.com/quartz-heron-58) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/25/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `device-fault` --- ### 📝 Commits (6) - [`da74b96`](https://github.com/ubiquitarianism/leonida/commit/da74b96810eba31eb15d1cfd576fe4c69f159912) vulkan: print the driver's fault report when the device is lost (RT-DEVICE-FAULT-INFO) - [`35e38ba`](https://github.com/ubiquitarianism/leonida/commit/35e38baee361f55cdbcb0c7b9febe4b48481fdcf) vulkan: a loss the driver shows only as a counter of UINT64_MAX is recorded - [`ef0cc42`](https://github.com/ubiquitarianism/leonida/commit/ef0cc4254f46b953cc2b3f46c18163a8f8e1351d) Merge main (6261ca91) into device-fault - [`3bc03ba`](https://github.com/ubiquitarianism/leonida/commit/3bc03ba69f30a09fd564287b3c8848c09260af54) Merge main (4a50cafc) into device-fault - [`cf4f434`](https://github.com/ubiquitarianism/leonida/commit/cf4f434d23808742a2bea5536aaf662662a64099) Merge main (82f033512) into device-fault; keep only the fence-counter loss - [`427abf2`](https://github.com/ubiquitarianism/leonida/commit/427abf2613a49fd1a52a50ab7cd5fa630ec780a4) vulkan_backend: name only the driver versions the counter loss was seen on ### 📊 Changes **3 files changed** (+146 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `runtime/CMakeLists.txt` (+16 -0) 📝 `runtime/src/vulkan_backend.h` (+16 -0) ➕ `runtime/test/vk_fence_lost_by_counter_test.cpp` (+114 -0) </details> ### 📄 Description Claimed in the coordination issue as: RT-DEVICE-FAULT-INFO (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7137960817) Depends on: #980 (RT-DEVICE-LOST-LOG). This branch is #980's commit `5c1f77e1` plus two of mine, so until #980 merges the diff here shows its commit too. It builds on `set_device_lost` and changes none of #980's lines apart from using its return value. ### What and why #980 makes the layer say once that its Vulkan device was lost. This adds why, as far as the driver will tell, and fixes one way the loss was never noticed at all. **1. The driver's fault report.** Where the device has `VK_EXT_device_fault` (feature `deviceFault`), the extension is enabled at device creation and, the first time the device is lost, `vkGetDeviceFaultInfoEXT` is queried and its report printed after #980's line: the description, each address fault (type, address, precision) and each vendor fault (description, code, data). At most 16 of each are printed, then a count of the rest. The vendor binary is not requested and `deviceFaultVendorBinary` stays off. Without the extension the entry point is null and nothing is printed or changed. `runtime/src/vulkan_device_fault.h` builds the lines from a callable, so a test can stand in for the driver. **2. A loss the driver shows only through a counter.** `VulkanFence::completed()` returned whatever `vkGetSemaphoreCounterValue` wrote when the call succeeded. On NVIDIA 621.24 (RTX 4080) a lost device is first visible there as `VK_SUCCESS` with a counter of `UINT64_MAX`; `vkWaitSemaphores` on that semaphore with timeout 0 also returns `VK_SUCCESS`. The value went to the title through the fence slot 12 mirror, the title took its device-removed path, and the layer's lost flag was never set. With #980 applied on its own, that run prints no "device was lost" line. `completed()` now treats `UINT64_MAX` as a question, not proof: it calls `vkDeviceWaitIdle` under the submit lock and records the loss only on `VK_ERROR_DEVICE_LOST`. Measured on the same driver: `vkGetDeviceFaultInfoEXT` returns `VK_ERROR_UNKNOWN` (-13) before a call has returned `VK_ERROR_DEVICE_LOST`, and answers after `vkDeviceWaitIdle` has. Open point for review: `vkDeviceWaitIdle` under `submit_mutex()` inside `completed()`. Its callers (`GetCompletedValue`, `Signal`, `SetEventOnCompletion` in `d3d12_com.cpp`) do not hold that lock, and the call returns at once on a lost device, but a counter that really is `UINT64_MAX` on a live device would wait for the queues. No fence of the layer is signalled to that value. ### Where this came from @DadaCap's `boot-prototype` (`9173e790`) with `LEONIDA_LAZY_PSO=1` and `LEONIDA_GPU_REGION_MB=10240`, own 1.0.2.1 copy, RTX 4080, driver 621.24, Windows 11 26300: the retail run reaches the first-run menus and stops 70 to 95 s in, right after they are accepted, at the title's device-removed `int3` (the one #980 describes), 12 runs of 12. The Windows event log has `nvlddmkm` event 153 at the same second each time. Not memory (same with 12 GB free), not the OBS capture layer (same with it disabled), and the Khronos validation layer reports no error before it apart from one `SYNC-HAZARD-WRITE-AFTER-WRITE` on two small `vkCmdCopyBuffer` writes to the arena buffer. With this branch cherry-picked onto the prototype the log reads: ``` [rt] vulkan: the device was lost (a fence's counter read UINT64_MAX and vkDeviceWaitIdle then returned VK_ERROR_DEVICE_LOST); its fences now read UINT64_MAX and device calls return DXGI_ERROR_DEVICE_REMOVED [rt] vulkan: the driver's fault report (VK_EXT_device_fault): no description [rt] vulkan: address fault 0: instruction pointer, cause unknown, address 0x2000af700, precision 0x10 [rt] vulkan: address fault 1: instruction pointer, cause unknown, address 0x2000af6f0, precision 0x10 ``` Three runs gave two or three faults, all `INSTRUCTION_POINTER_UNKNOWN`, at addresses within 0x300 of each other (`0x2000af410` to `0x2000af700`). No read or write of an invalid address is reported, so the cause is still open; the addresses are GPU addresses from the driver, not title addresses. The driver also offers a 166,156-byte vendor binary, which this change does not collect. ### Tested Native Windows 11, MSVC 14.44, Ninja, RelWithDebInfo, branch on `main` `1504c1af` + #980, RTX 4080 (driver 621.24), Vulkan SDK 1.4.363: - New `vk_device_fault_test` (no GPU, a stand-in driver): the lines for a report with address and vendor faults; the two-call shape with the vendor binary size set to 0; a failed count query and a failed report query; an empty report; an unterminated description; more faults than the print limit; counts written back larger than the room given; an unknown address type; and `report_device_fault` with a null entry point printing nothing. Passes. - New `vk_fence_lost_by_counter_test` (driver functions interposed on a real device, skips with 77 without one): `UINT64_MAX` with `vkDeviceWaitIdle` returning `VK_ERROR_DEVICE_LOST` marks the context lost, says the loss once and prints one fault report; a second read and a later `mark_device_lost()` say nothing more; `UINT64_MAX` with `vkDeviceWaitIdle` returning `VK_SUCCESS` records no loss; an ordinary value never reaches `vkDeviceWaitIdle`. Passes. - `ctest -R 'vk_device_fault|vk_fence|d3d12_fence|d3d12_cross_device_validation|vk_queue'`: 11 of 11 pass, #980's `vk_fence_dispatcher_sync` and `d3d12_fence_device_lost_counter` among them. - `gta6rt` builds with no new warning in the changed files. The full `ctest` suite was not run. - The retail lines above are from the prototype with these two commits and #980 cherry-picked; that tree is not this branch. - Not run: Linux, Wine, AMD, Intel, and a device without `VK_EXT_device_fault`. GPUs tested: NVIDIA GeForce RTX 4080, driver 621.24, Windows 11 26300 (the tests above and the retail run). AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (No translator change.) 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:19:58 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#1065
No description provided.