diff --git a/engine/src/flutter/vulkan/vulkan_application.cc b/engine/src/flutter/vulkan/vulkan_application.cc index 7ba881b843..eaba000274 100644 --- a/engine/src/flutter/vulkan/vulkan_application.cc +++ b/engine/src/flutter/vulkan/vulkan_application.cc @@ -129,6 +129,10 @@ const VulkanHandle& VulkanApplication::GetInstance() const { return instance_; } +void VulkanApplication::ReleaseInstanceOwnership() { + instance_.ReleaseOwnership(); +} + std::vector VulkanApplication::GetPhysicalDevices() const { if (!IsValid()) { return {}; diff --git a/engine/src/flutter/vulkan/vulkan_application.h b/engine/src/flutter/vulkan/vulkan_application.h index 9274701f95..a5f20c07f6 100644 --- a/engine/src/flutter/vulkan/vulkan_application.h +++ b/engine/src/flutter/vulkan/vulkan_application.h @@ -38,6 +38,8 @@ class VulkanApplication { const VulkanHandle& GetInstance() const; + void ReleaseInstanceOwnership(); + std::unique_ptr AcquireFirstCompatibleLogicalDevice() const; private: diff --git a/engine/src/flutter/vulkan/vulkan_device.cc b/engine/src/flutter/vulkan/vulkan_device.cc index 745110ed70..bb6c2e8a14 100644 --- a/engine/src/flutter/vulkan/vulkan_device.cc +++ b/engine/src/flutter/vulkan/vulkan_device.cc @@ -153,6 +153,10 @@ const VulkanHandle& VulkanDevice::GetHandle() const { return device_; } +void VulkanDevice::ReleaseDeviceOwnership() { + device_.ReleaseOwnership(); +} + const VulkanHandle& VulkanDevice::GetPhysicalDeviceHandle() const { return physical_device_; diff --git a/engine/src/flutter/vulkan/vulkan_device.h b/engine/src/flutter/vulkan/vulkan_device.h index e32f37d7ed..e9abf757f6 100644 --- a/engine/src/flutter/vulkan/vulkan_device.h +++ b/engine/src/flutter/vulkan/vulkan_device.h @@ -35,6 +35,8 @@ class VulkanDevice { uint32_t GetGraphicsQueueIndex() const; + void ReleaseDeviceOwnership(); + FXL_WARN_UNUSED_RESULT bool GetSurfaceCapabilities(const VulkanSurface& surface, VkSurfaceCapabilitiesKHR* capabilities) const; diff --git a/engine/src/flutter/vulkan/vulkan_handle.h b/engine/src/flutter/vulkan/vulkan_handle.h index 32f1f938e2..87f535e9b9 100644 --- a/engine/src/flutter/vulkan/vulkan_handle.h +++ b/engine/src/flutter/vulkan/vulkan_handle.h @@ -50,6 +50,11 @@ class VulkanHandle { operator Handle() const { return handle_; } + /// Relinquish responsibility of collecting the underlying handle when this + /// object is collected. It is the responsibility of the caller to ensure that + /// the lifetime of the handle extends past the lifetime of this object. + void ReleaseOwnership() { disposer_ = nullptr; } + void Reset() { DisposeIfNecessary(); } private: