Aracılığıyla paylaş


Developing for different Direct3D feature levels (DirectX and C++)

[ This article is for Windows 8.x and Windows Phone 8.x developers writing Windows Runtime apps. If you’re developing for Windows 10, see the latest documentation ]

Windows 8 supports a wide range of hardware configurations, from power efficient Windows RT systems to high-end gaming desktops with multiple graphics processing units (GPUs). Understanding how to optimize across many devices that have different levels of graphics performance will enable you to reach a wider audience for your Windows Store app using DirectX with C++.

The Direct3D 11 API uses feature levels to categorize the Direct3D graphics features supported by different graphics hardware. Each iteration of Direct3D has brought not only different graphics features (such as geometry and tessellation), but different approaches to rendering as well (such as support for more instructions and larger textures).

Note  The Direct3D feature levels only apply to Windows Store apps using DirectX. If you are developing a Windows Store app using JavaScript or Windows Store app using C++, C#, or Visual Basic, the feature levels do not apply to it.

 

Note  All Windows Phone devices only support feature level 9_3.

For a complete overview of what features are supported by each Direct3D feature level, see Direct3D 11 Feature Levels.

In this section

Topic Description

Publishing to the Windows Store

There are some requirements you must consider when you are building a Windows Store app using DirectX that you plan on publishing to the Windows Store. This topic discusses how to specify the minimum Direct3D feature level that your application supports, and how to publish that information in your app description on the Windows Store.

Implementing shadow buffers

To develop a Windows Runtime app using DirectX with C++ that renders shadows effects and that uses a Direct3D feature level of 9_1, 9_2, or 9_3, you must use a specific subset of Direct3D 10_0+ shadow buffer features to correctly implement shadow effects. Here we talk about implementing shadow buffers for Direct3D feature level 9.

 

Best practices for feature level support

To target the widest range of devices (and thus a larger potential audience), ensure that your app runs on the minimum hardware configuration for Windows 8 (and therefore Windows RT) devices, which specifies a minimum feature level of 9_1 and 1 gigabyte (GB) of RAM. With this baseline, you can add in support for higher feature levels, and take advantage of the expanded processing and performance added by advanced hardware, perhaps even as a separate render path in your code. (See the Resources section for links to samples and more information.) This not only allows customers with power-efficient devices to play your game, but customers with advanced hardware can take advantage of their own device's additional power and characteristics.

Here are some hardware features to consider when designing for higher-performance hardware:

  • Larger (or more high fidelity) textures
  • More detailed models/meshes
  • Additional MIP levels
  • Advanced shader models
  • More sophisticated shader behaviors (more instructions per shader for more computationally complex effects)
  • Geometry shaders
  • Compute shaders
  • Tesselation
  • Additional post-processing and full-screen shader effects

Because Windows RT devices are not required to support feature levels higher than 9_1, DirectX applications that target the Windows RT architecture must target feature level 9_1. To reach the largest audience, target the 9_1 feature set for your games and apps as a baseline for all CPU architectures. Create a more visually advanced game, using the 10_0 or higher feature levels for devices that support it. If your game requires a higher feature level than the device it's running on is capable of, use Direct2D to display a warning on 9_1 systems if your app requires a higher feature level. We recommend that you use the following technique to achieve this.

// This array defines the set of Direct3D hardware feature levels this app will support.
// Note the ordering should be preserved.
// Don't forget to declare your application's minimum required feature level in its
// description.  All applications are assumed to support 9.1 unless otherwise stated.
D3D_FEATURE_LEVEL featureLevels[] =
{
    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
};

// Create the DX11 API device object, and get a corresponding context.
ComPtr<ID3D11Device> device;
ComPtr<ID3D11DeviceContext> context;

D3D11CreateDevice(
    nullptr,                    // specify null to use the default adapter
    D3D_DRIVER_TYPE_HARDWARE,
    0,                          // leave as 0 unless software device
    creationFlags,              // optionally set debug and Direct2D compatibility flags
    featureLevels,              // list of feature levels this app can support
    ARRAYSIZE(featureLevels),   // number of entries in above list
    D3D11_SDK_VERSION,          // always set this to D3D11_SDK_VERSION for Windows Store apps
    &device,                    // returns the Direct3D device created
    &m_featureLevel,            // returns feature level of device created
    &context                    // returns the device immediate context
);

// ...

if (d3dDevice->GetFeatureLevel() < APP_MIN_FEATURE_LEVEL)
{
    // display warning using Direct2D
} 

Be aware that you call D3D11CreateDevice to request the feature level(s) for your Windows Store app using DirectX, as shown in the example above.

When testing your game, you can force a system with a higher feature level hardware to emulate a lower feature level using the dxcpl.exe tool included with Microsoft Visual Studio. For example, using dxcpl.exe, you can force an 11_1 device to emulate a 9_1 device. If you are planning to support Windows RT devices or lower feature level platforms, make this tool an integral part of your test process.

Resources

The Direct3D simple sprite sample and Direct3D HLSL fractal generator sample demonstrate these methods for adapting to different DirectX feature levels.

Developing apps (C++ and DirectX)