windows: fix VK_ERROR_DEVICE_LOST - give the D3D-interop blit its own VkQueue#174
Open
nobandegani wants to merge 1 commit into
Open
windows: fix VK_ERROR_DEVICE_LOST - give the D3D-interop blit its own VkQueue#174nobandegani wants to merge 1 commit into
nobandegani wants to merge 1 commit into
Conversation
…queue The logical device was created with a single queue in the graphics family. Filament receives that queue (index 0) through VulkanSharedContext and submits from its render thread, while the D3D-interop Blit fetched the same VkQueue and submitted from the Flutter platform thread. VkQueue access is externally synchronized, so this is a data race; older drivers tolerate it, but newer NVIDIA drivers (observed: RTX 5090, driver 610.62) fail the first concurrent submission with VK_ERROR_DEVICE_LOST, followed by a native abort via a vkGetQueryPoolResults postcondition in Filament timer queries. Request two queues from the family when the hardware exposes more than one (NVIDIA exposes 16) and use queue index 1 for the blit/command path, keeping queue 0 exclusively Filament's. Falls back to the old single-queue behavior on hardware with queueCount == 1. Reproduced with examples/flutter/quickstart before the fix; renders correctly after. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Windows with newer NVIDIA hardware/drivers, any Thermion app dies as soon as rendering starts:
sometimes followed by a native abort through Filament's timer-query postcondition (
vkGetQueryPoolResults error=-4). Reproduced with the unmodifiedexamples/flutter/quickstartat89c135bon:The device is lost on the first frame; the viewport stays blank (or shows the app's clear color) and the app eventually aborts.
Root cause
createLogicalDevicerequests a single queue (queueCount = 1) in the graphics family. Two independent code paths then fetch the sameVkQueue:VulkanSharedContext(graphicsQueueFamilyIndex,graphicsQueueIndex = 0), submitting from its render thread;createCommandResources(vkGetDeviceQueue(device, family, 0)), used by the D3D-interopBlit()submitting from the Flutter platform thread.Per the Vulkan spec, queue access is externally synchronized —
vkQueueSubmiton the same queue from two threads without host synchronization is invalid. Many driver generations happen to tolerate it, which is why this hasn't bitten on existing hardware; the current NVIDIA driver for Blackwell rejects the first concurrent submission withVK_ERROR_DEVICE_LOST.Fix
Request two queues from the graphics family when the hardware exposes more than one (NVIDIA exposes 16; the request is clamped to the family's
queueCount):createCommandResourcesfor the blit/command path.Both queues are in the same family, so no queue-family ownership transfers are needed and the existing barriers/fences are unchanged. On hardware exposing a single graphics queue (
queueCount == 1) the behavior is byte-for-byte the old one, so nothing regresses on platforms where the shared queue happened to work.Validation
examples/flutter/quickstartreproduces the device loss on the first frame (hardware above).[INFO] Blit/command queue: family 0, queue index 1.Happy to adjust if you'd prefer a different split (e.g. a dedicated transfer-family queue) — this is the minimal change that makes the existing design valid.
🤖 Generated with Claude Code