0

Windows 高级光栅化平台 (WARP)支持各种功能级别,这些功能级别因安装的 DirectX API 版本而异:

  • 安装 Direct3D 11 时的功能级别 9_1、9_2、9_3、10_0 和 10_1
  • 在 Windows 7 上安装 Direct3D 11.1 时,以上所有功能级别加上 11_0
  • 在 Windows 8 上安装 Direct3D 11.1 时,以上所有功能级别加上 11_1

如何通过 WARP 轻松确定可用的功能级别?我知道我可以运行的硬件设备ID3D11Device::GetFeatureLevel,但我没有看到 WARP 的等价物。

4

1 回答 1

2

使用Direct3D 11 Create Device 中的代码,但改用 WARP 设备类型。

D3D_FEATURE_LEVEL lvl[] = {
    D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0,
    D3D_FEATURE_LEVEL_10_1, D3D_FEATURE_LEVEL_10_0 };

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_WARP, nullptr,
    createDeviceFlags, lvl, _countof(lvl),
    D3D11_SDK_VERSION, &pDevice, &fl, &pContext );
if ( hr == E_INVALIDARG )
{
    hr = D3D11CreateDevice( nullptr, D3D_DRIVER_TYPE_WARP, nullptr,
       createDeviceFlags, &lvl[1], _countof(lvl)-1,
       D3D11_SDK_VERSION, &pDevice, &fl, &pContext );
}
if ( FAILED(hr) )
    // error handling

然后查看fl是10.1、11.0还是11.1。我们不需要在其中列出 9.1、9.2 或 9.3 功能级别,lvl因为 WARP 在 Windows 桌面 PC 上至少支持 10.1。为了稳健,我建议也列出 10.0。

于 2015-02-27T05:23:43.887 回答