2

MSDN on D3D11_CREATE_DEVICE_DISABLE_GPU_TIMEOUT says:

Direct3D 11: This value is not supported until Direct3D 11.1.

Does this mean runtime version or feature level?

Can I pass the flag to D3D11CreateDevice but only pass feature level 11_0?

Is the feature level irrelevant and it just depends on the installed runtime version? What happens if I pass the flag to a DX runtime 11.0? Will it just be ignored silently? Or do I first have to detect the DX runtime version somehow, and then pass the flag only if the DX runtime version is at least 11.1?

Peter
  • 3,322
  • 3
  • 27
  • 41
  • See [Direct3D Feature Levels](https://blogs.msdn.microsoft.com/chuckw/2012/06/20/direct3d-feature-levels/) and [Anatomy of Direct3D 11 Create Device](https://blogs.msdn.microsoft.com/chuckw/2014/02/05/anatomy-of-direct3d-11-create-device/). – Chuck Walbourn Sep 15 '16 at 16:54

3 Answers3

3

The 'correct' way to determine if you have the Direct3D 11.1 Runtime would be as follows:

#include <d3d11_1.h>
#include <wrl/client.h>

#pragma comment(lib,"d3d11.lib")

bool IsDirect3D11_1OrGreater()
{
    Microsoft::WRL::ComPtr<ID3D11Device> device;

    HRESULT hr = D3D11CreateDevice(
        nullptr,
        D3D_DRIVER_TYPE_NULL,
        nullptr,
        0,
        nullptr,
        0,
        D3D11_SDK_VERSION,
        device.GetAddressOf(),
        nullptr,
        nullptr
        );

    if (FAILED(hr))
        return false;

    Microsoft::WRL::ComPtr<ID3D11Device1> device1;
    return SUCCEEDED(device.As(&device1));
}

You then call IsDirect3D11_1OrGreater. If it's true, then you are safe to use a flag like D3D11_CREATE_DEVICE_DISABLE_GPU_TIMEOUT that requires the Direct3D 11.1 Runtime

Keep in mind that you shouldn't be using D3D11_CREATE_DEVICE_DISABLE_GPU_TIMEOUT as a matter of course. It really only should be used for DirectCompute-heavy programs that are free to tie up the GPU a lot and potentially cause the system to become unresponsive to UI. Use it with caution.

That also implies your application will require a Direct3D Feature Level 11.0 or greater card to use DirectCompute 5.0 -or- it will require Direct3D Feature Level 10.0 and need to do a CheckFeatureSupport(D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS, ...) call and verify D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS.ComputeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x is true for DirectCompute 4.0.

If IsDirect3D11_1OrGreater returns false, then you should tell the user:

This application requires the DirectX 11.1 Runtime. It is supported on
Windows 7 Service Pack 1 with KB2670838 or later Windows operating systems.

See also DirectX 11.1 and Windows 7 and DirectX 11.1 and Windows 7 Update.

Community
  • 1
  • 1
Chuck Walbourn
  • 38,259
  • 2
  • 58
  • 81
  • This claims D3D11.1 runtime is available on Win7SP1+KB2670838, but passing the `D3D11_CREATE_DEVICE_DISABLE_GPU_TIMEOUT` flag fails there. Any idea why? – Peter Sep 21 '16 at 12:11
  • Sorry, I need to double-check that on my Windows 7 setup. The flag is "known", but it is possible it requires newer drivers which are not supported for Win7SP1+KB2670838. Per [MSDN](https://msdn.microsoft.com/en-us/library/jj863687.aspx) DirectX 11.1 on Win7SP1+KB2670838 provides all the 'software' features but not anything that requires [WDDM 1.2](https://msdn.microsoft.com/en-us/library/windows/desktop/dn653373.aspx) drivers which are not supported on Win7SP1. – Chuck Walbourn Sep 21 '16 at 17:28
  • I've confirmed that you can in fact use the ``D3D11_CREATE_DEVICE_DISABLE_GPU_TIMEOUT `` flag on Windows 7 Service Pack 1 with KB 2670838 installed. – Chuck Walbourn Sep 21 '16 at 22:20
  • Sadly it doesn't always work though, see [comment below](http://stackoverflow.com/questions/39491352/can-d3d11-create-device-disable-gpu-timeout-be-passed-with-d3d-feature-level-11/39524088?noredirect=1#comment66571500_39491570). – Peter Sep 29 '16 at 14:33
  • Hmm, there must be a driver behavior dependacy here as well. Sounds like you have to create the device with the flag and if it fails, retry without it. I'm assuming your application fails without the flag set? – Chuck Walbourn Sep 29 '16 at 15:37
2

This is about runtime version, so you need Windows 8 at least to have this feature enabled.

You can request a Feature Level 11 only device while having this flag, just tried and it worked perfectly.

Otherwise it would be problematic since NVidia card support 11.1 only since their 900x generations.

mrvux
  • 8,523
  • 1
  • 27
  • 61
  • So what happens if the runtime is 11.0? Do I have to detect Win7 platform update somehow first and ensure not to pass the flag if it's missing? – Peter Sep 14 '16 at 13:27
  • To clarify: [900 series Geforce](https://en.wikipedia.org/wiki/GeForce_900_series) cards based on 2nd generation Maxwell chips (GM2xx) support feature level 12_0. 1st generation (GM1xx) supports only 11_0. 960M is based on GM107 (1st generation) – Ivan Aksamentov - Drop Sep 14 '16 at 13:47
  • Yes, that's about it, sadly don't have windows 7 machine anymore so I can't try. – mrvux Sep 14 '16 at 14:03
  • I found a windows 7 machine without DX11.1. Passing the flag fails with `HRESULT: [0x80004005], Module: [General], ApiCode: [E_FAIL/Unspecified error], Message: Unspecified error`. Surprisingly the KB2670838 and IE10 were already installed and d3d11.dll had version 6.2.9200.16570, but DX11.1 was still not installed. – Peter Sep 14 '16 at 14:53
  • Ok that settles it then – mrvux Sep 14 '16 at 14:54
  • A few things to note: KB2670838 requires Windows 7 Service Pack 1. This is not really much of a blocker as Windows 7 RTM is out-of-support entirely, VS 2015 C++ programs can't even run on it. See [this blog](http://blogs.msdn.com/b/chuckw/archive/2012/11/14/directx-11-1-and-windows-7.aspx) and [this](https://blogs.msdn.microsoft.com/chuckw/2013/02/26/directx-11-1-and-windows-7-update/). – Chuck Walbourn Sep 15 '16 at 16:49
  • @ChuckWalbourn This is on a machine with Windows 7 Service Pack 1 and KB2670838 installed. But there is no `d3d11_1.dll` (and no `d3d11_*sdklayers.dll` either). Your `IsDirect3D11_1OrGreater()` check returns `true`. – Peter Sep 21 '16 at 12:01
  • but if I pass the flag it fails (returns `false`) there. (Works and returns `true` on Win10.) – Peter Sep 21 '16 at 12:07
  • Are you getting ``E_INVALIDARG`` or ``E_FAIL`` back? My suspicion now is that the system has DirectX 11.1 but Windows 7 cannot support WDDM 1.2 drivers. I didn't expect the timeout flag to require new drivers, but it might. Note the ``d3d11_*sdklayers.dll`` is installed by the Windows 8 SDK for Windows 7 SP1+KB2670838. The legacy DirectX SDK does not support DirectX 11.1 or later. – Chuck Walbourn Sep 21 '16 at 17:35
  • I get `E_FAIL`. I found two more machines with Win7SP1+KB2670838. On both `dxdiag.exe` reports Drivers for "Driver Model: WDDM 1.1". Both return `true` for your `IsDirect3D11_1OrGreater()`. Passing the flag succeeds on M2 (NVidia, various SDKs installed) but fails on M3 (ATI, no SDKs) same as on the initial M1 (also Win7SP1+KB, ATI, no SDKs, WDDM1.1). – Peter Sep 22 '16 at 08:03
  • (M1 is NVidia.) – Peter Sep 22 '16 at 08:12
0

It refers to runtime version.

You might detect OS version, but you might go easier by checking installed DirectX runtime .dll version instead, by trying LoadLibrary on:

{ 
    "d3d11.dll",
    "d3d11_1.dll",
    "d3d11.dll",
    "d3d11_1sdklayers.dll",
    "d3d11_2sdklayers.dll",
    "d3d11_3sdklayers.dll",
    "d3d12.dll"
}

sequentially until it fails (returns NULL). Or in reverse order, until it succeeds. This is the same hack as with creating device with highest feature level.

Ivan Aksamentov - Drop
  • 12,860
  • 3
  • 34
  • 61
  • **Never use OS version detection to check for a feature**. See [What’s in a version number?](https://blogs.msdn.microsoft.com/chuckw/2010/02/24/whats-in-a-version-number/). By default you won't even get the "true" OS version number on Windows 8.1 or Windows 10. See [Manifest Madness](https://blogs.msdn.microsoft.com/chuckw/2013/09/10/manifest-madness/). The ``LoadLibrary`` DLL check is also problematic, but at least a better option than trying to infer it from the OS version. A simple solution is create a 11 device, QI a 11.1 device. If it works, you have 11.1 or better. – Chuck Walbourn Sep 15 '16 at 16:53
  • In this case, yes. You should never solve with a ``LoadLibrary`` dependency that you can solve more robustly with a direct feature check. In this case, calling ``QueryInterface`` for a ``ID3D11Device1`` off the ``ID3D11Device`` is the most robust and direct way to see if you have the Direct3D 11.1 Runtime. Yes it means you create the device without the flag, then do it again when you know it works. – Chuck Walbourn Sep 16 '16 at 04:53