Bug 1371190 - Part 8: Retry D3D11CreateDevice with feature level 11_0 if 11_1 is not supported. r=jgilbert
authorChih-Yi Leu <subsevenx2001@gmail.com>
Wed, 04 Oct 2017 09:27:43 +0800
changeset 385449 9f5ac1ae700103bc8f5aad0633504c1b34447e8a
parent 385448 ed85185ff27e2236f528116011e552a59ac33bc9
child 385450 8731edf699f39ef92c6c819f6f026de7dd5252bb
push id32656
push userarchaeopteryx@coole-files.de
push dateWed, 11 Oct 2017 09:50:40 +0000
treeherdermozilla-central@20d9ad08dd36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert
bugs1371190
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1371190 - Part 8: Retry D3D11CreateDevice with feature level 11_0 if 11_1 is not supported. r=jgilbert MozReview-Commit-ID: 1PGa6CuY7GZ
gfx/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp
--- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp
+++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp
@@ -772,32 +772,55 @@ egl::Error Renderer11::initializeD3DDevi
         {
             TRACE_EVENT0("gpu.angle", "D3D11CreateDevice (Debug)");
             result = D3D11CreateDevice(nullptr, mRequestedDriverType, nullptr,
                                        D3D11_CREATE_DEVICE_DEBUG, mAvailableFeatureLevels.data(),
                                        static_cast<unsigned int>(mAvailableFeatureLevels.size()),
                                        D3D11_SDK_VERSION, &mDevice,
                                        &(mRenderer11DeviceCaps.featureLevel), &mDeviceContext);
 
+            if (result == E_INVALIDARG &&
+                mAvailableFeatureLevels[0] == D3D_FEATURE_LEVEL_11_1)
+            {
+                // In some older Windows platform, D3D11.1 is not supported which returns E_INVALIDARG
+                // so we omit the 11.1 feature level flag and try again
+                result = D3D11CreateDevice(nullptr, mRequestedDriverType, nullptr,
+                                           D3D11_CREATE_DEVICE_DEBUG, mAvailableFeatureLevels.data()+1,
+                                           static_cast<unsigned int>(mAvailableFeatureLevels.size())-1,
+                                           D3D11_SDK_VERSION, &mDevice,
+                                           &(mRenderer11DeviceCaps.featureLevel), &mDeviceContext);
+            }
+
             if (!mDevice || FAILED(result))
             {
                 WARN() << "Failed creating Debug D3D11 device - falling back to release runtime.";
             }
         }
 
         if (!mDevice || FAILED(result))
         {
             SCOPED_ANGLE_HISTOGRAM_TIMER("GPU.ANGLE.D3D11CreateDeviceMS");
             TRACE_EVENT0("gpu.angle", "D3D11CreateDevice");
 
             result = D3D11CreateDevice(
                 nullptr, mRequestedDriverType, nullptr, 0, mAvailableFeatureLevels.data(),
                 static_cast<unsigned int>(mAvailableFeatureLevels.size()), D3D11_SDK_VERSION,
                 &mDevice, &(mRenderer11DeviceCaps.featureLevel), &mDeviceContext);
 
+            if (result == E_INVALIDARG &&
+                mAvailableFeatureLevels[0] == D3D_FEATURE_LEVEL_11_1)
+            {
+                // In some older Windows platform, D3D11.1 is not supported which returns E_INVALIDARG
+                // so we omit the 11.1 feature level flag and try again
+                result = D3D11CreateDevice(
+                    nullptr, mRequestedDriverType, nullptr, 0, mAvailableFeatureLevels.data()+1,
+                    static_cast<unsigned int>(mAvailableFeatureLevels.size())-1, D3D11_SDK_VERSION,
+                    &mDevice, &(mRenderer11DeviceCaps.featureLevel), &mDeviceContext);
+            }
+
             // Cleanup done by destructor
             if (!mDevice || FAILED(result))
             {
                 ANGLE_HISTOGRAM_SPARSE_SLOWLY("GPU.ANGLE.D3D11CreateDeviceError",
                                               static_cast<int>(result));
                 return egl::EglNotInitialized(D3D11_INIT_CREATEDEVICE_ERROR)
                        << "Could not create D3D11 device.";
             }