Commit 6aee8620 by Olli Etuaho Committed by Commit Bot

Fall back to D3D11.0 from D3D11.1 in device creation

Some users of ANGLE might want to use the D3D11 backend on older Windows 7 platforms that only support DXGI 1.1. DXGI 1.1 doesn't recognize the FL 11.1 enum passed to D3D11CreateDevice, so special fall-back code is needed to fall back to FL 11.0 or lower in this case. BUG=angleproject:2173 Change-Id: Id77401d0e2a16786ed44d117ca746908e8d0892c Reviewed-on: https://chromium-review.googlesource.com/716356Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent d736cccf
...@@ -752,6 +752,14 @@ egl::Error Renderer11::initialize() ...@@ -752,6 +752,14 @@ egl::Error Renderer11::initialize()
return egl::NoError(); return egl::NoError();
} }
HRESULT Renderer11::callD3D11CreateDevice(PFN_D3D11_CREATE_DEVICE createDevice, bool debug)
{
return createDevice(
nullptr, mRequestedDriverType, nullptr, debug ? D3D11_CREATE_DEVICE_DEBUG : 0,
mAvailableFeatureLevels.data(), static_cast<unsigned int>(mAvailableFeatureLevels.size()),
D3D11_SDK_VERSION, &mDevice, &(mRenderer11DeviceCaps.featureLevel), &mDeviceContext);
}
egl::Error Renderer11::initializeD3DDevice() egl::Error Renderer11::initializeD3DDevice()
{ {
HRESULT result = S_OK; HRESULT result = S_OK;
...@@ -789,11 +797,17 @@ egl::Error Renderer11::initializeD3DDevice() ...@@ -789,11 +797,17 @@ egl::Error Renderer11::initializeD3DDevice()
if (mCreateDebugDevice) if (mCreateDebugDevice)
{ {
TRACE_EVENT0("gpu.angle", "D3D11CreateDevice (Debug)"); TRACE_EVENT0("gpu.angle", "D3D11CreateDevice (Debug)");
result = D3D11CreateDevice(nullptr, mRequestedDriverType, nullptr, result = callD3D11CreateDevice(D3D11CreateDevice, true);
D3D11_CREATE_DEVICE_DEBUG, mAvailableFeatureLevels.data(),
static_cast<unsigned int>(mAvailableFeatureLevels.size()), if (result == E_INVALIDARG && mAvailableFeatureLevels.size() > 1u &&
D3D11_SDK_VERSION, &mDevice, mAvailableFeatureLevels[0] == D3D_FEATURE_LEVEL_11_1)
&(mRenderer11DeviceCaps.featureLevel), &mDeviceContext); {
// On older Windows platforms, D3D11.1 is not supported which returns E_INVALIDARG.
// Try again without passing D3D_FEATURE_LEVEL_11_1 in case we have other feature
// levels to fall back on.
mAvailableFeatureLevels.erase(mAvailableFeatureLevels.begin());
result = callD3D11CreateDevice(D3D11CreateDevice, true);
}
if (!mDevice || FAILED(result)) if (!mDevice || FAILED(result))
{ {
...@@ -806,10 +820,17 @@ egl::Error Renderer11::initializeD3DDevice() ...@@ -806,10 +820,17 @@ egl::Error Renderer11::initializeD3DDevice()
SCOPED_ANGLE_HISTOGRAM_TIMER("GPU.ANGLE.D3D11CreateDeviceMS"); SCOPED_ANGLE_HISTOGRAM_TIMER("GPU.ANGLE.D3D11CreateDeviceMS");
TRACE_EVENT0("gpu.angle", "D3D11CreateDevice"); TRACE_EVENT0("gpu.angle", "D3D11CreateDevice");
result = D3D11CreateDevice( result = callD3D11CreateDevice(D3D11CreateDevice, false);
nullptr, mRequestedDriverType, nullptr, 0, mAvailableFeatureLevels.data(),
static_cast<unsigned int>(mAvailableFeatureLevels.size()), D3D11_SDK_VERSION, if (result == E_INVALIDARG && mAvailableFeatureLevels.size() > 1u &&
&mDevice, &(mRenderer11DeviceCaps.featureLevel), &mDeviceContext); mAvailableFeatureLevels[0] == D3D_FEATURE_LEVEL_11_1)
{
// On older Windows platforms, D3D11.1 is not supported which returns E_INVALIDARG.
// Try again without passing D3D_FEATURE_LEVEL_11_1 in case we have other feature
// levels to fall back on.
mAvailableFeatureLevels.erase(mAvailableFeatureLevels.begin());
result = callD3D11CreateDevice(D3D11CreateDevice, false);
}
// Cleanup done by destructor // Cleanup done by destructor
if (!mDevice || FAILED(result)) if (!mDevice || FAILED(result))
......
...@@ -501,6 +501,7 @@ class Renderer11 : public RendererD3D ...@@ -501,6 +501,7 @@ class Renderer11 : public RendererD3D
const gl::TextureCaps &colorBufferFormatCaps, const gl::TextureCaps &colorBufferFormatCaps,
const gl::TextureCaps &depthStencilBufferFormatCaps) const; const gl::TextureCaps &depthStencilBufferFormatCaps) const;
HRESULT callD3D11CreateDevice(PFN_D3D11_CREATE_DEVICE createDevice, bool debug);
egl::Error initializeD3DDevice(); egl::Error initializeD3DDevice();
egl::Error initializeDevice(); egl::Error initializeDevice();
void releaseDeviceResources(); void releaseDeviceResources();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment