diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12basefilter.cpp b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12basefilter.cpp index 012b7a6df0..be1977b932 100644 --- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12basefilter.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12basefilter.cpp @@ -202,7 +202,7 @@ gst_d3d12_base_filter_before_transform (GstBaseTransform * trans, dmem = GST_D3D12_MEMORY_CAST (mem); /* d3d12 devices are singletons per adapter */ - if (dmem->device == self->device) + if (gst_d3d12_device_is_equal (dmem->device, self->device)) return; GST_INFO_OBJECT (self, "Updating device %" GST_PTR_FORMAT " -> %" diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12compositor.cpp b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12compositor.cpp index 8668c88ded..cd89a5f7bf 100644 --- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12compositor.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12compositor.cpp @@ -2132,7 +2132,7 @@ gst_d3d12_compositor_decide_allocation (GstAggregator * agg, GstQuery * query) gst_clear_object (&pool); } else { GstD3D12BufferPool *dpool = GST_D3D12_BUFFER_POOL (pool); - if (dpool->device != self->device) { + if (!gst_d3d12_device_is_equal (dpool->device, self->device)) { GST_DEBUG_OBJECT (self, "Different device, will create new one"); gst_clear_object (&pool); } @@ -2487,7 +2487,7 @@ gst_d3d12_compositor_check_device_update (GstElement * agg, dmem = GST_D3D12_MEMORY_CAST (mem); /* We can use existing device */ - if (dmem->device == self->device) { + if (gst_d3d12_device_is_equal (dmem->device, self->device)) { data->have_same_device = TRUE; return FALSE; } diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12convert.cpp b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12convert.cpp index f2f8d0d251..8da062f442 100644 --- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12convert.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12convert.cpp @@ -1457,7 +1457,7 @@ gst_d3d12_convert_propose_allocation (GstBaseTransform * trans, gst_clear_object (&pool); } else { auto dpool = GST_D3D12_BUFFER_POOL (pool); - if (dpool->device != filter->device) + if (!gst_d3d12_device_is_equal (dpool->device, filter->device)) gst_clear_object (&pool); } } @@ -1548,7 +1548,7 @@ gst_d3d12_convert_decide_allocation (GstBaseTransform * trans, GstQuery * query) gst_clear_object (&pool); } else { auto dpool = GST_D3D12_BUFFER_POOL (pool); - if (dpool->device != filter->device) + if (!gst_d3d12_device_is_equal (dpool->device, filter->device)) gst_clear_object (&pool); } } diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12converter.cpp b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12converter.cpp index 40b73b74e0..1d2b60d394 100644 --- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12converter.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12converter.cpp @@ -2192,7 +2192,7 @@ gst_d3d12_converter_check_needs_upload (GstD3D12Converter * self, return TRUE; auto dmem = GST_D3D12_MEMORY_CAST (mem); - if (dmem->device != self->device) + if (!gst_d3d12_device_is_equal (dmem->device, self->device)) return TRUE; auto resource = gst_d3d12_memory_get_resource_handle (dmem); diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12decoder.cpp b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12decoder.cpp index 2166473f21..f1cca40698 100644 --- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12decoder.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12decoder.cpp @@ -1420,7 +1420,7 @@ gst_d3d12_decoder_process_output (GstD3D12Decoder * self, mem = gst_buffer_peek_memory (frame->output_buffer, 0); if (gst_is_d3d12_memory (mem)) { dmem = GST_D3D12_MEMORY_CAST (mem); - if (dmem->device == self->device) { + if (gst_d3d12_device_is_equal (dmem->device, self->device)) { out_resource = gst_d3d12_memory_get_resource_handle (dmem); gst_d3d12_memory_get_subresource_index (dmem, 0, &out_subresource[0]); gst_d3d12_memory_get_subresource_index (dmem, 1, &out_subresource[1]); @@ -1791,7 +1791,7 @@ gst_d3d12_decoder_decide_allocation (GstD3D12Decoder * decoder, gst_clear_object (&pool); } else { GstD3D12BufferPool *dpool = GST_D3D12_BUFFER_POOL (pool); - if (dpool->device != decoder->device) { + if (!gst_d3d12_device_is_equal (dpool->device, decoder->device)) { GST_DEBUG_OBJECT (videodec, "Different device, will create new one"); gst_clear_object (&pool); } diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12device.cpp b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12device.cpp index e3d195e27f..38e69c72b2 100644 --- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12device.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12device.cpp @@ -1253,3 +1253,21 @@ gst_d3d12_device_clear_yuv_texture (GstD3D12Device * device, GstMemory * mem) gst_d3d12_command_allocator_unref (gst_ca); } } + +gboolean +gst_d3d12_device_is_equal (GstD3D12Device * device1, GstD3D12Device * device2) +{ + if (!device1 || !device2) + return FALSE; + + g_return_val_if_fail (GST_IS_D3D12_DEVICE (device1), FALSE); + g_return_val_if_fail (GST_IS_D3D12_DEVICE (device2), FALSE); + + if (device1 == device2) + return TRUE; + + if (device1->priv->inner == device2->priv->inner) + return TRUE; + + return FALSE; +} diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12device.h b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12device.h index 81d38c8197..32efa82faa 100644 --- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12device.h +++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12device.h @@ -119,5 +119,8 @@ void gst_d3d12_device_d3d12_debug (GstD3D12Devic const gchar * function, gint line); +gboolean gst_d3d12_device_is_equal (GstD3D12Device * device1, + GstD3D12Device * device2); + G_END_DECLS diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12encoder.cpp b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12encoder.cpp index 21358b1a55..b1189e45e2 100644 --- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12encoder.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12encoder.cpp @@ -702,7 +702,7 @@ gst_d3d12_encoder_upload_frame (GstD3D12Encoder * self, GstBuffer * buffer) auto mem = gst_buffer_peek_memory (buffer, 0); if (gst_is_d3d12_memory (mem)) { auto dmem = GST_D3D12_MEMORY_CAST (mem); - if (dmem->device == self->device) { + if (gst_d3d12_device_is_equal (dmem->device, self->device)) { GstMapInfo map_info; if (!gst_memory_map (mem, &map_info, (GstMapFlags) (GST_MAP_READ | GST_MAP_D3D12))) { diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12ipcsink.cpp b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12ipcsink.cpp index 490a3ef548..9824d4b056 100644 --- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12ipcsink.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12ipcsink.cpp @@ -515,7 +515,7 @@ gst_d3d12_ipc_upload (GstD3D12IpcSink * self, GstBuffer * buf) mem = gst_buffer_peek_memory (buf, 0); if (gst_is_d3d12_memory (mem)) { auto dmem = GST_D3D12_MEMORY_CAST (mem); - if (dmem->device == priv->device) { + if (gst_d3d12_device_is_equal (dmem->device, priv->device)) { D3D12_RESOURCE_DESC desc; D3D12_HEAP_FLAGS heap_flags = D3D12_HEAP_FLAG_NONE; @@ -575,7 +575,7 @@ gst_d3d12_ipc_sink_ensure_server (GstD3D12IpcSink * self, GstBuffer * buffer) mem = gst_buffer_peek_memory (buffer, 0); if (gst_is_d3d12_memory (mem)) { GstD3D12Memory *dmem = GST_D3D12_MEMORY_CAST (mem); - if (dmem->device != priv->device) { + if (!gst_d3d12_device_is_equal (dmem->device, priv->device)) { g_object_get (dmem->device, "adapter-luid", &adapter_luid, nullptr); gst_object_unref (priv->device); priv->device = (GstD3D12Device *) gst_object_ref (dmem->device); diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12pluginutils.cpp b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12pluginutils.cpp index 92641d2b5f..ccd795aae3 100644 --- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12pluginutils.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12pluginutils.cpp @@ -221,7 +221,7 @@ gst_d3d12_buffer_copy_into (GstBuffer * dst, GstBuffer * src, auto src_dmem = GST_D3D12_MEMORY_CAST (src_mem); device = dst_dmem->device; - if (device != src_dmem->device) { + if (!gst_d3d12_device_is_equal (device, src_dmem->device)) { GST_LOG ("different device, perform fallback copy"); return gst_d3d12_buffer_copy_into_fallback (dst, src, info); } diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12screencapturesrc.cpp b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12screencapturesrc.cpp index f1a7e72c8b..6698ad2375 100644 --- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12screencapturesrc.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12screencapturesrc.cpp @@ -751,7 +751,7 @@ gst_d3d12_screen_capture_src_decide_allocation (GstBaseSrc * bsrc, gst_clear_object (&pool); } else { auto dpool = GST_D3D12_BUFFER_POOL (pool); - if (dpool->device != self->device) + if (!gst_d3d12_device_is_equal (dpool->device, self->device)) gst_clear_object (&pool); } } diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12testsrc.cpp b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12testsrc.cpp index 0f5c285444..3335411e55 100644 --- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12testsrc.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12testsrc.cpp @@ -1814,7 +1814,7 @@ gst_d3d12_test_src_decide_allocation (GstBaseSrc * bsrc, GstQuery * query) gst_clear_object (&pool); } else { GstD3D12BufferPool *dpool = GST_D3D12_BUFFER_POOL (pool); - if (dpool->device != self->device) + if (!gst_d3d12_device_is_equal (dpool->device, self->device)) gst_clear_object (&pool); } } diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12videosink.cpp b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12videosink.cpp index 13d6e1c621..b6d0b05468 100644 --- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12videosink.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12videosink.cpp @@ -1025,7 +1025,7 @@ gst_d3d12_video_sink_check_device_update (GstD3D12VideoSink * self, return; auto dmem = GST_D3D12_MEMORY_CAST (mem); - if (dmem->device == self->device) + if (gst_d3d12_device_is_equal (dmem->device, self->device)) return; GST_INFO_OBJECT (self, "Updating device %" GST_PTR_FORMAT " -> %" diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12window.cpp b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12window.cpp index e79ac83b1a..47573e03d2 100644 --- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12window.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12window.cpp @@ -1232,7 +1232,7 @@ gst_d3d12_window_prepare (GstD3D12Window * window, GstD3D12Device * device, std::unique_lock < std::recursive_mutex > lk (priv->lock); HRESULT hr; - if (window->device != device) { + if (!gst_d3d12_device_is_equal (window->device, device)) { priv->ctx = nullptr; gst_clear_object (&window->device); window->device = (GstD3D12Device *) gst_object_ref (device);