Question

I have a DX11 application to which I would like to add support for software rendering. This is because in some circumstances it will be run on machines without GPUs. From the research I have done, it seems like my best bet is WARP.

It was surprisingly simple to change the app to use WARP:

hr = D3D11CreateDevice(
    NULL, 
    D3D_DRIVER_TYPE_WARP, // was D3D_DRIVER_TYPE_HARDWARE
    NULL,
    creationFlag,
    featureLevels,
    ARRAYSIZE(featureLevels),
    D3D11_SDK_VERSION,
    &mDevice,
    &mFeatureLevel,
    &mDeviceContext
    );

It runs nicely. Where I'm struggling is determining when to set the DriverType to WARP instead of hardware. Is there a function I can call that will tell me if hardware support is available on the system?

I'm using DX 11 feature level 9_1.

Was it helpful?

Solution

This is how it's done usually: Just try to D3D11CreateDevice() with all parameters you expect as to be fine, including D3D_DRIVER_TYPE_HARDWARE (try different feature levels in the loop, to find out best). If this will fail, roll back to WARP. If WARP will fail, roll back to software, D3D9, GL, etc. If all possible variants will fail, notify user that he needs to upgrade his machine and/or OS =)

Each try you check return code, and device and context pointers. When you found (HRESULT == S_OK) && (device != 0) && (context != 0) - Bingo!

Hope it helps.

OTHER TIPS

I think that hardware will drop to software if hardware is not available:

http://msdn.microsoft.com/en-us/library/windows/desktop/ff476328(v=vs.85).aspx

Specifically:

http://msdn.microsoft.com/en-us/library/windows/desktop/ff476082(v=vs.85).aspx

Where it says:

If DriverType == D3D_DRIVER_TYPE_HARDWARE, the adapter used will be the default adapter, which is the first adapter that is enumerated by IDXGIFactory1::EnumAdapters.

Alternatively, if you want to control between WARP or hardware and nothing else, use EnumAdapters to get available adapters:

http://msdn.microsoft.com/en-us/library/windows/desktop/bb174538(v=vs.85).aspx

This gives you more control in case some 3rd party software adapter's installed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top