Multi-monitor pain.

So, one of the shortcomings of the original Gorgon was that there was no support for multi-monitor.  And I see now why I didn’t bother… what a pain in the ass.

Anyway, I finally figured it out.  See, there are two ways to do multi-mon support in Direct 3D 9:

  1. Create 2 devices, one for each adapter.  This is actually simple, and is the only way to get multi-mon going for 2 discreet video cards.  The down side is that they can’t share data between them, so you’ll have to double up on your textures, vertices, etc…  if you want to have a copy of the same data on a difference device.  Not ideal, but manageable.  Of course, that’s just getting the 2 devices working in windowed mode…  when you go to full screen mode, then it becomes, in scientific terms, a clusterfuck.  Apparently, you can only have 1 device in full screen at any given time.  However, it’s possible to make both devices full screen if they meet a certain set of conditions:

    * The devices must be created by the same IDirect3D9 object.  –  That’s easy, I did that anyway.
    * The devices must share the same focus window. – Oh, ok… how do I determine which window is the focus window?  Well, for now, it’s the first window that’s created with a IDirect3DDevice9 object attached to it.
    * Must be a different  adapter ID.  – This was actually more of a pain to get around than you might think.

    Anyway, in the end, it works.  You can create multiple windows on multiple monitors and have them in full screen mode.  It was horrible.  And I really don’t know how well this is going to work on multiple physical cards since that’s a setup I don’t have access to.

  2. Create a multi-head device object.  Multi-head cards are the more common cards (look on the back, see a VGA and DVI or 2 DVI connectors?  Yeah, you got a multi-head card).  Direct 3D 9 treats both heads as separate devices for compatibility reasons (and indeed, that’s how the previous method works), but as stated before, we lose shared data with that method.  With a mult-head device we can go full screen on multiple monitors, -and- share the data.  It does this by creating 2 swap chains for the device (one IDirect3DDevice9 object with multiple swap chains).  Sounds good, but in Direct 3D 9, this is not without its own set of caveats:

    * It’s fullscreen only, if you want shared data across multiple heads in windowed mode, use additional swap chains. – Since the heads are driven by the same video card, the multiple swap chained windows will work just fine as is (they’re already sharing a device).  As for full screen, well, you can’t go full screen with an additional swap chain while having the device in full screen (i.e. the implicit swap chain on the device object is already full screen, in essence only one swap chain can be fullscreen at a time).  In the case of multi-head devices, they cheat a little (or that’s how it looks to me) and create 2 swap chains for one device in full screen mode.
    * You cannot create additional swap chains while in fullscreen mode.  – This is not really a big deal, as I limit the creation of multiple swap chains to windowed mode only in Gorgon anyway.
    * You must create swap chains for -all- heads, even if you’re only using 2.  – While this is not that common a scenario, it’s annoying and wasteful.
    * You must destroy the device object and recreate it to switch to windowed mode.  –  This is my biggest annoyance of all, it makes management of these objects quite difficult.  Because of this, I have to rethink how I want to design the implementation for the device objects.   It won’t be fun.

I’ve yet to get the multi-head stuff working the way I want.  As it is, it works, but it’s not very flexible (it’ll crash hard if you try to modify the device, see the last point of item 2).  Compared to Direct 3D 10/11, multiple monitor stuff is needlessly complicated.  The beauty of D3D10 and 11 is that you only need to create swap chains for the video outputs (heads) that you want.  Everything is far more flexible that way.
Anyway, that’s my rant on multiple monitors.

 

2 thoughts on “Multi-monitor pain.

  1. Tape_Worm Post author

    Adapter groups don’t work in windowed mode, they’re only meant for fullscreen, that’s likely why your device creation is failing.

  2. hp

    Hi,

    I am creating an app that is expected to run on 2 monitors. in Windowed mode.
    I have taken an ATI multi-head sample to start with and its working fine. The only problem is that its working in fullscreen mode.
    I tried to create in windowed mode using multiple swap chains but device creation is failing.
    It would of great if you can share some sample code to deal with this issue.
    Thanks in advance

Comments are closed.