Commit Graph

5 Commits

Author SHA1 Message Date
5c1f77e1d4 vulkan: say once when the device is lost (RT-DEVICE-LOST-LOG)
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.
2026-11-24 16:09:38 +00:00
047b789d7b vulkan: make re-entrant cancel test independent of ready-batch timing
Case 6 assumed both fences were in one ready batch. The dispatcher may wake after the first signal, leaving B in pending_ when A calls cancel(B); in that case cancel() correctly runs B's callback before it returns. Assert the real contract instead: B must not run after cancel(B) returns, whether it was pending or already in a ready batch. Set the A-side flags in one lock scope so the waiter cannot see them half-updated. Red control on the parent source: 0/100 pass; fixed: 100/100 pass.

Shdann and Exopus independently reproduced the timing dependence; kapitche verified the fix on two GPUs.
2026-11-23 06:34:12 +03:00
dea6c38354 vulkan: skip later same-batch callbacks cancelled re-entrantly
FenceWaitDispatcher recorded every entry of a ready batch with the dispatching thread as owner, and in_flight() ignored all same-owner entries. A callback for semaphore A that re-entered cancel(B) therefore returned while B was still queued in the same batch and would run with a semaphore the caller had already destroyed.

Give each batch entry its own dispatch slot. cancel() marks not-yet-started slots for that semaphore as cancelled so dispatch skips them, while a callback actually running on another thread is still waited for. The skipped entry's event is completed so no waiter is left behind.

Regression: two ready callbacks in one batch; A cancels B and B must not run. Red before (B ran), green after.
2026-11-23 05:31:10 +03:00
df99c89162 vulkan: make fence cancel wait for in-flight callbacks
run() unlocked mutex_ before dispatching ready entries, while cancel() only waited for an active vkWaitSemaphores. A cancel could return and destroy the VkSemaphore while a callback for it was still running. Record each dispatched entry with its owning thread before unlocking; cancel waits for entries it does not own, so callbacks can still re-entrantly cancel their own semaphore. All four run() dispatch paths use the same helper. Adds a deterministic regression where cancel must block until a blocked callback has used the semaphore; reverting only the wait fails it.

AI-assisted (OpenCode)
2026-11-23 04:44:51 +03:00
b01bed6efd Runtime: dispatch FenceWaitDispatcher callbacks outside mutex and wake blocked waits on device lost 2026-11-22 18:06:35 +03:00