如何确定系统DirectX是11还是11.1? [英] How to determine the system DirectX is 11 or 11.1?

查看:1090
本文介绍了如何确定系统DirectX是11还是11.1?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行Windows7。当我使用DxDiag时,它显示的版本为11。

I am running Windows 7. When I use DxDiag, it shows the version as 11.

当我使用可以访问Windows API的Visual Studio 2012时,它可以运行功能级别为D3D_FEATURE_LEVEL_11_1的代码

When I use Visual Studio 2012 which can access Windows API, it can run the code with feature level D3D_FEATURE_LEVEL_11_1

所以我感到困惑,我的DirectX版本的确切版本是什么?

So I agot confused, what is the exact version of my DirectX version?

推荐答案

这里有很多混杂因素在起作用,所以让我们一次来考虑它们:

There are a number of confounding factors at work here, so let's take them one at a time:


  1. DXDIAG与DirectX Runtime一起是OS的一部分,但也为该字符串进行了手动更新,因此,在报告 DirectX消息时通常不够详尽/不准确。版。对于Windows Vista SP1,它不会显示 DirectX 10.1。并说 DirectX 10。同样,对于Windows 8和Windows 7 SP 1 + KB2670838 仍会安装说 DirectX 11而非 DirectX 11.1。在Windows 8.1上,它仍然显示 DirectX 11。而非 DirectX 11.2。简而言之,DXDIAG并非此类技术细节的最佳选择。您可以尝试在Windows 8.1 SDK中使用最新版本的 dxcapsviewer 。在检查内容方面稍微复杂一些,但仍需要随着时间的推移进行手动更新,因此它目前对Windows 10的功能(如DX 11.3或DX 12)一无所知。

  2. 如果您将NULL传递给即使在Windows 8.x上,将pFeatureLevels设置为 D3DCreateDevice ,您仍然不会获得 D3D_FEATURE_LEVEL_11_1 。这是出于向后兼容的原因,并确保行为不会因NULL导致9.1-11.0的情况而改变。您必须手动在数组中列出11.1值才能获得它-假设system + driver组合实际上支持它。请注意,如果确实在数组中包含11.1,则在Windows Vista SP2,Windows 7 RTM或Windows 7 SP1(不带KB2670838)上,调用将失败,并显示 E_INVALIDARG
  3. Windows 7 SP1 + KB2670838提供DirectX 11.1 API,但不支持 D3D_FEATURE_LEVEL_11_1 或任何新的可选硬件功能,因为它不包括支持新的WDDM 1.2驱动程序模型。您必须使用Windows 8或更高版本才能通过WDDM 1.2驱动程序和适当的硬件来获得 D3D_FEATURE_LEVEL_11_1 。请参见 Microsoft文档

  1. DXDIAG is part of the OS along with the DirectX Runtime but is also manually updated for that string, so it is often less than detailed/accurate about reporting "DirectX" version. For Windows Vista SP1 it doesn't say "DirectX 10.1" and says "DirectX 10". Similarly, with both Windows 8 and Windows 7 SP 1 + KB2670838 installed it still says "DirectX 11" and not "DirectX 11.1". On Windows 8.1 it still says "DirectX 11" and not "DirectX 11.2". In short, DXDIAG is not your best option for technical details like this. You could try using the latest version of dxcapsviewer in the Windows 8.1 SDK which is a bit more sophisticated in how it check things, but still needs manually updating over time so it currently says nothing about Windows 10 features like DX 11.3 or DX 12.
  2. If you pass NULL for pFeatureLevels to 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.
  3. Windows 7 SP1 + KB2670838 provides the DirectX 11.1 API, but does not support 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 Docs

通常,为Windows桌面应用程序处理所有这些的正确方法是:

In 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))
   ...

然后如果检测到对Direct3D 11.1的支持,则查看是否可以获得Direct3D 11.1接口:

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 ) );
}

不要基于 Direct3D功能级别安装了什么版本的DirectX,反之亦然。

Don't make assumptions based on Direct3D Feature Level what version of DirectX is installed or vice-versa.


  • Windows 8应用商店应用程序可以假定存在DirectX 11.1,但不能假定任何特定的Direct3D功能级别(尽管9.1是您所见过的最低水平)。

  • Windows 8.1应用商店应用程序可以假定存在DirectX 11.2,但不能再假设任何有关Direct3D功能级别的信息。

  • Windows Phone 8.0应用程序可以假定存在DirectX 11.0,并且设备仅支持9.3。

  • Windows Phone 8.1应用可以假定存在DirectX 11.1,而设备仅支持9.3。

  • Xbox一个应用可以假定DirectX 11.1存在。独占应用可以假定存在FL 11.1。共享应用程序必须使用FL 10.0。

  • Windows 8 Store apps can assume that DirectX 11.1 is present, but can't assume any particular Direct3D Feature Level (although 9.1 is the minimum you'll ever see).
  • Windows 8.1 Store apps can assume DirectX 11.2 is present, but again can't assume anything about Direct3D Feature Level.
  • Windows phone 8.0 apps can assume DirectX 11.0 is present and the devices only support 9.3.
  • Windows phone 8.1 apps can assume DirectX 11.1 is present and the devices only support 9.3.
  • Xbox One apps can assume DirectX 11.1 is present. Exclusive apps can assume FL 11.1 is present. Shared apps have to use FL 10.0.

请参见这篇文章详细介绍了设备创建和DirectX 11.x版本检测的各种细微差别。

See this post for details on the various nuances of device creation and DirectX 11.x version detection.

请参见这篇文章有关Windows 7上DirectX 11.1的重要说明。

See this post and this one for important notes about DirectX 11.1 on Windows 7.

这篇关于如何确定系统DirectX是11还是11.1?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆