1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-04 16:24:29 +01:00

[d3d11] D3D11CreateDeviceAndSwapChain: Ignore swap chain if null

Fixes some issue with ReShade.
This commit is contained in:
Philip Rebohle 2018-12-02 13:43:55 +01:00
parent cf21111401
commit e4b91057ac

View File

@ -187,6 +187,9 @@ extern "C" {
Com<ID3D11Device> d3d11Device; Com<ID3D11Device> d3d11Device;
Com<ID3D11DeviceContext> d3d11Context; Com<ID3D11DeviceContext> d3d11Context;
if (ppSwapChain && !pSwapChainDesc)
return E_INVALIDARG;
// Try to create a device first. // Try to create a device first.
HRESULT status = D3D11CreateDevice(pAdapter, DriverType, HRESULT status = D3D11CreateDevice(pAdapter, DriverType,
Software, Flags, pFeatureLevels, FeatureLevels, Software, Flags, pFeatureLevels, FeatureLevels,
@ -197,32 +200,31 @@ extern "C" {
// Again, the documentation does not exactly tell us what we // Again, the documentation does not exactly tell us what we
// need to do in case one of the arguments is a null pointer. // need to do in case one of the arguments is a null pointer.
if (pSwapChainDesc == nullptr) if (ppSwapChain) {
return E_INVALIDARG; Com<IDXGIDevice> dxgiDevice = nullptr;
Com<IDXGIAdapter> dxgiAdapter = nullptr;
Com<IDXGIFactory> dxgiFactory = nullptr;
Com<IDXGIDevice> dxgiDevice = nullptr; if (FAILED(d3d11Device->QueryInterface(__uuidof(IDXGIDevice), reinterpret_cast<void**>(&dxgiDevice)))) {
Com<IDXGIAdapter> dxgiAdapter = nullptr; Logger::err("D3D11CreateDeviceAndSwapChain: Failed to query DXGI device");
Com<IDXGIFactory> dxgiFactory = nullptr; return E_FAIL;
}
if (FAILED(d3d11Device->QueryInterface(__uuidof(IDXGIDevice), reinterpret_cast<void**>(&dxgiDevice)))) { if (FAILED(dxgiDevice->GetParent(__uuidof(IDXGIAdapter), reinterpret_cast<void**>(&dxgiAdapter)))) {
Logger::err("D3D11CreateDeviceAndSwapChain: Failed to query DXGI device"); Logger::err("D3D11CreateDeviceAndSwapChain: Failed to query DXGI adapter");
return E_FAIL; return E_FAIL;
} }
if (FAILED(dxgiDevice->GetParent(__uuidof(IDXGIAdapter), reinterpret_cast<void**>(&dxgiAdapter)))) { if (FAILED(dxgiAdapter->GetParent(__uuidof(IDXGIFactory), reinterpret_cast<void**>(&dxgiFactory)))) {
Logger::err("D3D11CreateDeviceAndSwapChain: Failed to query DXGI adapter"); Logger::err("D3D11CreateDeviceAndSwapChain: Failed to query DXGI factory");
return E_FAIL; return E_FAIL;
} }
if (FAILED(dxgiAdapter->GetParent(__uuidof(IDXGIFactory), reinterpret_cast<void**>(&dxgiFactory)))) { DXGI_SWAP_CHAIN_DESC desc = *pSwapChainDesc;
Logger::err("D3D11CreateDeviceAndSwapChain: Failed to query DXGI factory"); if (FAILED(dxgiFactory->CreateSwapChain(d3d11Device.ptr(), &desc, ppSwapChain))) {
return E_FAIL; Logger::err("D3D11CreateDeviceAndSwapChain: Failed to create swap chain");
} return E_FAIL;
}
DXGI_SWAP_CHAIN_DESC desc = *pSwapChainDesc;
if (FAILED(dxgiFactory->CreateSwapChain(d3d11Device.ptr(), &desc, ppSwapChain))) {
Logger::err("D3D11CreateDeviceAndSwapChain: Failed to create swap chain");
return E_FAIL;
} }
if (ppDevice != nullptr) if (ppDevice != nullptr)