diff --git a/source/blender/gpu/vulkan/vk_context.hh b/source/blender/gpu/vulkan/vk_context.hh index 2cdf733a3cc..2a16c314ca7 100644 --- a/source/blender/gpu/vulkan/vk_context.hh +++ b/source/blender/gpu/vulkan/vk_context.hh @@ -27,6 +27,7 @@ class VKBatch; class VKStateManager; class VKShader; class VKThreadData; +class VKDevice; enum RenderGraphFlushFlags { NONE = 0, @@ -37,6 +38,8 @@ enum RenderGraphFlushFlags { ENUM_OPERATORS(RenderGraphFlushFlags, RenderGraphFlushFlags::WAIT_FOR_COMPLETION); class VKContext : public Context, NonCopyable { + friend class VKDevice; + private: VkExtent2D vk_extent_ = {}; VkSurfaceFormatKHR swap_chain_format_ = {}; diff --git a/source/blender/gpu/vulkan/vk_device.cc b/source/blender/gpu/vulkan/vk_device.cc index f9c431325d3..154a2e28679 100644 --- a/source/blender/gpu/vulkan/vk_device.cc +++ b/source/blender/gpu/vulkan/vk_device.cc @@ -464,6 +464,14 @@ void VKDevice::context_register(VKContext &context) void VKDevice::context_unregister(VKContext &context) { + if (context.render_graph_.has_value()) { + render_graph::VKRenderGraph &render_graph = context.render_graph(); + context.render_graph_.reset(); + BLI_assert_msg(render_graph.is_empty(), + "Unregistering a context that still has an unsubmitted render graph."); + render_graph.reset(); + BLI_thread_queue_push(unused_render_graphs_, &render_graph); + } orphaned_data.move_data(context.discard_pool, timeline_value_ + 1); contexts_.remove(contexts_.first_index_of(std::reference_wrapper(context))); }