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)
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;
......
......@@ -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 */
......@@ -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;
}
......
......@@ -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 (gpu_blacklist[i].vendor == VendorId)
{
if (hevc_blacklist[i].vendor == VendorId)
const struct decoders *pDevice = gpu_blacklist[i].devices;
while (pDevice->deviceID != 0)
{
const UINT *pDevice = hevc_blacklist[i].devices;
while (*pDevice != 0)
if (pDevice->deviceID == DeviceId)
{
if (*pDevice == DeviceId)
const GUID **pGuid = pDevice->decoder_list;
while (*pGuid != NULL)
{
msg_Warn(va, "Intel Hybrid HEVC detected, disabling hardware decoding");
if (IsEqualGUID(pCodec, *pGuid))
return false;
pGuid++;
}
return true;
}
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