Repository navigation
vulkan: say once when the device is lost (RT-DEVICE-LOST-LOG) - #980
Conversation
VulkanContext::mark_device_lost() and the fence dispatcher's two VK_ERROR_DEVICE_LOST paths only set the device's lost flag. From then on every fence reads UINT64_MAX and device calls return DXGI_ERROR_DEVICE_REMOVED, so a title takes its own device-removed path (on the retail boot an int3 at game_scarlett_master.exe+0x2474606, reached from its frame wait reading a fence's completed value as ~0), and nothing in the log said the device had gone first. set_device_lost() sets the flag with an exchange and, the first time for a device, prints one stderr line saying where the loss was seen. mark_device_lost() takes that place as an optional argument; the dispatcher passes its own two. device_lost_reports counts the lines for tests. Tests: vk_fence_dispatcher_sync_test cases 3 and 4 check one line per device, from mark_device_lost() and from the dispatcher's vkGetSemaphoreCounterValue path, and none from a later call on the same device. AI-assisted.
|
Test note for my approval above: reviewed current head |
|
Follow-up to my earlier software Vulkan run: I built the same |
|
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 0f98d19, its ctests pass both plain and with LEONIDA_VK_VALIDATION=1. Cumulative with the rest of this batch on main 507029d: 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 main 9c5e706: 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). |
Main now has its own device-fault report (LEONIDA_DEVICE_FAULT=1, from ProjectLeonida#984) and ProjectLeonida#980's device-lost line, so this branch's vulkan_device_fault.h, its report code and vk_device_fault_test are dropped in favour of main's. What stays is the case main does not cover: a loss the driver shows only as a timeline counter of UINT64_MAX. VulkanFence::completed() then asks vkDeviceWaitIdle through observe_result, so main's report runs, and marks the device lost when that returns VK_ERROR_DEVICE_LOST. vk_fence_lost_by_counter_test is adapted to main's reporter. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claimed in the coordination issue as: RT-DEVICE-LOST-LOG (#14 (comment))
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)