1

how can you detect if the directx version on a windows 7 machine is 11 or 11.1 ?

preferably using a .NET language maybe via PInvoke or SharpDX?

Charles
  • 50,943
  • 13
  • 104
  • 142
clamp
  • 33,000
  • 75
  • 203
  • 299

1 Answers1

4

Just try to create a device with a specific feature level (along with other parameters).

  • In native code (use one of the D3D11CreateDevice* functions) . If function will not succeed - feature level is not supported. To make it easier, we usually pass array of feature levels, and then, if device is not nullptr, we can check which one is highest supported:

    const D3D_FEATURE_LEVEL arrFeatLevels[] = 
    {
        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, 
    };
    
    const unsigned int nFeatLevels = _countof(arrFeatLevels);
    
    D3D11CreateDeviceAndSwapChain(..., arrFeatLevels, nFeatLevels, ..., 
                                       &m_Device, &featureLevel, &m_Context);
    if (m_Device && m_Context)
    {
        featureLevel // you can access to highest supported feature level here
    
  • In SharpDX you will need to use constructor, which accepts specific feature levels:

    Device(DriverType, DeviceCreationFlags, FeatureLevel[])
    

    if device creation succeeded, then check Device.FeatureLevel property.

Happy coding!

Edit

I think I misinterpret your question. You asked about detecting of which version is supported by OS, not by OS + graphics card + driver all together. Maximum supported version are preinstalled with OS, so you only need to know which OS are you on:

OS version                      Version of DX runtime

Windows Vista                   DirectX 10
Windows Vista SP1/SP2           DirectX 10.1
Windows Vista SP2               DirectX 11.0
Windows 7                       DirectX 11.0
Windows 7 SP1                   DirectX 11.0
Windows 7 SP1 with KB2670838    DirectX 11.1
Windows 8 / Windows RT          DirectX 11.1
Windows 8.1 / Windows RT        DirectX 11.2

sources:

You can also query version of d3d11.dll and compare with those which are on wiki page. See:

Community
  • 1
  • 1
Ivan Aksamentov - Drop
  • 12,860
  • 3
  • 34
  • 61
  • thanks! interestingly it reports D3D_FEATURE_LEVEL_10_0 on my windows 7. – clamp Mar 07 '14 at 08:11
  • That means that your graphics card only supports DirectX 10 – Ivan Aksamentov - Drop Mar 07 '14 at 12:30
  • @Drop "Maximum supported version are preinstalled with OS", "Windows 7 SP1 | DirectX 11.1" That's incorrect, right? Win7SP1 still only preinstalls DX11.0. A special "platform update" is required for DX11.1. Source: [Same wiki page](https://en.wikipedia.org/wiki/DirectX#DirectX_11). – Peter Sep 14 '16 at 09:38
  • 1
    @Peter Indeed, looks like Windows SP1 requires an update KB2670838 installed in order to get DirectX 11.1 runtime. See also [here](https://blogs.msdn.microsoft.com/chuckw/2013/02/26/directx-11-1-and-windows-7-update/). I added this information to the answer – Ivan Aksamentov - Drop Sep 14 '16 at 10:52
  • @Drop I just noticed another complication: Feature level is not the same as DirectX version. On my notebook with Windows 10 the DX runtime is 12, the integrated Intel HD 530 card supports feature level 12_1 but the additional NVidia GTX 960M card only supports feature level 11_0! – Peter Sep 14 '16 at 12:59
  • 1
    @Peter Yes, it is by design. (I hint to this in the second phrase in the "Edit" section above). You can write your programs using any API version as long as OS supports it, but feature level (a set of per-defined features you can actually run) is defined by a combination of available API version, hardware and driver capabilities (and possibly other vendor-specific factors). See: [MSDN: Direct3D feature levels](https://msdn.microsoft.com/en-us/library/windows/desktop/ff476876%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396) – Ivan Aksamentov - Drop Sep 14 '16 at 13:12
  • @Drop If a flag (like `D3D11_CREATE_DEVICE_DISABLE_GPU_TIMEOUT`) ["is not supported until Direct3D 11.1"](https://msdn.microsoft.com/en-us/library/windows/desktop/ff476107(v=vs.85).aspx) does that refer to feature level or runtime version? Would it simply ignore the flag on older runtimes or do I really have to check for Win7 KB2670838 first? – Peter Sep 14 '16 at 13:16