[vlc-commits] dxva: allow blacklisting for different codecs

Steve Lhomme git at videolan.org
Mon Jun 25 17:59:03 CEST 2018


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Jun 25 15:38:29 2018 +0200| [79c56aadae985ee55851f2755a351fb8ba9ded86] | committer: Steve Lhomme

dxva: allow blacklisting for different codecs

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=79c56aadae985ee55851f2755a351fb8ba9ded86
---

 modules/codec/avcodec/d3d11va.c        |  32 +++++------
 modules/codec/avcodec/directx_va.h     |   2 +-
 modules/codec/avcodec/dxva2.c          |  26 ++++-----
 modules/codec/avcodec/dxva_blacklist.c | 102 ++++++++++++++++++++-------------
 4 files changed, 86 insertions(+), 76 deletions(-)

diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c
index 9f78f15280..95230bbe08 100644
--- a/modules/codec/avcodec/d3d11va.c
+++ b/modules/codec/avcodec/d3d11va.c
@@ -542,24 +542,8 @@ static int DxGetInputList(vlc_va_t *va, input_list_t *p_list)
     return VLC_SUCCESS;
 }
 
-extern const GUID DXVA_ModeHEVC_VLD_Main;
 extern const GUID DXVA_ModeHEVC_VLD_Main10;
 extern const GUID DXVA_ModeVP9_VLD_10bit_Profile2;
-static bool CanUseIntelHEVC(vlc_va_t *va)
-{
-    vlc_va_sys_t *sys = va->sys;
-    IDXGIAdapter *pAdapter = D3D11DeviceAdapter(sys->d3d_dev.d3ddevice);
-    if (!pAdapter)
-        return false;
-
-    DXGI_ADAPTER_DESC adapterDesc;
-    HRESULT hr = IDXGIAdapter_GetDesc(pAdapter, &adapterDesc);
-    IDXGIAdapter_Release(pAdapter);
-    if (FAILED(hr))
-        return false;
-
-    return directx_va_canUseHevc( va, adapterDesc.VendorId, adapterDesc.DeviceId );
-}
 
 static int DxSetupOutput(vlc_va_t *va, const GUID *input, const video_format_t *fmt)
 {
@@ -576,9 +560,21 @@ static int DxSetupOutput(vlc_va_t *va, const GUID *input, const video_format_t *
     }
 #endif
 
-    if ((IsEqualGUID(input,&DXVA_ModeHEVC_VLD_Main) ||
-         IsEqualGUID(input,&DXVA_ModeHEVC_VLD_Main10)) && !CanUseIntelHEVC(va))
+    IDXGIAdapter *pAdapter = D3D11DeviceAdapter(sys->d3d_dev.d3ddevice);
+    if (!pAdapter)
+        return VLC_EGENERIC;
+
+    DXGI_ADAPTER_DESC adapterDesc;
+    hr = IDXGIAdapter_GetDesc(pAdapter, &adapterDesc);
+    IDXGIAdapter_Release(pAdapter);
+    if (FAILED(hr))
+        return VLC_EGENERIC;
+
+    if (!directx_va_canUseDecoder(va, adapterDesc.VendorId, adapterDesc.DeviceId, input))
+    {
+        msg_Warn(va, "GPU blacklisted for %s codec", directx_va_GetDecoderName(input));
         return VLC_EGENERIC;
+    }
 
     DXGI_FORMAT processorInput[5];
     int idx = 0;
diff --git a/modules/codec/avcodec/directx_va.h b/modules/codec/avcodec/directx_va.h
index 635d8e6eb6..5e72f2188a 100644
--- a/modules/codec/avcodec/directx_va.h
+++ b/modules/codec/avcodec/directx_va.h
@@ -82,6 +82,6 @@ int directx_va_Open(vlc_va_t *, directx_sys_t *);
 void directx_va_Close(vlc_va_t *, directx_sys_t *);
 int directx_va_Setup(vlc_va_t *, directx_sys_t *, const AVCodecContext *avctx, const es_format_t *, int flag_xbox);
 char *directx_va_GetDecoderName(const GUID *guid);
-bool directx_va_canUseHevc(vlc_va_t *, UINT VendorId, UINT DeviceId);
+bool directx_va_canUseDecoder(vlc_va_t *, UINT VendorId, UINT DeviceId, const GUID *pCodec);
 
 #endif /* AVCODEC_DIRECTX_VA_H */
diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c
index 2c0b5940c5..e410f54097 100644
--- a/modules/codec/avcodec/dxva2.c
+++ b/modules/codec/avcodec/dxva2.c
@@ -495,32 +495,26 @@ static int DxGetInputList(vlc_va_t *va, input_list_t *p_list)
     return VLC_SUCCESS;
 }
 
-extern const GUID DXVA_ModeHEVC_VLD_Main;
-extern const GUID DXVA_ModeHEVC_VLD_Main10;
-static bool CanUseIntelHEVC(vlc_va_t *va)
+static int DxSetupOutput(vlc_va_t *va, const GUID *input, const video_format_t *fmt)
 {
+    VLC_UNUSED(fmt);
     vlc_va_sys_t *sys = va->sys;
 
     D3DADAPTER_IDENTIFIER9 identifier;
     HRESULT hr = IDirect3D9_GetAdapterIdentifier(sys->hd3d.obj, sys->d3d_dev.adapterId, 0, &identifier);
     if (FAILED(hr))
-        return false;
-
-    return directx_va_canUseHevc( va, identifier.VendorId, identifier.DeviceId );
-}
-
-static int DxSetupOutput(vlc_va_t *va, const GUID *input, const video_format_t *fmt)
-{
-    VLC_UNUSED(fmt);
+        return VLC_EGENERIC;
 
-    if ((IsEqualGUID(input,&DXVA_ModeHEVC_VLD_Main) ||
-         IsEqualGUID(input,&DXVA_ModeHEVC_VLD_Main10)) && !CanUseIntelHEVC(va))
+    if (!directx_va_canUseDecoder(va, identifier.VendorId, identifier.DeviceId, input))
+    {
+        msg_Warn(va, "GPU blacklisted for %s codec", directx_va_GetDecoderName(input));
         return VLC_EGENERIC;
+    }
 
     int err = VLC_EGENERIC;
     UINT      output_count = 0;
     D3DFORMAT *output_list = NULL;
-    if (FAILED(IDirectXVideoDecoderService_GetDecoderRenderTargets(va->sys->dx_sys.d3ddec,
+    if (FAILED(IDirectXVideoDecoderService_GetDecoderRenderTargets(sys->dx_sys.d3ddec,
                                                                    input,
                                                                    &output_count,
                                                                    &output_list))) {
@@ -551,12 +545,12 @@ static int DxSetupOutput(vlc_va_t *va, const GUID *input, const video_format_t *
             }
             if (!is_supported)
                 continue;
-            if (pass == 0 && format->format != va->sys->render)
+            if (pass == 0 && format->format != sys->render)
                 continue;
 
             /* We have our solution */
             msg_Dbg(va, "Using decoder output '%s'", format->name);
-            va->sys->render = format->format;
+            sys->render = format->format;
             err = VLC_SUCCESS;
             break;
         }
diff --git a/modules/codec/avcodec/dxva_blacklist.c b/modules/codec/avcodec/dxva_blacklist.c
index fb5e6c6b89..159c44b573 100644
--- a/modules/codec/avcodec/dxva_blacklist.c
+++ b/modules/codec/avcodec/dxva_blacklist.c
@@ -40,62 +40,82 @@ typedef struct
 
 #include "directx_va.h"
 
-static UINT IntelDevices[] = {
+extern const GUID DXVA_ModeHEVC_VLD_Main;
+extern const GUID DXVA_ModeHEVC_VLD_Main10;
+
+struct decoders {
+    const UINT deviceID;
+    const GUID **decoder_list;
+};
+
+static const GUID *NoHEVC[] = {
+    &DXVA_ModeHEVC_VLD_Main,
+    &DXVA_ModeHEVC_VLD_Main10,
+    NULL,
+};
+
+static struct decoders IntelDevices[] = {
     /* Intel Broadwell GPUs with hybrid HEVC */
-    0x1606, /* HD Graphics */
-    0x160E, /* HD Graphics */
-    0x1612, /* HD Graphics 5600 */
-    0x1616, /* HD Graphics 5500 */
-    0x161A, /* HD Graphics P5700 */
-    0x161E, /* HD Graphics 5300 */
-    0x1622, /* Iris Pro Graphics 6200 */
-    0x1626, /* HD Graphics 6000 */
-    0x162A, /* Iris Pro Graphics P6300 */
-    0x162B, /* Iris Graphics 6100 */
-
-    0x0402, /* HD Graphics */
-    0x0406, /* HD Graphics */
-    0x040A, /* HD Graphics */
-    0x0412, /* HD Graphics 4600 */
-    0x0416, /* HD Graphics 4600 */
-    0x041E, /* HD Graphics 4400 */
-    0x041A, /* HD Graphics P4600/P4700 */
-
-    0x0A06, /* HD Graphics */
-    0x0A0E, /* HD Graphics */
-    0x0A16, /* HD Graphics Family */
-    0x0A1E, /* HD Graphics Family */
-    0x0A26, /* HD Graphics 5000 */
-    0x0A2E, /* Iris(TM) Graphics 5100 */
-
-    0x0D22, /* Iris(TM) Pro Graphics 5200 */
-    0x0D26, /* Iris(TM) Pro Graphics 5200 */
-    0
+    { 0x1606, NoHEVC }, /* HD Graphics */
+    { 0x160E, NoHEVC }, /* HD Graphics */
+    { 0x1612, NoHEVC }, /* HD Graphics 5600 */
+    { 0x1616, NoHEVC }, /* HD Graphics 5500 */
+    { 0x161A, NoHEVC }, /* HD Graphics P5700 */
+    { 0x161E, NoHEVC }, /* HD Graphics 5300 */
+    { 0x1622, NoHEVC }, /* Iris Pro Graphics 6200 */
+    { 0x1626, NoHEVC }, /* HD Graphics 6000 */
+    { 0x162A, NoHEVC }, /* Iris Pro Graphics P6300 */
+    { 0x162B, NoHEVC }, /* Iris Graphics 6100 */
+
+    { 0x0402, NoHEVC }, /* HD Graphics */
+    { 0x0406, NoHEVC }, /* HD Graphics */
+    { 0x040A, NoHEVC }, /* HD Graphics */
+    { 0x0412, NoHEVC }, /* HD Graphics 4600 */
+    { 0x0416, NoHEVC }, /* HD Graphics 4600 */
+    { 0x041E, NoHEVC }, /* HD Graphics 4400 */
+    { 0x041A, NoHEVC }, /* HD Graphics P4600/P4700 */
+
+    { 0x0A06, NoHEVC }, /* HD Graphics */
+    { 0x0A0E, NoHEVC }, /* HD Graphics */
+    { 0x0A16, NoHEVC }, /* HD Graphics Family */
+    { 0x0A1E, NoHEVC }, /* HD Graphics Family */
+    { 0x0A26, NoHEVC }, /* HD Graphics 5000 */
+    { 0x0A2E, NoHEVC }, /* Iris(TM) Graphics 5100 */
+
+    { 0x0D22, NoHEVC }, /* Iris(TM) Pro Graphics 5200 */
+    { 0x0D26, NoHEVC }, /* Iris(TM) Pro Graphics 5200 */
+    {0, NULL}
 };
 
 static struct {
-    UINT vendor;
-    const UINT *devices;
-} hevc_blacklist[] = {
+    const UINT vendor;
+    const struct decoders *devices;
+} gpu_blacklist[] = {
     { .vendor = GPU_MANUFACTURER_INTEL, .devices = IntelDevices },
 };
 
-bool directx_va_canUseHevc(vlc_va_t *va, UINT VendorId, UINT DeviceId)
+bool directx_va_canUseDecoder(vlc_va_t *va, UINT VendorId, UINT DeviceId, const GUID *pCodec)
 {
     if (va->obj.force)
         return true;
 
-    for (size_t i=0; i<ARRAY_SIZE(hevc_blacklist); i++)
+    for (size_t i=0; i<ARRAY_SIZE(gpu_blacklist); i++)
     {
-        if (hevc_blacklist[i].vendor == VendorId)
+        if (gpu_blacklist[i].vendor == VendorId)
         {
-            const UINT *pDevice = hevc_blacklist[i].devices;
-            while (*pDevice != 0)
+            const struct decoders *pDevice = gpu_blacklist[i].devices;
+            while (pDevice->deviceID != 0)
             {
-                if (*pDevice == DeviceId)
+                if (pDevice->deviceID == DeviceId)
                 {
-                    msg_Warn(va, "Intel Hybrid HEVC detected, disabling hardware decoding");
-                    return false;
+                    const GUID **pGuid = pDevice->decoder_list;
+                    while (*pGuid != NULL)
+                    {
+                        if (IsEqualGUID(pCodec, *pGuid))
+                            return false;
+                        pGuid++;
+                    }
+                    return true;
                 }
                 pDevice++;
             }



More information about the vlc-commits mailing list