Skip to content

Commit b1eeb96

Browse files
committed
Add Windows 7 WARP fallback for D3D11 device creation
When D3D11CreateDevice fails with DXGI_ERROR_UNSUPPORTED on Windows 7, retry using the WARP (software) driver type. Also remove the D3D11_CREATE_DEVICE_DEBUG flag in this case, as the Win7 software adapter does not support creating a debug device.
1 parent 3b74fa2 commit b1eeb96

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

axmol/rhi/d3d/DriverD3D.cpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -253,20 +253,25 @@ DriverImpl::DriverImpl()
253253
{
254254
// Try again with software driver type
255255
requestDriverType = D3D_DRIVER_TYPE_WARP;
256-
hr = D3D11CreateDevice(nullptr, // Adapter
257-
requestDriverType, // Driver Type
258-
nullptr, // Software
259-
createDeviceFlags, // Flags
260-
featureLevels, // Feature Levels
261-
ARRAYSIZE(featureLevels), // Num Feature Levels
262-
D3D11_SDK_VERSION, // SDK Version
263-
&_device, // Device
264-
&_featureLevel, // Feature Level
265-
&_context);
256+
// windows 7: D3D11 software adapter not support create debug device
257+
createDeviceFlags &= ~D3D11_CREATE_DEVICE_DEBUG;
258+
hr = D3D11CreateDevice(nullptr, // Adapter
259+
requestDriverType, // Driver Type
260+
nullptr, // Software
261+
createDeviceFlags, // Flags
262+
featureLevels, // Feature Levels
263+
ARRAYSIZE(featureLevels), // Num Feature Levels
264+
D3D11_SDK_VERSION, // SDK Version
265+
&_device, // Device
266+
&_featureLevel, // Feature Level
267+
&_context);
266268
}
267269
if (FAILED(hr))
268270
{
269-
AXLOGE("Failed to create D3D11 device.");
271+
auto msg = fmt::format("D3D11 required, please upgrade the driver of your video card.");
272+
AXLOGE("{}", msg);
273+
messageBox(msg.c_str(), "Failed to create D3D11 device.");
274+
utils::killCurrentProcess(); // kill current process, don't cause crash when driver issue.
270275
}
271276

272277
Microsoft::WRL::ComPtr<IDXGIDevice> dxgiDevice;

0 commit comments

Comments
 (0)