Manager.CheckDepthStencilMatch Method ()

Determines whether a depth stencil format is compatible with a render target format in a particular display mode.

Overload List

public static bool CheckDepthStencilMatch(int, DeviceType, Format, Format, DepthFormat);
public static bool CheckDepthStencilMatch(int, DeviceType, Format, Format, DepthFormat, out int);

Remarks

The CheckDepthStencilMatch method enables applications to work with hardware that requires that certain depth formats work only with certain render-target formats.

The following C# code fragment demonstrates the use of CheckDeviceFormat to validate a depth stencil format.

              [C#]
              
public void TestFunc()
{
    int result;

    // Test some formats
    IsDepthFormatOK(DepthFormat.D16, Format.X8R8G8B8, Format.A8R8G8B8, out result);

    if (result == (int)ResultCode.NotAvailable)
        System.Windows.Forms.MessageBox.Show(String.Format("The depth stencil format is invalid:  {0}", result));
}

private bool IsDepthFormatOK (DepthFormat depthFmt, Format adapterFmt, Format backbufferFmt, out int result)
{
    AdapterInformation ai = Manager.Adapters.Default;
    
    // Verify that the depth format exists
    if (Manager.CheckDeviceFormat(ai.Adapter, DeviceType.Hardware, adapterFmt, Usage.DepthStencil, ResourceType.Surface, depthFmt, out result))
    {
        // Verify that the depth format is compatible
        if (Manager.CheckDepthStencilMatch(ai.Adapter, DeviceType.Hardware, adapterFmt, backbufferFmt, depthFmt, out result))
        {
            return true;    // if both calls succeed
        }
    }

    return false;   // if either call fails.  NOTE: HRESULT passed back in result
}

The preceding call returns false if depthFmt cannot be used in conjunction with adapterFmt and backbufferFmt.