MCPcopy Create free account
hub / github.com/Aleksoid1978/VideoRenderer / SetDevice

Method SetDevice

Source/DX11VideoProcessor.cpp:1254–1448  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1252}
1253
1254HRESULT CDX11VideoProcessor::SetDevice(ID3D11Device *pDevice, ID3D11DeviceContext *pContext)
1255{
1256 DLog(L"CDX11VideoProcessor::SetDevice()");
1257
1258 ReleaseSwapChain();
1259 m_pDXGIFactory2.Release();
1260 ReleaseDevice();
1261
1262 CheckPointer(pDevice, E_POINTER);
1263
1264 HRESULT hr = pDevice->QueryInterface(IID_PPV_ARGS(&m_pDevice));
1265 if (FAILED(hr)) {
1266 return hr;
1267 }
1268 if (pContext) {
1269 hr = pContext->QueryInterface(IID_PPV_ARGS(&m_pDeviceContext));
1270 if (FAILED(hr)) {
1271 return hr;
1272 }
1273 } else {
1274 m_pDevice->GetImmediateContext1(&m_pDeviceContext);
1275 }
1276
1277 // for d3d11 subtitles
1278 CComQIPtr<ID3D10Multithread> pMultithread(m_pDeviceContext);
1279 pMultithread->SetMultithreadProtected(TRUE);
1280
1281 CComPtr<IDXGIDevice> pDXGIDevice;
1282 hr = m_pDevice->QueryInterface(IID_PPV_ARGS(&pDXGIDevice));
1283 if (FAILED(hr)) {
1284 DLog(L"CDX11VideoProcessor::SetDevice() : QueryInterface(IDXGIDevice) failed with error {}", HR2Str(hr));
1285 ReleaseDevice();
1286 return hr;
1287 }
1288
1289 CComPtr<IDXGIAdapter> pDXGIAdapter;
1290 hr = pDXGIDevice->GetAdapter(&pDXGIAdapter);
1291 if (FAILED(hr)) {
1292 DLog(L"CDX11VideoProcessor::SetDevice() : GetAdapter(IDXGIAdapter) failed with error {}", HR2Str(hr));
1293 ReleaseDevice();
1294 return hr;
1295 }
1296
1297 DXGI_ADAPTER_DESC dxgiAdapterDesc = {};
1298 hr = pDXGIAdapter->GetDesc(&dxgiAdapterDesc);
1299 if (SUCCEEDED(hr)) {
1300 m_VendorId = dxgiAdapterDesc.VendorId;
1301 m_strAdapterDescription = std::format(L"{} ({:04X}:{:04X})", dxgiAdapterDesc.Description, dxgiAdapterDesc.VendorId, dxgiAdapterDesc.DeviceId);
1302 DLog(L"Graphics DXGI adapter: {}", m_strAdapterDescription);
1303 }
1304
1305 HRESULT hr2 = m_D3D11VP.InitVideoDevice(m_pDevice, m_pDeviceContext, m_VendorId);
1306 DLogIf(FAILED(hr2), L"CDX11VideoProcessor::SetDevice() : InitVideoDevice failed with error {}", HR2Str(hr2));
1307
1308 D3D11_SAMPLER_DESC SampDesc = {};
1309 SampDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
1310 SampDesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
1311 SampDesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;

Callers 2

InitInternalMethod · 0.80
ActivateD3D11DecodingMethod · 0.80

Calls 11

DLogFunction · 0.85
HR2StrFunction · 0.85
GetDataFromResourceFunction · 0.85
InitVideoDeviceMethod · 0.80
CreateBlendStateMethod · 0.80
OnDisplayModeChangeMethod · 0.80
ReleaseMethod · 0.45
QueryInterfaceMethod · 0.45
GetDescMethod · 0.45
InitDeviceObjectsMethod · 0.45
CreateMethod · 0.45

Tested by

no test coverage detected