Bug 1371190 - Retry D3D11CreateDevice with feature level 11_0 if 11_1 is not supported draft
authorChih-Yi Leu <subsevenx2001@gmail.com>
Wed, 04 Oct 2017 09:27:43 +0800
changeset 675285 a637e9eb226f047ee3b8f0070207ab3d74f67526
parent 674756 a66978382eaf500504bee863d3ef54fa69913d06
child 675286 65022b9de73513eed1fa009072878fddfa438171
push id83094
push userbmo:cleu@mozilla.com
push dateThu, 05 Oct 2017 03:39:09 +0000
bugs1371190
milestone58.0a1
Bug 1371190 - Retry D3D11CreateDevice with feature level 11_0 if 11_1 is not supported 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.";
             }