[vlc-devel] [PATCH] direct3d9: add an option to use DXVA-HD rather than StretchRect by default

Steve Lhomme robux4 at ycbcr.xyz
Fri Mar 13 10:29:32 CET 2020


The driver may lie about its conversion capabilities (like Y410 to X8R8G8B8 on
Intel) when DXVA-HD works correctly. So we use this option by default.
---
 modules/video_output/win32/direct3d9.c | 34 ++++++++++++++++----------
 1 file changed, 21 insertions(+), 13 deletions(-)

diff --git a/modules/video_output/win32/direct3d9.c b/modules/video_output/win32/direct3d9.c
index 06f1ab22bb6..5954fa4012b 100644
--- a/modules/video_output/win32/direct3d9.c
+++ b/modules/video_output/win32/direct3d9.c
@@ -96,6 +96,9 @@ static void GLConvClose(vlc_object_t *);
 /* The latest option in the selection list: used for loading a shader file. */
 #define SELECTED_SHADER_FILE N_("HLSL File")
 
+#define DXVAHD_TEXT N_("Use DXVA-HD conversion")
+#define DXVAHD_LONGTEXT N_("Use DXVA-HD to render pictures instead of legacy StrecthRect.")
+
 #define D3D9_HELP N_("Recommended video output for Windows Vista and later versions")
 
 vlc_module_begin ()
@@ -112,6 +115,8 @@ vlc_module_begin ()
     add_loadfile("direct3d9-shader-file", NULL,
                  PIXEL_SHADER_FILE_TEXT, PIXEL_SHADER_FILE_LONGTEXT)
 
+    add_bool("direct3d9-dxvahd", true, DXVAHD_TEXT, DXVAHD_LONGTEXT, true)
+
     add_shortcut("direct3d9", "direct3d")
     set_callback_display(Open, 280)
 
@@ -1638,20 +1643,9 @@ static int Direct3D9Open(vout_display_t *vd, video_format_t *fmt, vlc_video_cont
         msg_Err(vd, "unsupported source pixel format %4.4s", &vd->source.i_chroma);
         goto error;
     }
-    msg_Dbg(vd, "found input surface format %s", d3dfmt->name);
-
-    bool force_dxva_hd = false;
-    // test whether device can perform color-conversion from that format to target format
-    HRESULT hr = IDirect3D9_CheckDeviceFormatConversion(sys->d3d9_device->hd3d.obj,
-                                                sys->d3d9_device->d3ddev.adapterId,
-                                                D3DDEVTYPE_HAL,
-                                                d3dfmt->format, sys->BufferFormat);
-    if (FAILED(hr))
-    {
-        msg_Dbg(vd, "Unsupported conversion trying with DXVA-HD");
-        force_dxva_hd = true;
-    }
+    msg_Dbg(vd, "found input surface format %s for source %4.4s", d3dfmt->name, (const char *)&vd->source.i_chroma);
 
+    bool force_dxva_hd = var_InheritBool(vd, "direct3d9-dxvahd");
     if (force_dxva_hd || (dst_format && vd->source.color_range != COLOR_RANGE_FULL && dst_format->rmask && !d3dfmt->rmask &&
                           sys->d3d9_device->d3ddev.identifier.VendorId == GPU_MANUFACTURER_NVIDIA))
     {
@@ -1659,7 +1653,21 @@ static int Direct3D9Open(vout_display_t *vd, video_format_t *fmt, vlc_video_cont
         msg_Dbg(vd, "init DXVA-HD processor from %s to %s", d3dfmt->name, dst_format?dst_format->name:"unknown");
         int err = InitRangeProcessor( vd, d3dfmt, &render_out );
         if (err != VLC_SUCCESS)
+            force_dxva_hd = false;
+    }
+    if (!force_dxva_hd)
+    {
+        // test whether device can perform color-conversion from that format to target format
+        HRESULT hr = IDirect3D9_CheckDeviceFormatConversion(sys->d3d9_device->hd3d.obj,
+                                                    sys->d3d9_device->d3ddev.adapterId,
+                                                    D3DDEVTYPE_HAL,
+                                                    d3dfmt->format, sys->BufferFormat);
+        if (FAILED(hr))
+        {
+            msg_Dbg(vd, "Unsupported conversion from %s to %s", d3dfmt->name, dst_format?dst_format->name:"unknown" );
             goto error;
+        }
+        msg_Dbg(vd, "using StrecthRect from %s to %s", d3dfmt->name, dst_format?dst_format->name:"unknown" );
     }
 
     /* */
-- 
2.17.1



More information about the vlc-devel mailing list