Manager.GetDeviceCaps(Int32,DeviceType) Method (Microsoft.DirectX.Direct3D)

How Do I...?

  • Check for Shader Support

Retrieves information specific to a device.

Definition

Visual Basic Public Shared Function GetDeviceCaps( _
    ByVal adapter As Integer, _
    ByVal deviceType As DeviceType _
) As Caps
C# public static Caps GetDeviceCaps(
    int adapter,
    DeviceType deviceType
);
C++ public:
static Caps GetDeviceCaps(
    int adapter,
    DeviceType deviceType
);
JScript public static function GetDeviceCaps(
    adapter : int,
    deviceType : DeviceType
) : Caps;

Parameters

adapter System.Int32
Ordinal number that denotes the display adapter. AdapterListCollection.Default is always the primary display adapter.
deviceType Microsoft.DirectX.Direct3D.DeviceType
Member of the DeviceType enumeration that identifies the device type.

Return Value

Microsoft.DirectX.Direct3D.Caps
If the method succeeds, the return value is a Caps object that contains information that describes the device's capabilities.

Remarks

The application should not assume the persistence of vertex processing capabilities across Microsoft Direct3D device objects. The particular capabilities that a physical device exposes might depend on parameters supplied to Device.Device. For example, the capabilities might yield different vertex processing capabilities before and after creating a Direct3D Device object with hardware vertex processing enabled. For more information, see Caps.

Exceptions

InvalidCallException

Method call is invalid. For example, a method's parameter might contain an invalid value.

InvalidDeviceException

Requested device type is not valid.

OutOfVideoMemoryException

Direct3D does not have enough display memory to perform the operation.

How Do I...?

Check for Shader Support

This example shows how to check the hardware device for shader support.

To determine whether the hardware device supports shaders, Direct3D allows the application to check the shader version.

To check for shader support:

  1. Obtain the device's capabilities by using the Manager.GetDeviceCaps method.
  2. Using the capabilities object obtained with the previous call, check the shader version by calling Caps.VertexShaderVersion.
              [C#]
              

public bool CheckShaderSupport()
{
    Version v1_1 = new Version(1,1); // check version is at least shader 1.1

    // retrieve the device caps
    Caps caps = Manager.GetDeviceCaps(0, DeviceType.Hardware);

    // check the supported shader version
    if ((caps.VertexShaderVersion >= v1_1) && (caps.PixelShaderVersion >= v1_1))
    {
        return true;
    }

    return false;
}