ValveSoftware / openvr

OpenVR SDK
http://steamvr.com
BSD 3-Clause "New" or "Revised" License
6.12k stars 1.28k forks source link

OpenVR can only run Vive (DirectX11) on primary adapter? #361

Open CUSkidmore opened 7 years ago

CUSkidmore commented 7 years ago

We frequently run Vive on machines with multiple video cards. Using DirectX11/Win 7, there are two ways to create the D3D11 device:

Simple way, supports primary device only: D3D11CreateDevice (NULL, D3D_DRIVER_TYPE_HARDWARE, etc . . .

Generic way, which supports any number of devices:

IDXGIAdapter *adapter;  // obtained from EnumAdapters
D3D11CreateDevice (adapter, D3D_DRIVER_TYPE_UNKNOWN, etc . . .

When using the generic method, even for the primary adapter, IVRCompositor::Submit fails with the error: _VRCompositorErrorSharedTexturesNotSupported. The workaround is to only run on the primary adapter using the simple method. Is this a known limitation?

miker-constructive commented 7 years ago

As an adjunct to this question, if it turns out that we can't currently specify the device we are running on, we would like to be able to query for the device the HMD is on. Something similar to the windows EnumDisplayDevices and then hunt for the HMD could be used for this I guess, but it is windows specific.

aleiby commented 7 years ago

Make sure you call CreateDXGIFactory1 (note the 1 at the end) before D3D11CreateDevice. This ensures you are using DXGI1.1 (instead of the default DXGI1.0). Shared textures are only supported in DXGI1.1 or newer, and OpenVR relies on shared textures to communicate between the application and compositor.

CUSkidmore commented 7 years ago

Thanks aleiby, that fixed it. I was using CreateDXGIFactory to create a IDXGIFactory2 interface - switching to CreateDXGIFactory1 now allows me to use the generic method mentioned above. With that, and VR_IsHmdPresent IVRSystem::GetDXGIOutputInfo (which returns the adapter ID of the HMD), it should be easy to scan for HMDs as suggested by miker.