How to Prevent VkDevice Destruction on minimize in QVulkanWindow?
-
Problem:
I’m building a progressive ray tracer with renderer usingQVulkanWindow
and a customQVulkanWindowRenderer
. My ray tracer dispatches compute pipeline (vkCmdDispatch
) to an output image, which I copy to a renderer-owned texture (renderImage
) for display on a full-screen quad after each sample. This works fine when the window is visible. However, when I minimize the window, releaseResources() is called, and the VkDevice (managed byQVulkanWindow
) is destroyed (or becomes invalid), breaking compute loop in the background. I want the VkDevice to persist across minimization so ray tracing can continue and update the display when the window is restored.Details:
- Setup: The renderer copies the compute output to
renderImage
usingvkCmdCopyImage
and renders it with a graphics pipeline - Current Behavior: On minimize,
releaseResources()
triggers, and if I clean up the compute pipeline there, background dispatching stops. If I don’t clean it up, I risk validation errors or crashes (e.g.,vkFreeMemory
on invalidVkDeviceMemory
handles) when the window is maximized, suggesting theVkDevice
is recreated byQVulkanWindow
. - Goal: prevent destruction of
VkDevice
when minimized, so I can dispatch compute work in a background thread and resume rendering seamlessly on maximize.
What I’ve Tried:
- Moving resource cleanup to
releaseResources()
stops background work. - Using a separate
VkDevice
for compute avoids this but breaksvkCmdCopyImage
(different devices), requiring host-staged transfers, which I’d like to avoid for performance.
Question:
How can I override or customizeQVulkanWindow
’sVkDevice
destruction logic to keep it alive during minimization? Is there a way to manage the device lifecycle? Alternatively, how can I detect and recover from device recreation without disrupting persistent compute resources?Context:
- Qt 6.8.1, Windows, NVIDIA GPU.
- Vulkan 1.3 (Vulkan SDK 1.4.304.0).
Any guidance or examples would be appreciated!
- Setup: The renderer copies the compute output to
-
Hi,
It's a bit a shot in the dark since I haven't used that class yet but would the PersistentResources flag do what you want ?
-