Selecting a Device
Applications can query hardware to detect the supported Microsoft® Direct3D® device types. This section contains information on the primary tasks involved in enumerating display adapters and selecting Direct3D devices.
An application must perform a series of tasks to select an appropriate Direct3D device. Note that the following steps are intended for a full-screen application. In most cases, a windowed application can skip most of these steps.
- Initially, the application must enumerate the display adapters on the system. An adapter is a physical piece of hardware. Note that the graphics card might contain more than a single adapter, as is the case with a dual-head display. Applications that are not concerned with multimonitor support can disregard this step, and pass D3DADAPTER_DEFAULT to the Direct3D8.EnumAdapterModes method in step 2.
- For each adapter, the application enumerates the supported display modes by calling EnumAdapterModes.
- If required, the application checks for the presence of hardware acceleration in each enumerated display mode by calling Direct3D8.CheckDeviceType. Note that this is only one of the possible uses for CheckDeviceType. For details see Determining Hardware Support.
- The application checks for the desired level of functionality for the device on this adapter by calling the Direct3D8.GetDeviceCaps method. This method filters out those devices that do not support the required functionality. The device capability returned by GetDeviceCaps is guaranteed to be constant for a device across all display modes verified by CheckDeviceType.
- Devices can always render to surfaces of the format of an enumerated display mode that is supported by the device. If the application is required to render to a surface of a different format, it can call Direct3D8.CheckDeviceFormat. If the device can render to the format, then it is guaranteed that all capabilities returned by GetDeviceCaps are applicable.
- Lastly, the application can determine if multisampling techniques, such as full-scene antialiasing, are supported for a render format by using the Direct3D8.CheckDeviceMultiSampleType method.
After completing the above steps, the application should have a list of display modes in which it can operate. The final step is to verify that enough device-accessible memory is available to accommodate the required number of buffers and antialiasing. This test is necessary because the memory consumption for the mode and multisample combination is impossible to predict without verifying it. Moreover, some display adapter architectures might not have a constant amount of device-accessible memory. This means that an application should be able to report out-of-video-memory failures when going into full-screen mode. Typically, an application should remove full-screen mode from the list of modes it offers to a user, or it should attempt to consume less memory by reducing the number of back buffers or using a less expensive multisampling technique.
A windowed application performs a similar set of tasks.
- It determines the desktop rectangle covered by the client area of the window.
- It enumerates adapters, looking for the adapter whose monitor covers the client area. If the client area is owned by more than one adapter, then the application can choose to drive each adapter independently, or to drive a single adapter and have Direct3D transfer pixels from one device to another at presentation. The application can also disregard steps one and two and use the D3DADAPTER_DEFAULT adapter. Note that this might result in slower operation when the window is placed on a secondary monitor.
- The application should call CheckDeviceType to determine if the device can support rendering to a back buffer of the specified format while in desktop mode. Direct3D8.GetAdapterDisplayMode can be used to determine the desktop display format.