Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/LAVFilters.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHendrik Leppkes <h.leppkes@gmail.com>2017-08-19 16:33:23 +0300
committerHendrik Leppkes <h.leppkes@gmail.com>2017-08-19 16:33:23 +0300
commit4ec93e5857a2341d65376c15c859f4b288a55774 (patch)
treee6f7c778e6dc1e2eea4812e37af008b0a66d003c
parente00966544659bd7952e7452f73833a22405ecfdc (diff)
d3d11: implement device selection for copy-back mode
-rw-r--r--decoder/LAVVideo/decoders/d3d11va.cpp81
-rw-r--r--decoder/LAVVideo/decoders/d3d11va.h2
2 files changed, 82 insertions, 1 deletions
diff --git a/decoder/LAVVideo/decoders/d3d11va.cpp b/decoder/LAVVideo/decoders/d3d11va.cpp
index 683bc8f8..7437d250 100644
--- a/decoder/LAVVideo/decoders/d3d11va.cpp
+++ b/decoder/LAVVideo/decoders/d3d11va.cpp
@@ -268,7 +268,20 @@ STDMETHODIMP CDecD3D11::PostConnect(IPin *pPin)
av_buffer_unref(&m_pDevCtx);
// device id
- UINT nDevice = pD3D11DecoderConfiguration ? pD3D11DecoderConfiguration->GetD3D11AdapterIndex() : 0;
+ UINT nDevice = 0;
+
+ // use the device the renderer recommends
+ if (pD3D11DecoderConfiguration)
+ {
+ nDevice = pD3D11DecoderConfiguration->GetD3D11AdapterIndex();
+ }
+ else
+ {
+ // use the configured device
+ nDevice = m_pSettings->GetHWAccelDeviceIndex(HWAccel_D3D11, nullptr);
+ if (nDevice == LAVHWACCEL_DEVICE_DEFAULT)
+ nDevice = 0;
+ }
// create the device
ID3D11Device *pD3D11Device = nullptr;
@@ -1089,6 +1102,72 @@ STDMETHODIMP CDecD3D11::GetPixelFormat(LAVPixelFormat *pPix, int *pBpp)
return S_OK;
}
+STDMETHODIMP_(DWORD) CDecD3D11::GetHWAccelNumDevices()
+{
+ DWORD nDevices = 0;
+ UINT i = 0;
+ IDXGIAdapter *pDXGIAdapter = nullptr;
+ IDXGIFactory1 *pDXGIFactory = nullptr;
+
+ HRESULT hr = dx.mCreateDXGIFactory1(IID_IDXGIFactory1, (void **)&pDXGIFactory);
+ if (FAILED(hr))
+ goto fail;
+
+ DXGI_ADAPTER_DESC desc;
+ while (SUCCEEDED(pDXGIFactory->EnumAdapters(i, &pDXGIAdapter)))
+ {
+ pDXGIAdapter->GetDesc(&desc);
+ SafeRelease(&pDXGIAdapter);
+
+ // stop when we hit the MS software device
+ if (desc.VendorId == 0x1414 && desc.DeviceId == 0x8c)
+ break;
+
+ i++;
+ }
+
+ nDevices = i;
+
+fail:
+ SafeRelease(&pDXGIFactory);
+ return nDevices;
+}
+
+STDMETHODIMP CDecD3D11::GetHWAccelDeviceInfo(DWORD dwIndex, BSTR *pstrDeviceName, DWORD *dwDeviceIdentifier)
+{
+ IDXGIAdapter *pDXGIAdapter = nullptr;
+ IDXGIFactory1 *pDXGIFactory = nullptr;
+
+ HRESULT hr = dx.mCreateDXGIFactory1(IID_IDXGIFactory1, (void **)&pDXGIFactory);
+ if (FAILED(hr))
+ goto fail;
+
+ hr = pDXGIFactory->EnumAdapters(dwIndex, &pDXGIAdapter);
+ if (FAILED(hr))
+ goto fail;
+
+ DXGI_ADAPTER_DESC desc;
+ pDXGIAdapter->GetDesc(&desc);
+
+ // stop when we hit the MS software device
+ if (desc.VendorId == 0x1414 && desc.DeviceId == 0x8c)
+ {
+ hr = E_INVALIDARG;
+ goto fail;
+ }
+
+ if (pstrDeviceName)
+ *pstrDeviceName = SysAllocString(desc.Description);
+
+ if (dwDeviceIdentifier)
+ *dwDeviceIdentifier = desc.DeviceId;
+
+fail:
+ SafeRelease(&pDXGIFactory);
+ SafeRelease(&pDXGIAdapter);
+ return hr;
+}
+
STDMETHODIMP CDecD3D11::GetHWAccelActiveDevice(BSTR *pstrDeviceName)
{
CheckPointer(pstrDeviceName, E_POINTER);
diff --git a/decoder/LAVVideo/decoders/d3d11va.h b/decoder/LAVVideo/decoders/d3d11va.h
index a63a3e77..a0fb1d85 100644
--- a/decoder/LAVVideo/decoders/d3d11va.h
+++ b/decoder/LAVVideo/decoders/d3d11va.h
@@ -55,6 +55,8 @@ public:
STDMETHODIMP_(const WCHAR*) GetDecoderName() { return m_bReadBackFallback ? (m_bDirect ? L"d3d11 cb direct" : L"d3d11 cb") : L"d3d11 native"; }
STDMETHODIMP HasThreadSafeBuffers() { return S_FALSE; }
STDMETHODIMP SetDirectOutput(BOOL bDirect) { m_bDirect = bDirect; return S_OK; }
+ STDMETHODIMP_(DWORD) GetHWAccelNumDevices();
+ STDMETHODIMP GetHWAccelDeviceInfo(DWORD dwIndex, BSTR *pstrDeviceName, DWORD *dwDeviceIdentifier);
STDMETHODIMP GetHWAccelActiveDevice(BSTR *pstrDeviceName);
// CDecBase