Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to Prevent VkDevice Destruction on minimize in QVulkanWindow?
Forum Updated to NodeBB v4.3 + New Features

How to Prevent VkDevice Destruction on minimize in QVulkanWindow?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 312 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    decastyle
    wrote on last edited by
    #1

    Problem:
    I’m building a progressive ray tracer with renderer using QVulkanWindow and a custom QVulkanWindowRenderer. 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 by QVulkanWindow) 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 using vkCmdCopyImage 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 invalid VkDeviceMemory handles) when the window is maximized, suggesting the VkDevice is recreated by QVulkanWindow.
    • 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 breaks vkCmdCopyImage (different devices), requiring host-staged transfers, which I’d like to avoid for performance.

    Question:
    How can I override or customize QVulkanWindow’s VkDevice 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!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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 ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • D Offline
        D Offline
        decastyle
        wrote on last edited by
        #3

        Thank you a lot! I overlooked this flag initially.

        For anyone else encountering this issue, just add this after Vulkan window creation

        vulkanWindow->setFlags(QVulkanWindow::PersistentResources);
        
        1 Reply Last reply
        1
        • D decastyle has marked this topic as solved on

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved