1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-19 14:52:10 +01:00

[d3d10] D3D10CreateDeviceAndSwapChain: Ignore swap chain if null

Like e4b91057ac74266671d806e535b76f0db6f409bc, this might fix some
issues with ReShade in D3D10 games.
This commit is contained in:
Philip Rebohle 2018-12-02 15:52:17 +01:00
parent e4b91057ac
commit 835d92b802

View File

@ -152,6 +152,9 @@ extern "C" {
InitReturnPtr(ppDevice); InitReturnPtr(ppDevice);
InitReturnPtr(ppSwapChain); InitReturnPtr(ppSwapChain);
if (ppSwapChain && !pSwapChainDesc)
return E_INVALIDARG;
// Try to create the device as usual // Try to create the device as usual
Com<ID3D10Device1> d3d10Device = nullptr; Com<ID3D10Device1> d3d10Device = nullptr;
HRESULT hr = D3D10CreateDevice1(pAdapter, HRESULT hr = D3D10CreateDevice1(pAdapter,
@ -162,31 +165,30 @@ extern "C" {
return hr; return hr;
// Create the swap chain if requested // Create the swap chain if requested
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(d3d10Device->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(d3d10Device->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)))) { if (FAILED(dxgiFactory->CreateSwapChain(d3d10Device.ptr(), pSwapChainDesc, ppSwapChain))) {
Logger::err("D3D11CreateDeviceAndSwapChain: Failed to query DXGI factory"); Logger::err("D3D11CreateDeviceAndSwapChain: Failed to create swap chain");
return E_FAIL; return E_FAIL;
} }
if (FAILED(dxgiFactory->CreateSwapChain(d3d10Device.ptr(), pSwapChainDesc, ppSwapChain))) {
Logger::err("D3D11CreateDeviceAndSwapChain: Failed to create swap chain");
return E_FAIL;
} }
// Write back device pointer // Write back device pointer