Share via


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

Specifies whether a hardware-accelerated device type can be used on the current adapter.

Definition

Visual Basic Public Shared Function CheckDeviceType( _
    ByVal adapter As Integer, _
    ByVal checkType As DeviceType, _
    ByVal displayFormat As Format, _
    ByVal backBufferFormat As Format, _
    ByVal windowed As Boolean, _
    ByRef result As Integer _
) As Boolean
C# public static bool CheckDeviceType(
    int adapter,
    DeviceType checkType,
    Format displayFormat,
    Format backBufferFormat,
    bool windowed,
    out int result
);
C++ public:
static bool CheckDeviceType(
    int adapter,
    DeviceType checkType,
    Format displayFormat,
    Format backBufferFormat,
    bool windowed,
    [Out] intresult
);
JScript public static function CheckDeviceType(
    adapter : int,
    checkType : DeviceType,
    displayFormat : Format,
    backBufferFormat : Format,
    windowed : boolean,
    result : int
) : 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.
checkType Microsoft.DirectX.Direct3D.DeviceType
Member of the DeviceType enumeration that indicates the device type to check.
displayFormat Microsoft.DirectX.Direct3D.Format
Member of the Format enumeration that indicates the format of the adapter display mode for which the device type is being checked. For example, some devices operate only in modes of 16 bits per pixel.
backBufferFormat Microsoft.DirectX.Direct3D.Format
Back buffer format. For more information about formats, see Format. This value must be one of the render target formats. Device.DisplayMode can be used to obtain the current format.

For windowed applications, the back buffer format does not need to match the display mode format if the hardware supports color conversion. The set of possible back buffer formats is constrained, but the runtime allows any valid back buffer format to be presented to any desktop format. Additionally, the device must be operable in desktop mode because devices typically do not operate in modes of 8 bits per pixel.

Full-screen applications cannot perform color conversion.

Format.Unknown is allowed for windowed mode.
windowed System.Boolean
Set to true if the device type will be used in windowed mode. Set to false if the device type will be used in full-screen.
result System.Int32
HRESULT code passed back from the method.

Return Value

System.Boolean
Returns true if the method succeeds and the device can be used on this adapter; false if the method fails. Check the result parameter for the HRESULT code returned.

If the method fails, result is set to ResultCode.InvalidCall, provided adapter equals or exceeds the number of display adapters in the system. ResultCode.InvalidCall also is returned if CheckDeviceType specified a device that does not exist.

If the requested back buffer format is not supported, or if hardware acceleration is not available for the specified formats, result is set to ResultCode.NotAvailable.

Remarks

A hardware abstraction layer (HAL) device type requires hardware acceleration. Applications can use Manager.CheckDeviceType to determine whether the hardware and drivers necessary to support a HAL device are present.

Full-screen applications should not specify a displayFormat that contains an alpha channel; doing so will result in a failed call. Note that an alpha channel can be present in the back buffer, but the two display formats must be identical in all other respects. For example, if displayFormat = Format.X1R5G5B5, valid values for backBufferFormat include Format.X1R5G5B5 and Format.A1R5G5B5 but exclude Format.R5G6B5.

The following C# code fragment demonstrates the use of CheckDeviceType to determine whether a certain device type can be used on the adapter.

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

    // Test some formats
    IsDeviceTypeOK(Format.X8R8G8B8, Format.A8R8G8B8, out result);

    if (result != (int)ResultCode.Success)
        System.Windows.Forms.MessageBox.Show(String.Format("The device check failed:  {0}", result));
}

public bool IsDeviceTypeOK (Format displayFmt, Format backbufferFmt, out int result)
{
    AdapterInformation ai = Manager.Adapters.Default;

    // Verify that the device can be used on the default adapter with the given surface format
    if (Manager.CheckDeviceType(ai.Adapter, DeviceType.Hardware, displayFmt, backbufferFmt, false, out result))
    {
        return true;    // if the call succeeds
    }

    return false;   // otherwise fail.  NOTE: HRESULT passed back in result
}

The preceding code returns true if the device can be used on the default adapter with the specified surface format.

Using Manager.CheckDeviceType to test for compatibility between a back buffer that differs from the display format returns appropriate values. This means that the call reflects device capabilities. If the device cannot render to the requested back-buffer format, result is still set to ResultCode.NotAvailable. If the device can render to the format but cannot perform the color-converting presentation, result is also set to ResultCode.NotAvailable. Applications can discover hardware support for the presentation itself by calling Manager.CheckDeviceFormatConversion. No software emulation for the color-converting presentation itself is offered.