如何使用 Direct3D9 确定哪些显示器连接到同一物理设备?
使用 Direct3D9,我可以使用 IDirect3D9::GetAdapterCount()
对可用适配器进行计数。 然而,这会返回输出的数量,即对于单个双头显卡而言为 2。 使用 Win32 API,我可以使用以下代码片段枚举显示设备和连接的监视器:
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
}
}
我的问题是:D3D 中是否有等效项,如果我随后使用 D3DCREATE_ADAPTERGROUP_DEVICE 创建 D3D 设备,它也可以正常工作代码>? 如果不是,我是否可以对可用于将 Win32 API 结果与 D3D 适配器匹配的设备的枚举顺序做出任何假设? 换句话说:Direct3D 适配器 0 是否保证是 EnumDisplayDevices 返回的第一个适配器?
另外:我刚刚发现,我可以将 D3DADAPTER_IDENTIFIER9
中的设备名称与 Win32 的设备名称相匹配。 但是,有没有办法首先从 D3D 获取物理设备?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果有人感兴趣,我发现了如何做到这一点:
D3DCAPS9
中的NumberOfAdaptersInGroup
包含适配器组主设备的输出数量(具有多个交换的物理设备)链),对于从属(“非物理”适配器)为零。 MSDN 指出:In case someone is interested, I found out how to do it:
NumberOfAdaptersInGroup
in theD3DCAPS9
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: