Commit 79c56aad authored by Steve Lhomme's avatar Steve Lhomme

dxva: allow blacklisting for different codecs

parent 9daba7a1
...@@ -542,24 +542,8 @@ static int DxGetInputList(vlc_va_t *va, input_list_t *p_list) ...@@ -542,24 +542,8 @@ static int DxGetInputList(vlc_va_t *va, input_list_t *p_list)
return VLC_SUCCESS; return VLC_SUCCESS;
} }
extern const GUID DXVA_ModeHEVC_VLD_Main;
extern const GUID DXVA_ModeHEVC_VLD_Main10; extern const GUID DXVA_ModeHEVC_VLD_Main10;
extern const GUID DXVA_ModeVP9_VLD_10bit_Profile2; 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) 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 * ...@@ -576,9 +560,21 @@ static int DxSetupOutput(vlc_va_t *va, const GUID *input, const video_format_t *
} }
#endif #endif
if ((IsEqualGUID(input,&DXVA_ModeHEVC_VLD_Main) || IDXGIAdapter *pAdapter = D3D11DeviceAdapter(sys->d3d_dev.d3ddevice);
IsEqualGUID(input,&DXVA_ModeHEVC_VLD_Main10)) && !CanUseIntelHEVC(va)) 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; return VLC_EGENERIC;
}
DXGI_FORMAT processorInput[5]; DXGI_FORMAT processorInput[5];
int idx = 0; int idx = 0;
......
...@@ -82,6 +82,6 @@ int directx_va_Open(vlc_va_t *, directx_sys_t *); ...@@ -82,6 +82,6 @@ int directx_va_Open(vlc_va_t *, directx_sys_t *);
void directx_va_Close(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); 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); 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 */ #endif /* AVCODEC_DIRECTX_VA_H */
...@@ -495,32 +495,26 @@ static int DxGetInputList(vlc_va_t *va, input_list_t *p_list) ...@@ -495,32 +495,26 @@ static int DxGetInputList(vlc_va_t *va, input_list_t *p_list)
return VLC_SUCCESS; return VLC_SUCCESS;
} }
extern const GUID DXVA_ModeHEVC_VLD_Main; static int DxSetupOutput(vlc_va_t *va, const GUID *input, const video_format_t *fmt)
extern const GUID DXVA_ModeHEVC_VLD_Main10;
static bool CanUseIntelHEVC(vlc_va_t *va)
{ {
VLC_UNUSED(fmt);
vlc_va_sys_t *sys = va->sys; vlc_va_sys_t *sys = va->sys;
D3DADAPTER_IDENTIFIER9 identifier; D3DADAPTER_IDENTIFIER9 identifier;
HRESULT hr = IDirect3D9_GetAdapterIdentifier(sys->hd3d.obj, sys->d3d_dev.adapterId, 0, &identifier); HRESULT hr = IDirect3D9_GetAdapterIdentifier(sys->hd3d.obj, sys->d3d_dev.adapterId, 0, &identifier);
if (FAILED(hr)) if (FAILED(hr))
return false; return VLC_EGENERIC;
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);
if ((IsEqualGUID(input,&DXVA_ModeHEVC_VLD_Main) || if (!directx_va_canUseDecoder(va, identifier.VendorId, identifier.DeviceId, input))
IsEqualGUID(input,&DXVA_ModeHEVC_VLD_Main10)) && !CanUseIntelHEVC(va)) {
msg_Warn(va, "GPU blacklisted for %s codec", directx_va_GetDecoderName(input));
return VLC_EGENERIC; return VLC_EGENERIC;
}
int err = VLC_EGENERIC; int err = VLC_EGENERIC;
UINT output_count = 0; UINT output_count = 0;
D3DFORMAT *output_list = NULL; D3DFORMAT *output_list = NULL;
if (FAILED(IDirectXVideoDecoderService_GetDecoderRenderTargets(va->sys->dx_sys.d3ddec, if (FAILED(IDirectXVideoDecoderService_GetDecoderRenderTargets(sys->dx_sys.d3ddec,
input, input,
&output_count, &output_count,
&output_list))) { &output_list))) {
...@@ -551,12 +545,12 @@ static int DxSetupOutput(vlc_va_t *va, const GUID *input, const video_format_t * ...@@ -551,12 +545,12 @@ static int DxSetupOutput(vlc_va_t *va, const GUID *input, const video_format_t *
} }
if (!is_supported) if (!is_supported)
continue; continue;
if (pass == 0 && format->format != va->sys->render) if (pass == 0 && format->format != sys->render)
continue; continue;
/* We have our solution */ /* We have our solution */
msg_Dbg(va, "Using decoder output '%s'", format->name); msg_Dbg(va, "Using decoder output '%s'", format->name);
va->sys->render = format->format; sys->render = format->format;
err = VLC_SUCCESS; err = VLC_SUCCESS;
break; break;
} }
......
...@@ -40,62 +40,82 @@ typedef struct ...@@ -40,62 +40,82 @@ typedef struct
#include "directx_va.h" #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 */ /* Intel Broadwell GPUs with hybrid HEVC */
0x1606, /* HD Graphics */ { 0x1606, NoHEVC }, /* HD Graphics */
0x160E, /* HD Graphics */ { 0x160E, NoHEVC }, /* HD Graphics */
0x1612, /* HD Graphics 5600 */ { 0x1612, NoHEVC }, /* HD Graphics 5600 */
0x1616, /* HD Graphics 5500 */ { 0x1616, NoHEVC }, /* HD Graphics 5500 */
0x161A, /* HD Graphics P5700 */ { 0x161A, NoHEVC }, /* HD Graphics P5700 */
0x161E, /* HD Graphics 5300 */ { 0x161E, NoHEVC }, /* HD Graphics 5300 */
0x1622, /* Iris Pro Graphics 6200 */ { 0x1622, NoHEVC }, /* Iris Pro Graphics 6200 */
0x1626, /* HD Graphics 6000 */ { 0x1626, NoHEVC }, /* HD Graphics 6000 */
0x162A, /* Iris Pro Graphics P6300 */ { 0x162A, NoHEVC }, /* Iris Pro Graphics P6300 */
0x162B, /* Iris Graphics 6100 */ { 0x162B, NoHEVC }, /* Iris Graphics 6100 */
0x0402, /* HD Graphics */ { 0x0402, NoHEVC }, /* HD Graphics */
0x0406, /* HD Graphics */ { 0x0406, NoHEVC }, /* HD Graphics */
0x040A, /* HD Graphics */ { 0x040A, NoHEVC }, /* HD Graphics */
0x0412, /* HD Graphics 4600 */ { 0x0412, NoHEVC }, /* HD Graphics 4600 */
0x0416, /* HD Graphics 4600 */ { 0x0416, NoHEVC }, /* HD Graphics 4600 */
0x041E, /* HD Graphics 4400 */ { 0x041E, NoHEVC }, /* HD Graphics 4400 */
0x041A, /* HD Graphics P4600/P4700 */ { 0x041A, NoHEVC }, /* HD Graphics P4600/P4700 */
0x0A06, /* HD Graphics */ { 0x0A06, NoHEVC }, /* HD Graphics */
0x0A0E, /* HD Graphics */ { 0x0A0E, NoHEVC }, /* HD Graphics */
0x0A16, /* HD Graphics Family */ { 0x0A16, NoHEVC }, /* HD Graphics Family */
0x0A1E, /* HD Graphics Family */ { 0x0A1E, NoHEVC }, /* HD Graphics Family */
0x0A26, /* HD Graphics 5000 */ { 0x0A26, NoHEVC }, /* HD Graphics 5000 */
0x0A2E, /* Iris(TM) Graphics 5100 */ { 0x0A2E, NoHEVC }, /* Iris(TM) Graphics 5100 */
0x0D22, /* Iris(TM) Pro Graphics 5200 */ { 0x0D22, NoHEVC }, /* Iris(TM) Pro Graphics 5200 */
0x0D26, /* Iris(TM) Pro Graphics 5200 */ { 0x0D26, NoHEVC }, /* Iris(TM) Pro Graphics 5200 */
0 {0, NULL}
}; };
static struct { static struct {
UINT vendor; const UINT vendor;
const UINT *devices; const struct decoders *devices;
} hevc_blacklist[] = { } gpu_blacklist[] = {
{ .vendor = GPU_MANUFACTURER_INTEL, .devices = IntelDevices }, { .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) if (va->obj.force)
return true; 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; const struct decoders *pDevice = gpu_blacklist[i].devices;
while (*pDevice != 0) while (pDevice->deviceID != 0)
{ {
if (*pDevice == DeviceId) if (pDevice->deviceID == DeviceId)
{ {
msg_Warn(va, "Intel Hybrid HEVC detected, disabling hardware decoding"); const GUID **pGuid = pDevice->decoder_list;
return false; while (*pGuid != NULL)
{
if (IsEqualGUID(pCodec, *pGuid))
return false;
pGuid++;
}
return true;
} }
pDevice++; pDevice++;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment