From 339c81bac8bf5a92762a5071134edb1df71d0590 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Tue, 18 Jun 2024 00:33:37 +0900 Subject: [PATCH] d3d12: Promote decoder and videosink rank to primary It's proven that d3d12 performs better than d3d11 while consumes less resources in various cases. Assign primary+ rank to decoder and videosink in case of Windows10/11, so that it can be tested widely Part-of: --- .../sys/d3d12/gstd3d12pluginutils.cpp | 11 ++++++++ .../sys/d3d12/gstd3d12pluginutils.h | 2 ++ .../gst-plugins-bad/sys/d3d12/plugin.cpp | 26 ++++++++++++++----- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12pluginutils.cpp b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12pluginutils.cpp index b0ad739845..ef746f7846 100644 --- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12pluginutils.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12pluginutils.cpp @@ -143,3 +143,14 @@ gst_d3d12_need_transform (gfloat rotation_x, gfloat rotation_y, return FALSE; } + +gboolean +gst_d3d12_is_windows_10_or_greater (void) +{ + static gboolean ret = FALSE; + GST_D3D12_CALL_ONCE_BEGIN { + ret = g_win32_check_windows_version (10, 0, 0, G_WIN32_OS_ANY); + } GST_D3D12_CALL_ONCE_END; + + return ret; +} diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12pluginutils.h b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12pluginutils.h index 88bcb7e925..2dfb6fd7a5 100644 --- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12pluginutils.h +++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12pluginutils.h @@ -58,4 +58,6 @@ gboolean gst_d3d12_need_transform (gfloat rotation_x, gfloat scale_x, gfloat scale_y); +gboolean gst_d3d12_is_windows_10_or_greater (void); + G_END_DECLS diff --git a/subprojects/gst-plugins-bad/sys/d3d12/plugin.cpp b/subprojects/gst-plugins-bad/sys/d3d12/plugin.cpp index db6d06a2ac..f2941ed731 100644 --- a/subprojects/gst-plugins-bad/sys/d3d12/plugin.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d12/plugin.cpp @@ -72,6 +72,13 @@ plugin_init (GstPlugin * plugin) return TRUE; } + guint sink_rank = GST_RANK_NONE; + guint decoder_rank = GST_RANK_NONE; + bool have_video_device = false; + + if (gst_d3d12_is_windows_10_or_greater ()) + decoder_rank = GST_RANK_PRIMARY + 2; + /* Enumerate devices to register decoders per device and to get the highest * feature level */ /* AMD seems to be supporting up to 12 cards, and 8 for NVIDIA */ @@ -93,18 +100,20 @@ plugin_init (GstPlugin * plugin) continue; } + have_video_device = true; + gst_d3d12_mpeg2_dec_register (plugin, device, video_device.Get (), - GST_RANK_NONE); + decoder_rank); gst_d3d12_h264_dec_register (plugin, device, video_device.Get (), - GST_RANK_NONE); + decoder_rank); gst_d3d12_h265_dec_register (plugin, device, video_device.Get (), - GST_RANK_NONE); + decoder_rank); gst_d3d12_vp8_dec_register (plugin, device, video_device.Get (), - GST_RANK_NONE); + decoder_rank); gst_d3d12_vp9_dec_register (plugin, device, video_device.Get (), - GST_RANK_NONE); + decoder_rank); gst_d3d12_av1_dec_register (plugin, device, video_device.Get (), - GST_RANK_NONE); + decoder_rank); gst_d3d12_h264_enc_register (plugin, device, video_device.Get (), GST_RANK_NONE); @@ -112,6 +121,9 @@ plugin_init (GstPlugin * plugin) gst_object_unref (device); } + if (gst_d3d12_is_windows_10_or_greater () && have_video_device) + sink_rank = GST_RANK_PRIMARY + 1; + gst_element_register (plugin, "d3d12convert", GST_RANK_NONE, GST_TYPE_D3D12_CONVERT); gst_element_register (plugin, @@ -119,7 +131,7 @@ plugin_init (GstPlugin * plugin) gst_element_register (plugin, "d3d12upload", GST_RANK_NONE, GST_TYPE_D3D12_UPLOAD); gst_element_register (plugin, - "d3d12videosink", GST_RANK_NONE, GST_TYPE_D3D12_VIDEO_SINK); + "d3d12videosink", sink_rank, GST_TYPE_D3D12_VIDEO_SINK); gst_element_register (plugin, "d3d12testsrc", GST_RANK_NONE, GST_TYPE_D3D12_TEST_SRC); gst_element_register (plugin,