[vlc-devel] DXVA : workaround for a bug in ATI drivers

Mathieu Velten matmaul at gmail.com
Tue Dec 29 22:41:24 CET 2009


hello !

I am a hacker on the directshow player MPC-HC. I just see that you add
hardware acceleration (great work !).
I read the code and it seems that you are not aware of a DXVA
implementation bug in ATI driver :
the ATI driver needs the scaling matrix in raster order (vs zigzag
order in the standard).
You should change the fill_scaling_lists function accordingly in the
ffmpeg dxva2 patch using the "workaround" field of the context I
guess.
this bug should only trigger with files using custom matrices since a
flat matrix is the same with both orders.

here is some D3D code from MPC to detect the brand of the graphic card :

UINT GetAdapter(IDirect3D9* pD3D, HWND hWnd)
{
	if(hWnd == NULL || pD3D == NULL)
		return D3DADAPTER_DEFAULT;

	HMONITOR hMonitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
	if(hMonitor == NULL) return D3DADAPTER_DEFAULT;

	for(UINT adp = 0, num_adp = pD3D->GetAdapterCount(); adp < num_adp; ++adp)
	{
		HMONITOR hAdpMon = pD3D->GetAdapterMonitor(adp);
		if(hAdpMon == hMonitor) return adp;
	}

	return D3DADAPTER_DEFAULT;
}

void DetectVideoCard(HWND hWnd)
{
	IDirect3D9* pD3D9;
	m_nPCIVendor = 0;
	m_nPCIDevice = 0;
	m_VideoDriverVersion.HighPart = 0;
	m_VideoDriverVersion.LowPart = 0;

	if (pD3D9 = Direct3DCreate9(D3D_SDK_VERSION))
	{
		D3DADAPTER_IDENTIFIER9 adapterIdentifier;
		if (pD3D9->GetAdapterIdentifier(GetAdapter(pD3D9, hWnd), 0,
&adapterIdentifier) == S_OK)
		{
			m_nPCIVendor = adapterIdentifier.VendorId; // 0x1002 for ATI,
0x10DE for NVIDIA, 0x8086 for Intel, 0x5333 for S3 Graphics
			m_nPCIDevice = adapterIdentifier.DeviceId;
			m_VideoDriverVersion = adapterIdentifier.DriverVersion;
			m_strDeviceDescription = adapterIdentifier.Description;
			m_strDeviceDescription.AppendFormat (_T(" (%d)"), m_nPCIVendor);
		}
		pD3D9->Release();
	}
}

Mathieu Velten



More information about the vlc-devel mailing list