vulkan: say once when the device is lost (RT-DEVICE-LOST-LOG) #980
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!980
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/980/head"
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?
@CLHelper on GitHub · 2026-11-24 16:15 UTC · original
CLHelper:runtime/device-lost-log→main· +37 −6 · 2 files · 1 commits · merged 2026-11-25 00:01 UTCClaimed in the coordination issue as: RT-DEVICE-LOST-LOG (#14)
What and why
When the layer's Vulkan device is lost,
VulkanContext::mark_device_lost()and the fence dispatcher's twoVK_ERROR_DEVICE_LOSTpaths only set the device's lost flag. From then on every fence readsUINT64_MAXand device calls returnDXGI_ERROR_DEVICE_REMOVED, so the title takes its own device-removed path, and nothing in the log said that the device went first.On the retail boot that path is easy to misread. The title's frame wait gets the address of a fence's completed value (fence slot 12), spins on it, and when it reads
~0it calls a fatal routine that ends in anint3atgame_scarlett_master.exe+0x2474606(static reading of my own 1.0.2.1 copy: the wait at+0x4fb0ad0,call +0x2474870when the value is-1, the routine at+0x2474500). WithLEONIDA_SKIP_INT3the title then runs on into reads of garbage addresses. In five runs of @DadaCap'sboot-prototypeon my machine, thatint3and the access violations after it were the only visible stop. The fence values come fromGetCompletedValue. Correction after review elsewhere: I first wrote here that the layer answersUINT64_MAXonly once its lost flag is set. That is not the whole story: on NVIDIA a lost device can first show up asvkGetSemaphoreCounterValuereturningVK_SUCCESSwith a counter ofUINT64_MAX, and then the flag is never set and this pull request alone prints nothing. #1028 (which builds on this one) catches that case and adds the driver's fault report; @DesertGamer measured the same path on a fifth machine (#14).The change (
runtime/src/vulkan_backend.h, plus its test):set_device_lost(flag, where)sets the flag with an exchange and, the first time for a device, prints one line on stderr:[rt] vulkan: the device was lost (<where>); its fences now read UINT64_MAX and device calls return DXGI_ERROR_DEVICE_REMOVED.mark_device_lost()uses it, with an optionalwhere(default: a Vulkan call returnedVK_ERROR_DEVICE_LOST); every existing caller is unchanged. The dispatcher's two direct stores use it with their ownwhere(vkWaitSemaphoresandvkGetSemaphoreCounterValuein the fence dispatcher).device_lost_reportscounts the lines said in the process, for tests. Nothing else changes: the flag, the dispatcher wake-up and every return value behave as before.Tested
Native Windows 11, MSVC 19.44, Ninja, RelWithDebInfo, on
maina28927849(merges cleanly on42d705c85), RTX 4060 Laptop, NVIDIA 576.80, Vulkan SDK 1.4.363:vk_fence_dispatcher_sync_test: case 3 now also checks one line frommark_device_lost()and none from a second call or from the dispatcher waking on the same flag; case 4 checks one line from the dispatcher'svkGetSemaphoreCounterValuepath and none from a latermark_device_lost(). Passes.d3d12_fence_device_lost_counter_testandd3d12_cross_device_validation_test, which lose devices on purpose, pass; the first prints the line once for each device it loses.vk_fence_dispatcher_sync_testat case 3.gta6rtbuilds.GPUs tested: NVIDIA GeForce RTX 4060 Laptop GPU, driver 576.80, Windows 11 (the three tests above).
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)@KernelSmoker on GitHub · 2026-11-24 16:23 UTC · original · approved these changes
@KernelSmoker on GitHub · 2026-11-24 16:24 UTC · original
Test note for my approval above: reviewed current head
5c1f77e1d4bafb3cba8c3e2037de28cb376f633e. The first transition of the per-context lost flag is reported once via atomic exchange; later dispatcher/context paths do not emit duplicate lines. Both explicit mark and dispatcher counter-error paths assert once-only behavior. Builtvk_fence_dispatcher_sync_testin a disposable Fedora 45 Vulkan-tools image; CTest: 1/1 passed (0.32 s). The container exposed llvmpipe, so this verifies the test path with a software device; it does not establish RTX 3090 execution or hardware device-loss behavior.git diff --checkpassed. Hosted checks were pending at review time.@KernelSmoker on GitHub · 2026-11-24 16:39 UTC · original
Follow-up to my earlier software Vulkan run: I built the same
vk_fence_dispatcher_sync_testtarget in the disposable Fedora 45 image, then ran the executable on the host with the NVIDIA x86_64 Vulkan ICD selected. It reportedNVIDIA GeForce RTX 3090(driver 620.73.04) and all six fence-dispatcher scenarios passed, including the once-only report assertions for synthetic context-mark andvkGetSemaphoreCounterValuedevice-loss paths. This exercises the real NVIDIA Vulkan device setup; it does not induce a physical GPU failure or use game data.@QemmHD on GitHub · 2026-11-25 00:01 UTC · original
Merging.
Why merged: RT-DEVICE-LOST-LOG: when the device is lost, the layer prints one stderr line per device. An atomic exchange keeps the context path and the dispatcher path from both printing. KernelSmoker approved it (llvmpipe and RTX 3090).
Why it's good: vk_fence_dispatcher_sync, vk_queue and vk_queue_query_sync pass both plain and under validation.
Tested on Windows 11 / RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0. Merged alone onto main
0f98d193c, its ctests pass both plain and with LEONIDA_VK_VALIDATION=1. Cumulative with the rest of this batch on main507029d1e: the repo-consistency set gives 578 passed / 5 skipped / 0 failed, compileall is clean, and full ctest is 317/318 with the usual 11 skips; the only failure is main's pre-existing d3d12_depth_resolve. All d3d12_* tests under validation: 119/120 with 0 VUIDs. The semantic suite has only the known environment-only failure. git merge-tree against current main9c5e70661: no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls or CI changes.AI-assisted (Claude Code, Claude Opus 5.5).