Share via


Manager.CheckDeviceMultiSampleType Method ()

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

Overload List

public static bool CheckDeviceMultiSampleType(int, DeviceType, Format, bool, MultiSampleType);
public static bool CheckDeviceMultiSampleType(int, DeviceType, Format, bool, MultiSampleType, out int, out int);

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.