"Direct3D Feature Level 11 unsupported."Win7+VS2010环境下

"Direct3D Feature Level 11 unsupported." under the environment of Win7 + VS2010

最近才开始学习D3D。我已经按照我正在关注的在线教程设置了我的环境,但是当我 运行 Luna 关于 DX11 的书的第 6 章 BOX 源时出现问题。

当 运行 ("Direct3D Feature Level 11 unsupported.")

时,我得到以下 dialog box

问题代码段:

D3D_FEATURE_LEVEL featureLevel;
HRESULT hr = D3D11CreateDevice(
        0,                 // default adapter
        md3dDriverType,
        0,                 // no software device
        createDeviceFlags, 
        0, 0,              // default feature level array
        D3D11_SDK_VERSION,
        &md3dDevice,
        &featureLevel,
        &md3dImmediateContext);

if( FAILED(hr) )
{
    MessageBox(0, L"D3D11CreateDevice Failed.", 0, 0);
    return false;
}

if( featureLevel != D3D_FEATURE_LEVEL_11_0 )
{
    MessageBox(0, L"Direct3D Feature Level 11 unsupported.", 0, 0);
    return false;
}

我在Whosebug上发现了类似的问题(Two problems while initializing Directx 11.0 - 1.FeatureLevel, 2. 4xMSAA quality), 但答案并不能解决我的问题。我已经更新了我的图形驱动程序。

我使用了DxDiag工具,结果如下:

dxdiag

仅仅因为您的图形驱动程序是最新的,并不意味着它们支持 D3D_FEATURE_LEVEL_11_0。目前尚不清楚您的 DxDiag 实际拥有哪种视频卡,但 HP 3005 MT 的默认规格显示最好的可用卡为 Nvidia 315,它仅支持 DirectX 10.1。

D3D11CreateDeivce 的文档中说明:

If pFeatureLevels is set to NULL, this function uses the following array of feature levels:

{ 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, };

意味着如果您的设备支持这些功能级别中的任何一个,该功能将成功(它将按顺序尝试)。很可能,它给你的设备 featureLevelD3D_FEATURE_LEVEL_10_1(或更低,取决于实际的卡)。是时候买一张新显卡了。

Windows 7 包含 DirectX 11 API,但这并不意味着您拥有支持 DirectX 11 的视频硬件。 DirectX 11(API)支持排列成 Direct3D hardware feature levels. Just because your current driver/card doesn't support 11.0, it may support 10.1 or 10.0 which has many (but not all) the same features.

的一系列视频硬件

On Windows 8 or later, there are additional feature levels beyond 11.0 you can request. By default, if you pass nullptr to the default feature level array, it will only return 9.1, 9.2, 9.3, 10.0, 10.1, or 11.0.

Note that on Windows 7 Service Pack 1, the DirectX 11.1 Runtime can be installed but it does not support the newer driver model. Therefore, you can't use Direct3D hardware Feature Level 11.1--these cards all support 11.0 so you can fallback to that. See DirectX 11.1 and Windows 7. DirectX 11.2 and beyond are not available for Windows 7.

为简单起见,Frank Luna 的消息来源假设您拥有支持 11.0 的视频卡,但您仍然可以使用旧卡做很多事情。有关如何创建具有一系列功能级别的设备的详细信息,请参阅 Anatomy of Direct3D 11 Create Device

或者,您可以获得更新的视频卡。

As you are new to DirectX development, be sure to read Book Recommendations for notes on some aspects of Luna's book that were out-of-date shortly after the print date of the book. You may also want to look at the DirectX Tool Kit tutorials.

最后,考虑转向更新版本的 Visual Studio。至此,现代的大部分DirectX supporting libraries won't build with VS 2010 as it only had a few C++11 draft language features implemented. You should take a look at using VS Community edition只要满足license要求都是免费的。