views:

180

answers:

1

Using Direct3D9, I can count the available adapters using IDirect3D9::GetAdapterCount(). However, this returns the number of outputs, i.e. 2 for a single dual-head graphics card. Using Win32 API, I can enumerate the display devices and the monitors attached using the following snippet:

DISPLAY_DEVICE displayDevice;
::ZeroMemory(&displayDevice, sizeof(displayDevice));
displayDevice.cb = sizeof(displayDevice);

/* Enumerate adapters. */
for (UINT i = 0; ::EnumDisplayDevices(NULL, i, &displayDevice, 0); i++) {

    /* Enumerate the monitors. */
    for (UINT j = 0; ::EnumDisplayDevices(displayDevice.DeviceName, j, 
            &displayDevice, 0); j++) {
        // Do stuff here
    } 
}

My questions are: Is there an equivalent for this in D3D, which also works correctly if I create the D3D device afterwards using D3DCREATE_ADAPTERGROUP_DEVICE? If not, are there any assumptions I can make about the enumeration order of the devices which I can use to match the Win32 API results to D3D adapters? In other words: Is the Direct3D adapter 0 guaranteed to be the first adapter returned by EnumDisplayDevices?

Addition: I just found out, that I could match the device name from D3DADAPTER_IDENTIFIER9 to the device name of Win32. However, is there a way to get just the physical devices from D3D in the first place?

A: 

In case someone is interested, I found out how to do it: NumberOfAdaptersInGroupin the D3DCAPS9 contains the number of outputs for the master of an adapter group (physical device with multiple swap chains) and is zero for subordinate ("non-physical" adapters). MSDN states:

NumberOfAdaptersInGroup is 1 for conventional adapters, and greater than 1 for the master adapter of a multihead card. The value will be 0 for a subordinate adapter of a multihead card. Each card can have at most one master, but might have many subordinates.

Christoph