Repository navigation
Runtime: unblock independent Vulkan queue submissions during calibration - #3841
Conversation
|
Tested 7306e58 (based on main 4c52ce2) on Windows 11 build 26300, MSVC 19.44, Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0, with two GPUs picked by
The 77 on the UHD 770 is the expected skip. Its Vulkan driver exposes a single graphics/compute/transfer queue ( AI-assisted (Claude Code). No game files. |
Flyander
left a comment
There was a problem hiding this comment.
This queue-local lock leaves a device-wide host-synchronization gap with the bindless flush path.
|
|
||
| bool idle() { | ||
| std::lock_guard lock(context_.submit_mutex()); | ||
| std::lock_guard lock(context_.queue_host_mutex(queue_)); |
There was a problem hiding this comment.
vkDeviceWaitIdle still runs in runtime/shims/d3d12_vulkan_device.cpp under only submit_mutex, while GetClockCalibration/VulkanQueue::idle() now call vkQueueWaitIdle under this per-queue lock. VulkanQueue::execute() can invoke the bindless prepare callback while another thread is calibrating Q1, so the device-wide idle can overlap host access to that queue. Vulkan requires host access to all queues from the device to be externally synchronized during vkDeviceWaitIdle (spec); before this change both calls shared submit_mutex. Please coordinate device-wide idle with all queue host accesses (while preserving the ability for other queues to submit work needed by pending waits), and add a synthetic regression for bindless flush concurrent with calibration.
|
Tested
AI-assisted (Gemini, Antigravity). |
|
Tested 2454731 on AMD Radeon(TM) Graphics (gfx1036, driver 26.10.1) and NVIDIA GeForce RTX 5080 (driver 616.92), Windows 11, MSVC RelWithDebInfo: |
|
Tested 2454731 merged onto main 03b09a0 on an RTX 5090 (driver 616.92), Windows 11, MSVC 19.44, Vulkan SDK 1.4.363, RelWithDebInfo:
AI-assisted (Claude Code). |
Claimed in current coordinator: #3796 (comment)
What and why
The fallback ID3D12CommandQueue::GetClockCalibration (Vulkan device without calibrated timestamp domains) took a device-GLOBAL submit mutex across vkQueueWaitIdle(Q1). If Q1 had a submitted GPU wait on unsignaled fence F, Q2 could not submit the Signal(F) needed to unblock Q1 because Q2 also needed that same global mutex. This creates a genuine circular deadlock between otherwise independent queues, distinct from #2951's held Wait-before-Signal batches.
Introduce per-PHYSICAL-VkQueue host synchronization shared among VulkanQueue, D3D12 calibration, native presenter and DXGI swapchain. Vulkan submits / sparse binds / queue labels acquire per-queue host mutex BEFORE brief device-global submit/ticket critical section. Blocking QueueWaitIdle acquires only the queue's mutex and leaves the global mutex free for independent queues. Queue teardown retires tickets under the global lock AFTER idle, retaining correct ticket bookkeeping. Same physical VkQueue remains externally synchronized. No game assets.
Deterministic regression and WARP parity
New CTest uses two distinct VkQueue handles from vktest::Device (two graphics queues), a COM D3D12 device and an intercepted vkGetDeviceProcAddr. Test-only vkQueueWaitIdle hook parks Q1 for at most 700ms, while an independent thread calls Q2::Signal(F,1), testing whether Q2 actually enters vkQueueSubmit before the watchdog. Hook never blocks the physical GPU indefinitely.
Current upstream integration and tests
Original exact commit c85bbe8 was built and tested against f847748. Upstream main subsequently advanced to 4c52ce2 and merged #2951; rather than overwrite or force-push old tested branch, this PR is the fresh isolated integration 7306e58 based on current main. Resolved the only source conflict by keeping #2951's held-operation scheduling and applying host mutex to its relocated VulkanQueue::idle().
Current-main Windows MSVC 19.44/Vulkan SDK 1.4.363 focused compile 21/21 actions. RTX 4060 Ti, LEONIDA_VK_VALIDATION=1, Medal capture disabled: 7/7 focused CTests PASS (new D3D12 calibration + WARP variant, d3d12_fence_timing, merged #2951 d3d12_queue_handover, vk_presenter_sync, vk_queue_query_sync, dxgi_swapchain), zero failures, 15.02 seconds; git diff --check clean. Earlier main-based 8/8 focused CTests pass plus 12 repeated synthetic GPU regressions.
Limitations / integration