Upravit

Sdílet prostřednictvím


Capability querying

Your application can discover the level of support for resource binding (as well as the level of support for many other features), with a call to ID3D12Device::CheckFeatureSupport.

How to query for the resource binding tier

This first example focuses on resource binding. Each resource binding tier is a superset of lower tiers in functionality, so code that works on a given tier works unchanged on any higher tier.

The resource binding tiers are constants in the D3D12_RESOURCE_BINDING_TIER enumeration.

To query for the resource binding tier, use code such as this. This code example demonstrates the general pattern for querying for any of the various kinds of feature support.

D3D12_RESOURCE_BINDING_TIER get_resource_binding_tier(::ID3D12Device* pIDevice)
{
    D3D12_FEATURE_DATA_D3D12_OPTIONS featureSupport{};
    winrt::check_hresult(
        pIDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS, &featureSupport, sizeof(featureSupport))
    );

    switch (featureSupport.ResourceBindingTier)
    {
    case D3D12_RESOURCE_BINDING_TIER_1:
        // Tier 1 is supported.
        break;

    case D3D12_RESOURCE_BINDING_TIER_2:
        // Tiers 1 and 2 are supported.
        break;

    case D3D12_RESOURCE_BINDING_TIER_3:
        // Tiers 1, 2, and 3 are supported.
        break;
    }

    return featureSupport.ResourceBindingTier;
}

Note that any enumerated constant that you pass (D3D12_FEATURE_D3D12_OPTIONS, in this case) has a corresponding data structure that receives info about that feature or set of features (D3D12_FEATURE_DATA_D3D12_OPTIONS, in this case). Always pass a pointer to the structure that matches the enumerated constant that you pass.

How to query for any feature level

As well as the resource binding tier, there are many other features whose level of support you can query for using the same pattern shown in the code example above. You just pass a different constant from the D3D12_FEATURE enumeration to ID3D12Device::CheckFeatureSupport (to tell the API what feature to request support information on), and you pass a pointer to an instance of the matching structure (in which to receive the requested info).

Hardware support for DXGI Formats

To view tables of DXGI formats and hardware features, refer to these topics.