Can D3D11_CREATE_DEVICE_DISABLE_GPU_TIMEOUT be passed with D3D_FEATURE_LEVEL_11_0?

爷,独闯天下 提交于 2020-01-02 09:56:24

问题


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?


回答1:


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.




回答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.




回答3:


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.



来源:https://stackoverflow.com/questions/39491352/can-d3d11-create-device-disable-gpu-timeout-be-passed-with-d3d-feature-level-11

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!