Reputation: 25778
I am running Windows 7. When I use DxDiag, it shows the version as 11.
When I use Visual Studio 2012 which can access Windows API, it can run the code with feature level D3D_FEATURE_LEVEL_11_1
So I agot confused, what is the exact version of my DirectX version?
Upvotes: 5
Views: 8946
Reputation: 41127
There are a number of confounding factors at work here, so let's take them one at a time:
D3DCreateDevice
even on Windows 8.x, you will still not get D3D_FEATURE_LEVEL_11_1
. This is for backcompat reasons and ensures the behavior doesn't change where NULL gets you 9.1 - 11.0. You have to manually list the 11.1 value in the array to get it--assuming the system+driver combo actually supports it. Note that if you do include 11.1 in the array, the call will fail with E_INVALIDARG
on Windows Vista SP2, Windows 7 RTM, or Windows 7 SP1 without KB2670838.D3D_FEATURE_LEVEL_11_1
or any of the new optional hardware features because it doesn't include support for the new WDDM 1.2 driver model. You have to be using Windows 8 or later to get D3D_FEATURE_LEVEL_11_1
with a WDDM 1.2 driver and appropriate hardware. See Microsoft DocsIn general, the proper way to handle all this for Windows desktop applications is:
D3D_FEATURE_LEVEL lvl[] = {
D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0,
D3D_FEATURE_LEVEL_10_1, D3D_FEATURE_LEVEL_10_0,
D3D_FEATURE_LEVEL_9_3, D3D_FEATURE_LEVEL_9_2, D3D_FEATURE_LEVEL_9_1
};
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_HARDWARE, nullptr,
createDeviceFlags, lvl, _countof(lvl),
D3D11_SDK_VERSION, &pDevice, &fl, &pContext );
if ( hr == E_INVALIDARG )
{
hr = D3D11CreateDevice( nullptr, D3D_DRIVER_TYPE_HARDWARE, nullptr,
createDeviceFlags, &lvl[1], _countof(lvl)-1,
D3D11_SDK_VERSION, &pDevice, &fl, &pContext );
}
if (FAILED(hr))
...
Then to detect support for Direct3D 11.1, you see if you can obtain the Direct3D 11.1 interfaces:
ID3D11Device1* pDevice1 = nullptr;
ID3D11DeviceContext1* pContext1 = nullptr;
hr = pDevice->QueryInterface( __uuidof( ID3D11Device1 ),
reinterpret_cast<void**>( &pDevice1 ) );
if ( SUCCEEDED(hr) )
{
// DirectX 11.1 is present, otherwise only DirectX 11.0
(void)pContext->QueryInterface( __uuidof( ID3D11DeviceContext1 ),
reinterpret_cast<void**>( &pContext1 ) );
}
Don't make assumptions based on Direct3D Feature Level what version of DirectX is installed or vice-versa.
See this post for details on the various nuances of device creation and DirectX 11.x version detection.
See this post and this one for important notes about DirectX 11.1 on Windows 7.
Upvotes: 11
Reputation: 10049
https://walbourn.github.io/directx-11-1-and-windows-7-update/ (http://blogs.msdn.com/b/chuckw/archive/2013/02/26/directx-11-1-and-windows-7-update.aspx)
DXDIAG: Even after applying KB 2670838 to Windows 7 SP1, DXDIAG will still report it as "DirectX 11".
When in doubt, I would suggest relying on the feature level returned from CreateDevice (et al) to be correct.
Upvotes: 0
Reputation: 1
As said before: Run dxdiag -> go to display -> check driver model. If you have WDDM 1.3 than DirectX 11.2 is installed in your system, if you have WDDM 1.2 than you have DirectX 11.1.
Upvotes: 0
Reputation: 1503
https://msdn.microsoft.com/en-us/library/windows/desktop/ff476876%28v=vs.85%29.aspx
A feature level is a well defined set of GPU functionality.
Your DirectX version is 11, but depending on your hardware (GPU) you might get feature level 11_1. If your friend down the street has Windows 8.1 and a supporting graphics card, they might have 11.2 features.
Although from what it sounds like, you have at least some 11.1 features available to you.
Upvotes: 0