mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-15 07:29:17 +01:00
[dxvk] Fixed D3D11CreateDeviceAndSwapChain bug
Some applications may want to create a swap chain without specifying a device or context pointer.
This commit is contained in:
parent
c5bbf2d989
commit
52f6ba1756
@ -148,21 +148,22 @@ extern "C" {
|
||||
ID3D11Device **ppDevice,
|
||||
D3D_FEATURE_LEVEL *pFeatureLevel,
|
||||
ID3D11DeviceContext **ppImmediateContext) {
|
||||
Com<ID3D11Device> d3d11Device;
|
||||
Com<ID3D11DeviceContext> d3d11Context;
|
||||
|
||||
// Try to create a device first.
|
||||
HRESULT status = D3D11CreateDevice(pAdapter, DriverType,
|
||||
Software, Flags, pFeatureLevels, FeatureLevels,
|
||||
SDKVersion, ppDevice, pFeatureLevel, ppImmediateContext);
|
||||
SDKVersion, &d3d11Device, pFeatureLevel, &d3d11Context);
|
||||
|
||||
if (FAILED(status))
|
||||
return status;
|
||||
|
||||
// Again, the documentation does not exactly tell us what we
|
||||
// need to do in case one of the arguments is a null pointer.
|
||||
if (ppDevice != nullptr && ppSwapChain != nullptr) {
|
||||
if (pSwapChainDesc == nullptr)
|
||||
return E_INVALIDARG;
|
||||
|
||||
Com<ID3D11Device> d3d11Device = *ppDevice;
|
||||
Com<IDXGIDevice> dxgiDevice = nullptr;
|
||||
Com<IDXGIAdapter> dxgiAdapter = nullptr;
|
||||
Com<IDXGIFactory> dxgiFactory = nullptr;
|
||||
@ -188,11 +189,13 @@ extern "C" {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if (ppDevice != nullptr)
|
||||
*ppDevice = d3d11Device.ref();
|
||||
|
||||
if (ppImmediateContext != nullptr)
|
||||
*ppImmediateContext = d3d11Context.ref();
|
||||
|
||||
return S_OK;
|
||||
} else {
|
||||
Logger::warn("D3D11CreateDeviceAndSwapChain: Not creating a swap chain");
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user