1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-03 22:24:13 +01:00

[d3d11] Updated D3D11CreateDevice

Since D3D11Device and D3D11DeviceContext share the same reference
counter, we can actually create a device if the device pointer is
missing. Fixes Homefront.
This commit is contained in:
Philip Rebohle 2018-01-18 01:18:22 +01:00
parent ade9cd0587
commit 3ac25d5e2a
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99

View File

@ -105,34 +105,29 @@ extern "C" {
if (pFeatureLevel != nullptr) if (pFeatureLevel != nullptr)
*pFeatureLevel = fl; *pFeatureLevel = fl;
// The documentation is unclear about what exactly should be done if // If we cannot write back either the device or
// the application passes NULL to ppDevice, but a non-NULL pointer to // the context, don't create the device at all
// ppImmediateContext. In our implementation, the immediate context if (ppDevice == nullptr && ppImmediateContext == nullptr)
// does not hold a strong reference to the device that owns it, so return S_FALSE;
// if we cannot write back the device, it would be destroyed.
if (ppDevice != nullptr) { Com<IDXGIDevicePrivate> dxvkDevice = nullptr;
Com<IDXGIDevicePrivate> dxvkDevice = nullptr;
const VkPhysicalDeviceFeatures deviceFeatures
const VkPhysicalDeviceFeatures deviceFeatures = D3D11Device::GetDeviceFeatures(adapter, fl);
= D3D11Device::GetDeviceFeatures(adapter, fl);
if (FAILED(DXGICreateDevicePrivate(dxvkAdapter.ptr(), &deviceFeatures, &dxvkDevice))) {
if (FAILED(DXGICreateDevicePrivate(dxvkAdapter.ptr(), &deviceFeatures, &dxvkDevice))) { Logger::err("D3D11CreateDevice: Failed to create DXGI device");
Logger::err("D3D11CreateDevice: Failed to create DXGI device"); return E_FAIL;
return E_FAIL;
}
Com<D3D11Device> d3d11Device = new D3D11Device(
dxvkDevice.ptr(), fl, Flags);
*ppDevice = d3d11Device.ref();
if (ppImmediateContext != nullptr)
d3d11Device->GetImmediateContext(ppImmediateContext);
return S_OK;
} else {
Logger::warn("D3D11CreateDevice: ppDevice is null");
return S_OK;
} }
Com<D3D11Device> d3d11Device = new D3D11Device(dxvkDevice.ptr(), fl, Flags);
if (ppDevice != nullptr)
*ppDevice = d3d11Device.ref();
if (ppImmediateContext != nullptr)
d3d11Device->GetImmediateContext(ppImmediateContext);
return S_OK;
} catch (const DxvkError& e) { } catch (const DxvkError& e) {
Logger::err("D3D11CreateDevice: Failed to create D3D11 device"); Logger::err("D3D11CreateDevice: Failed to create D3D11 device");
return E_FAIL; return E_FAIL;