   [MDX 2.0] Multi Head Rendering
  Hi,I'm trying to recreate the ATI Multi Head example in C# and MDX 2.0 and I'm coming across some problems.When I try to create the Device I'm getting an InvalidCallExecption being thrown. In the output window I get a message saying "Please turn on unmanaged debugging for more information" but when I set the D3D Runtime to Debug mode the program just hangs on the Device creation line.This is the section of code I use to create my device...PresentParameters[] presentParameters = new PresentParameters[Manager.Adapters.Count];for (int i = 0; i < Manager.Adapters.Count; i++){    DisplayMode mode = Manager.Adapters.CurrentDisplayMode;    presentParameters = new PresentParameters();    presentParameters.BackBufferWidth = mode.Width;    presentParameters.BackBufferHeight = mode.Height;    presentParameters.BackBufferFormat = mode.Format;    presentParameters.BackBufferCount = 1;    presentParameters.MultiSampleType = MultiSampleType.None;    presentParameters.MultiSampleQuality = 0;    presentParameters.SwapEffect = SwapEffect.Flip;    presentParameters.IsWindowed = false;    presentParameters.EnableAutoDepthStencil = false;    presentParameters.FullScreenRefreshRateInHz = mode.RefreshRate;    presentParameters.PresentationInterval = PresentInterval.Immediate;}CreateFlags createFlags = CreateFlags.AdapterGroupDevice | CreateFlags.HardwareVertexProcessing;device = new Device(0, DeviceType.Hardware, this.Handle, createFlags, presentParameters);I've tried it with MDX 1 (v 1.0.2902) but I get the same result.Does anyone have any ideas what I might be doing wrong? Has anyone ever got Multi Head working with MDX?I've uploaded my project files here, so if someone could have a look and see if they get any debug output that would be great.   
  I don't exactly know what you're trying to do, but when you specify a device not to be windowed, the handle must be a top form, I mean, the parent control in your project.   ;  Thanks for the reply!Quote:Original post by DreamyI don't exactly know what you're trying to do, but when you specify a device not to be windowed, the handle must be a top form, I mean, the parent control in your project.I'm trying to create enough PresentParameters for each adapter so I can render to two screens at once. Once the device is created I can get then get a swap chain for each screen and from tjhat the back buffer to render to.The class this code is in extends System.Windows.Forms.Form so this.Handle in the device creation call is getting the handle of the form which is the top most control.[Edited by - Mrs Kensington on June 18, 2006 4:38:34 AM];  I doubt this would be it, but try using AdapterCollection.Default.Adapter instead of 0 for the adaptor Id. Maybe it isn't 0?I assume the same code works fine when you're not using multihead (no AdapterGroupDevice flag and the PresentationParameters isn't an array).Also, try a different swap effect (Discard is likely most supported). Maybe flip isn't supported in multi-head mode on your card, or something of the likes.Lastly, try providing an AutoDepthStencil format even though you're not using it. I seem to recall something about having to fill that in even if the enable is false, though I could be wrong.If none of these things help, maybe you should try the DIRECTXDEV mailing list.Hope this helps.   ;  You need one form per head and set the handle to this form in the present structure for this head. Your code sample misses this.   ;Quote:Original post by DemirugYou need one form per head and set the handle to this form in the present structure for this head. Your code sample misses this.OK that makes sense... my code now does this...presentParameters = new PresentParameters[Manager.Adapters.Count];forms = new Form[Manager.Adapters.Count];for (int i = 0; i < Manager.Adapters.Count; i++){    DisplayMode mode = Manager.Adapters.CurrentDisplayMode;    presentParameters = new PresentParameters();    forms = new Form();    presentParameters.BackBufferWidth = mode.Width;    presentParameters.BackBufferHeight = mode.Height;    presentParameters.BackBufferFormat = mode.Format;    presentParameters.BackBufferCount = 1;    presentParameters.MultiSampleType = MultiSampleType.None;    presentParameters.MultiSampleQuality = 0;    presentParameters.SwapEffect = SwapEffect.Flip;    presentParameters.IsWindowed = false;    presentParameters.EnableAutoDepthStencil = false;    presentParameters.FullScreenRefreshRateInHz = mode.RefreshRate;    presentParameters.PresentationInterval = PresentInterval.Immediate;    presentParameters.DeviceWindowHandle = forms.Handle;}CreateFlags createFlags = CreateFlags.AdapterGroupDevice | CreateFlags.HardwareVertexProcessing;device = new Device(0, DeviceType.Hardware, forms[0].Handle, createFlags, presentParameters);I now get a grey form showing on one screen but it then freezes and the only way I get stop it is to do a Shift-F5 to stop debugging.I've also tried setting the Owner property of the second form to the first form as the ATI example does. But that doesn't change anything (I originally tried setting its Parent property and it throw an exception then).Any ideas? I feel I am getting close but probably missing one thing. If you want I can upload my latest code as well.Edited:@sirob: Sorry I originally missed your post I'll have a look into your suggestions now.   ;Quote:Original post by NamethatnobodyelsetookAnother little note that's hidden away in the SDK somewhere. When attempting to create two devices, the creation of the second will cause a lost device of the first. Simply "Create A", "Create B", "Reset A" to have both devices active.This may have been an odd DX8 thing, and may be gone in DX9. I just thought I'd warn you ahead of time.This was posted elsewhere on these forums and seems like sound advice. You'd probably want to try that out too.Hope this helps.   ;Quote:Original post by sirobI doubt this would be it, but try using AdapterCollection.Default.Adapter instead of 0 for the adaptor Id. Maybe it isn't 0?It didn't help but its probably a good thing to use anyway, thanks for the suggestion.Quote:I assume the same code works fine when you're not using multihead (no AdapterGroupDevice flag and the PresentationParameters isn't an array).Yes I believe so...Quote:Also, try a different swap effect (Discard is likely most supported). Maybe flip isn't supported in multi-head mode on your card, or something of the likes.The ATI example used Flip and that works fine on my system but I've tried Discard and that didn't solve it...Quote:Lastly, try providing an AutoDepthStencil format even though you're not using it. I seem to recall something about having to fill that in even if the enable is false, though I could be wrong.Yep that seemed to be it, I now have my two monitors, one showing Corn Flower Blue and one Dark Turquise. For some reason I have the cursor showing, but I think Visual Studio is trying to tell me something that I can't see so I'll have to try setting up remote debugging with my laptop.Thanks for the help guys! You've been brilliant!   