Search code examples
directxdirect3ddirect3d11

Can D3D11_CREATE_DEVICE_DISABLE_GPU_TIMEOUT be passed with D3D_FEATURE_LEVEL_11_0?


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?


Solution

  • 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.