This topics shows how to get the highest feature level supported by a device. Direct3D 11 devices support a fixed set of feature levels that are defined in the D3D_FEATURE_LEVEL enumeration. When you know the highest feature level supported by a device, you can run code paths that are appropriate for that device.
To get the device feature level
-
Call either the D3D11CreateDevice function or the D3D11CreateDeviceAndSwapChain functions while specifying NULL for the ppDevice parameter. You can do this before device creation.
- or -
Call ID3D11Device::GetFeatureLevel after device creation.
- Examine the value of the returned D3D_FEATURE_LEVEL enumeration from the last step to determine the supported feature level.
The following code example demonstrates how to determine the highest supported feature level by calling the D3D11CreateDevice function. D3D11CreateDevice stores the highest supported feature level in the FeatureLevel variable. You can use code to examine the value of the D3D_FEATURE_LEVEL enumerated type that D3D11CreateDevice returns.
HRESULT hr = E_FAIL;
D3D_FEATURE_LEVEL FeatureLevel;
hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, NULL, 0,
D3D11_SDK_VERSION, NULL, &FeatureLevel, NULL );
if(FAILED(hr))
{
return hr;
}
The 10Level9 Reference section lists the differences between how various ID3D11Device and ID3D11DeviceContext methods behave at various 10Level9 feature levels.
Related topics
Send comments about this topic to Microsoft
Build date: 11/28/2012