Share via


Manager.CheckDepthStencilMatch(Int32,DeviceType,Format,Format,DepthFormat,Int32) Method (Microsoft.DirectX.Direct3D)

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

Definition

Visual Basic Public Shared Function CheckDepthStencilMatch( _
    ByVal adapter As Integer, _
    ByVal deviceType As DeviceType, _
    ByVal adapterFormat As Format, _
    ByVal renderTargetFormat As Format, _
    ByVal depthStencilFormat As DepthFormat, _
    ByRef result As Integer _
) As Boolean
C# public static bool CheckDepthStencilMatch(
    int adapter,
    DeviceType deviceType,
    Format adapterFormat,
    Format renderTargetFormat,
    DepthFormat depthStencilFormat,
    out int result
);
C++ public:
static bool CheckDepthStencilMatch(
    int adapter,
    DeviceType deviceType,
    Format adapterFormat,
    Format renderTargetFormat,
    DepthFormat depthStencilFormat,
    [Out] intresult
);
JScript public static function CheckDepthStencilMatch(
    adapter : int,
    deviceType : DeviceType,
    adapterFormat : Format,
    renderTargetFormat : Format,
    depthStencilFormat : DepthFormat,
    result : int
) : boolean;

Parameters

adapter System.Int32
Ordinal number that denotes the display adapter to query. AdapterListCollection.Default is always the primary display adapter.
deviceType Microsoft.DirectX.Direct3D.DeviceType
Member of the DeviceType enumeration that identifies the device type.
adapterFormat Microsoft.DirectX.Direct3D.Format
Member of the Format enumeration that identifies the format of the display mode into which the adapter will be placed.
renderTargetFormat Microsoft.DirectX.Direct3D.Format
Member of the Format enumeration that identifies the format of the render-target surface to be tested.
depthStencilFormat Microsoft.DirectX.Direct3D.DepthFormat
Member of the DepthFormat enumeration that identifies the format of the depth stencil surface to be tested.
result System.Int32
HRESULT code passed back from the method.

Return Value

System.Boolean
Value that is true if the method succeeds; false if it fails. Check the result parameter for the HRESULT code returned. If a depth stencil format is not compatible with the render target in the display mode, result is set to ResultCode.NotAvailable.

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.