0

Windows Advanced Rasterization Platform (WARP) supports a variety of feature levels that vary based on the version of the DirectX API that is installed:

  • feature levels 9_1, 9_2, 9_3, 10_0, and 10_1 when Direct3D 11 is installed
  • all above feature levels plus 11_0 when Direct3D 11.1 is installed on Windows 7
  • all above feature levels plus 11_1 when Direct3D 11.1 is installed on Windows 8

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.

NextInLine
  • 2,126
  • 14
  • 23
  • You should be able to call `GetFeatureLevel` when using WARP as well. Are you seeing problems with that? – MooseBoys Feb 27 '15 at 02:20
  • @MooseBoys, the documentation says that `GetFeatureLevel` returns *"a member of the D3D_FEATURE_LEVEL enumerated type that describes the feature level of the **hardware** device."* – NextInLine Mar 02 '15 at 17:13

1 Answers1

2

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.

Chuck Walbourn
  • 38,259
  • 2
  • 58
  • 81