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

Steve Lhomme robux4 at ycbcr.xyz
Wed Mar 18 15:05:21 CET 2020


They don't really share a header but I'll put it in d3d9_fmt.h

On 2020-03-18 14:38, Jean-Baptiste Kempf wrote:
> I don't see why you don't use the same string for both.
> 
> And then, LGTM.
> 
> On Wed, Mar 18, 2020, at 11:42, Steve Lhomme wrote:
>> 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/opengl/interop_dxva2.c | 15 ++++++---
>>   modules/video_output/win32/direct3d9.c      | 34 +++++++++++++--------
>>   2 files changed, 31 insertions(+), 18 deletions(-)
>>
>> diff --git a/modules/video_output/opengl/interop_dxva2.c
>> b/modules/video_output/opengl/interop_dxva2.c
>> index 9da5b7be468..9321c2eb55b 100644
>> --- a/modules/video_output/opengl/interop_dxva2.c
>> +++ b/modules/video_output/opengl/interop_dxva2.c
>> @@ -59,6 +59,9 @@
>>   static int  GLConvOpen(vlc_object_t *);
>>   static void GLConvClose(vlc_object_t *);
>>   
>> +#define DXVAHD_TEXT N_("Use DXVA-HD conversion")
>> +#define DXVAHD_LONGTEXT N_("Use DXVA-HD for color conversion.")
>> +
>>   vlc_module_begin ()
>>       set_shortname("dxva2")
>>       set_category(CAT_VIDEO)
>> @@ -66,6 +69,8 @@ vlc_module_begin ()
>>       set_description("DXVA2 surface converter")
>>       set_capability("glinterop", 1)
>>       set_callbacks(GLConvOpen, GLConvClose)
>> +
>> +    add_bool("direct3d9-dxvahd", true, DXVAHD_TEXT, DXVAHD_LONGTEXT, true)
>>   vlc_module_end ()
>>   
>>   struct wgl_vt {
>> @@ -453,15 +458,15 @@ GLConvOpen(vlc_object_t *obj)
>>       priv->vt = vt;
>>   
>>       HRESULT hr;
>> -    bool force_dxva_hd = false;
>> -    if ( interop->fmt.color_range != COLOR_RANGE_FULL &&
>> -         d3d9_decoder->d3ddev.identifier.VendorId ==
>> GPU_MANUFACTURER_NVIDIA )
>> +    bool force_dxva_hd = var_InheritBool(interop, "direct3d9-dxvahd");
>> +    if (force_dxva_hd || (interop->fmt.color_range != COLOR_RANGE_FULL
>> &&
>> +                          d3d9_decoder->d3ddev.identifier.VendorId ==
>> GPU_MANUFACTURER_NVIDIA))
>>       {
>>           // NVIDIA bug, YUV to RGB internal conversion in StretchRect
>> always converts from limited to limited range
>>           msg_Dbg(interop->gl, "init DXVA-HD processor from %4.4s to
>> RGB", (const char*)&vctx_sys->format);
>>           int err = InitRangeProcessor(interop,
>> d3d9_decoder->d3ddev.devex, vctx_sys->format);
>> -        if (err == VLC_SUCCESS)
>> -            force_dxva_hd = true;
>> +        if (err != VLC_SUCCESS)
>> +            force_dxva_hd = false;
>>       }
>>       if (!force_dxva_hd)
>>       {
>> diff --git a/modules/video_output/win32/direct3d9.c
>> b/modules/video_output/win32/direct3d9.c
>> index b72033b170b..e5bc3b73956 100644
>> --- a/modules/video_output/win32/direct3d9.c
>> +++ b/modules/video_output/win32/direct3d9.c
>> @@ -90,6 +90,9 @@ static void Close(vout_display_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 for color conversion.")
>> +
>>   #define D3D9_HELP N_("Recommended video output for Windows Vista and
>> later versions")
>>   
>>   vlc_module_begin ()
>> @@ -106,6 +109,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)
>>   vlc_module_end ()
>> @@ -1625,20 +1630,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))
>>       {
>> @@ -1646,7 +1640,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
>>
>> _______________________________________________
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>> https://mailman.videolan.org/listinfo/vlc-devel
> 
> -- 
> Jean-Baptiste Kempf -  President
> +33 672 704 734
> 


More information about the vlc-devel mailing list