views:

47

answers:

4

I'm using XNA and creating a bunch of forms that roll their own 'game loop' to handle drawing and such. Each new form is opened on its own thread, with a subsequent Application.Run(form) to make the thread handle the messages for that form.

When I started I noticed that despite me not implementing any kind of frame limiting timing, the window drew at 60 fps. This was the number I was aiming for anyway so I left it at that.

However now I discovered that when I open multiple windows, the original 60 fps gets divided evenly between them: 2 windows 30 each, 3 20 each, etc.

I also tried a loop with Application.DoEvents instead of Application.Run, but with the same results.

Anyone know where this 60fps limit coming from, how to overcome it?

A: 

I'm not an XNA expert, but it sounds that you're being limited by vsync, did you check that?

Matias Valdenegro
A matter of seconds. :-)
JustBoo
A: 

Go to your graphic driver settings window. Turn off VSYNC.

JustBoo
Forced vsync off, still 60 fps at 1 window. Furthermore, why is this number being split evenly between multiple windows each with their own thread? If they were waiting for vsync I'd expect all of them to be at 60.
Bicubic
Possibly your threads are "converging" somewhere. You are getting the behavior of "time-slicing" and there are only so many time-slices, so your fps is reduced. Are you waiting for an event someplace? It’s all “backing up” there.
JustBoo
Thanks to your suggestion I took a deeper dig into XNA and found that the holdup was occuring at GraphcisDevice.Present()The limit can be removed by setting PresentationParameters.PresentationInterval = PresentInterval.ImmediateThe only question that remains is why attempting to present with any other value causes multiple threads to block while multiple XNA processes can run side by side without hitting this.
Bicubic
A: 

You say "forms" which leads me to believe you are running in windows on the desktop and not using a dedicated full screen display?

I believe that with Vista and Windows 7, the desktop compositor ("dwm") handles all of the actual drawing. It probably runs at 60 fps (or less when on battery). I am not sure why it divides the FPS between the two windows, but it could be some interaction of locking between graphics calls.

Zan Lynx
A: 

You can't benefit from multi threading drawing calls to the GPU. The GPU, although very good at parallel processing in it's own right, interacts with the CPU one thing at a time only and everything is blocked until it finishes the task at hand. Two draw calls on one thread will take just as long as two Draw calls on separate threads. Actually slower because of threading overhead.

Steve H