Windows Advanced Rasterization Platform (WARP) supports a variety of feature levels that vary based on the version of the DirectX API that is installed:
How can I easily determine what feature level is available via WARP? I know for the hardware device I can run ID3D11Device::GetFeatureLevel
, but I don't see an equivalent for WARP.
Use the code from Anatomy of Direct3D 11 Create Device but use the WARP device type instead.
D3D_FEATURE_LEVEL lvl[] = {
D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0,
D3D_FEATURE_LEVEL_10_1, D3D_FEATURE_LEVEL_10_0 };
DWORD createDeviceFlags = 0;
#ifdef _DEBUG
createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif
ID3D11Device* pDevice = nullptr;
ID3D11DeviceContext* pContext = nullptr;
D3D_FEATURE_LEVEL fl;
HRESULT hr = D3D11CreateDevice( nullptr, D3D_DRIVER_TYPE_WARP, nullptr,
createDeviceFlags, lvl, _countof(lvl),
D3D11_SDK_VERSION, &pDevice, &fl, &pContext );
if ( hr == E_INVALIDARG )
{
hr = D3D11CreateDevice( nullptr, D3D_DRIVER_TYPE_WARP, nullptr,
createDeviceFlags, &lvl[1], _countof(lvl)-1,
D3D11_SDK_VERSION, &pDevice, &fl, &pContext );
}
if ( FAILED(hr) )
// error handling
Then check fl
to see if it is 10.1, 11.0, or 11.1. We don't need to list the 9.1, 9.2, or 9.3 feature level in lvl
since WARP supports at least 10.1 on Windows desktop PCs. For robustness, I'd suggest listing 10.0 as well.