diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12device.cpp b/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12device.cpp index 0cc0323dc4..29ef109e37 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12device.cpp +++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12device.cpp @@ -367,20 +367,6 @@ public: return device; } - void ReleaseDevice (gint64 luid) - { - std::lock_guard lk (lock_); - for (const auto & it : list_) { - if (it->adapter_luid == luid) { - if (it.use_count () == 1) { - it->Drain (); - it->ReportLiveObjects (); - } - return; - } - } - } - void OnDeviceRemoved (gint64 luid) { std::lock_guard lk (lock_); @@ -498,6 +484,15 @@ public: } } + void FlushAll () + { + std::lock_guard lk (lock_); + for (const auto & it : list_) { + it->Drain (); + it->ReportLiveObjects (); + } + } + private: DeviceCacheManager () {} ~DeviceCacheManager () {} @@ -729,15 +724,8 @@ gst_d3d12_device_finalize (GObject * object) GST_DEBUG_OBJECT (self, "Finalize"); - gint64 luid = 0; - if (self->priv->inner) - luid = self->priv->inner->adapter_luid; - delete self->priv; - auto manager = DeviceCacheManager::GetInstance (); - manager->ReleaseDevice (luid); - G_OBJECT_CLASS (parent_class)->finalize (object); } @@ -2241,3 +2229,17 @@ gst_d3d12_device_non_zeroed_supported (GstD3D12Device * device) return device->priv->inner->non_zeroed_supported; } + +/** + * gst_d3d12_flush_all_devices: + * + * Flushes all devices and waits for completion of all scheduled GPU tasks + * + * Since: 1.26 + */ +void +gst_d3d12_flush_all_devices (void) +{ + auto manager = DeviceCacheManager::GetInstance (); + manager->FlushAll (); +} diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12utils.h b/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12utils.h index 7bb988e2af..5c151da172 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12utils.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12utils.h @@ -78,6 +78,10 @@ gboolean gst_d3d12_get_copyable_footprints (GstD3D12Device * device, D3D12_PLACED_SUBRESOURCE_FOOTPRINT layout[GST_VIDEO_MAX_PLANES], guint64 * size); + +GST_D3D12_API +void gst_d3d12_flush_all_devices (void); + GST_D3D12_API gboolean _gst_d3d12_result (HRESULT hr, GstD3D12Device * device, diff --git a/subprojects/gst-plugins-bad/sys/d3d12/plugin.cpp b/subprojects/gst-plugins-bad/sys/d3d12/plugin.cpp index 1e539ce1da..475ab6cd7d 100644 --- a/subprojects/gst-plugins-bad/sys/d3d12/plugin.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d12/plugin.cpp @@ -73,6 +73,7 @@ static void plugin_deinit (gpointer data) { gst_d3d12_ipc_client_deinit (); + gst_d3d12_flush_all_devices (); } static gboolean