Manager.CheckDeviceMultiSampleType(Int32,DeviceType,Format,Boolean,MultiSampleType) Method (Microsoft.DirectX.Direct3D)

Determines whether a multisampling technique is available on the current device.

Definition

Visual Basic Public Shared Function CheckDeviceMultiSampleType( _
    ByVal adapter As Integer, _
    ByVal deviceType As DeviceType, _
    ByVal surfaceFormat As Format, _
    ByVal windowed As Boolean, _
    ByVal multiSampleType As MultiSampleType _
) As Boolean
C# public static bool CheckDeviceMultiSampleType(
    int adapter,
    DeviceType deviceType,
    Format surfaceFormat,
    bool windowed,
    MultiSampleType multiSampleType
);
C++ public:
static bool CheckDeviceMultiSampleType(
    int adapter,
    DeviceType deviceType,
    Format surfaceFormat,
    bool windowed,
    MultiSampleType multiSampleType
);
JScript public static function CheckDeviceMultiSampleType(
    adapter : int,
    deviceType : DeviceType,
    surfaceFormat : Format,
    windowed : boolean,
    multiSampleType : MultiSampleType
) : boolean;

Parameters

adapter System.Int32
Display adapter ordinal number. AdapterListCollection.Default is always the primary display adapter. This method returns ResultCode.InvalidCall when the value equals or exceeds the number of display adapters in the system.
deviceType Microsoft.DirectX.Direct3D.DeviceType
Member of the DeviceType enumeration.
surfaceFormat Microsoft.DirectX.Direct3D.Format
Member of the Format enumeration that specifies the format of the surface to be multisampled. See Remarks.
windowed System.Boolean
Set to true to inquire about windowed multisampling. Set to false to inquire about full-screen multisampling.
multiSampleType Microsoft.DirectX.Direct3D.MultiSampleType
Member of the MultiSampleType enumeration that identifies the multisampling technique to test.

Return Value

System.Boolean
Returns true if the method succeeds; false if it fails. Check the result parameter for the HRESULT code returned.

If the method fails, result is set to one of the following values: ResultCode.InvalidCall if the adapter or multiSampleType parameters are invalid, ResultCode.NotAvailable if the device does not support the queried multisampling technique, or ResultCode.InvalidDevice if deviceType does not apply to the adapter.

Remarks

This method is intended for use with both render-target and depth stencil surfaces because they must be created multisampled to be used together.

The following C# code fragment demonstrates the use of CheckDeviceMultiSampleType to test for devices that support a specific multisampling method.

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

    // Test some formats
    IsDeviceMultiSampleOK(DepthFormat.D16, Format.A8R8G8B8, MultiSampleType.TwoSamples, out result);

    if (result != (int)ResultCode.Success)
        System.Windows.Forms.MessageBox.Show(String.Format("The multisample options are invalid:  {0}", result));
}

public bool IsDeviceMultiSampleOK (DepthFormat depthFmt, Format backbufferFmt, MultiSampleType multisampleType, out int result)
{
    AdapterInformation ai = Manager.Adapters.Default;
    int qualityLevels = 0;

    // Verify that the render target surface supports the given multisample type
    if (Manager.CheckDeviceMultiSampleType(ai.Adapter, DeviceType.Hardware, backbufferFmt, false, multisampleType, out result, ref qualityLevels))
    {
        // Verify that the depth stencil surface supports the given multisample type
        if (Manager.CheckDeviceMultiSampleType(ai.Adapter, DeviceType.Hardware, (Format)depthFmt, false, multisampleType, out result, ref qualityLevels))
        {
            return true;    // if both calls succeed
        }
    }

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

The preceding code returns true if the device supports the full-screen MultiSampleType.TwoSamples multisampling method with the surface format.