Dual monitors and full screen input issues

Started by
26 comments, last by JoshuaBaker 11 years, 8 months ago
I came across the issue in another thread involving mouse cursors. It grew into a wider problem so I thought it deserved its own thread.

I am running a dual monitor setup and my code is using slimdx and c#. When I run the code in fullscreen mode I get a ridiculous amount of choppyness when ever I move the mouse or hold down a key. When I am no longer sending input event everything is silky smooth. This problem does not show up in window mode or if I DISCONNECT MY SECOND MONITOR o.0 this is causing me no end of confusion any help would be appreciated
Advertisement
Are you detecting user input through the mouse/keyboard? In other words, are you processing user input in an event?
Yes I am hooked into the form events.
What does your message loop look like?
Mike Popoloski | Journal | SlimDX

What does your message loop look like?


Thanks for trying to help Mike, hopefully you can help figure out where iv gone wrong...
My message loop looks like this.


public void Run() {
Initialize();
Load();
Stopwatch time = Stopwatch.StartNew();
const float deltaTime = 0.03f;
float oldTime = 0.0f;
float newTime = 0.0f;
float frameTime = 0.0f;
float accumulator = 0.0f;
MessagePump.Run(Form, () => {
newTime = (float)time.Elapsed.TotalSeconds;
frameTime = newTime - oldTime;
oldTime = newTime;
accumulator += frameTime;
while (accumulator >= deltaTime) {
_update(deltaTime);
accumulator -= deltaTime;
}
if(GraphicsDevice.IsDeviceLost()) {
Thread.Sleep(100);
}
else {
GraphicsDevice.ClearBuffer(Color.Black);
_render(accumulator / deltaTime);
GraphicsDevice.PresentBuffer();
}
});
time.Stop();
Unload();
}


I am implementing the fixed time-step from gafferongames (attempting to if i got it all wrong smile.png ) Some of the lost device stuff is inside my GraphicsDevice class if you think the culprit is something to do with that i can post more information.
Nothing looks wrong there. It's weird that a second monitor would cause issues. Are you making sure that the device you create uses the right adapter for the monitor it's on?
Mike Popoloski | Journal | SlimDX
As far as i know it is, it's my main monitor and I have the adaptor set for 0


Device = new Device(direct3d, 0, DeviceType.Hardware, _form.Handle, CreateFlags.HardwareVertexProcessing, fullscreenparameters);


I tried playing around with the adapter, tried setting it to 1 (my second monitor) and it showed up there ok, oddly it seemed to lessen the effect, I still had some jumpy movement every few seconds when moving the mouse, but it was dramatically different. I then turned on GPU aspect scaling for the second monitor (it was stretching it before) and the horrible effects started to happen on that monitor. o.0 Turning off GPU scaling on my primary monitor didnt change anything.

Then I did another test....if i set


fullscreenparameters.PresentationInterval = PresentInterval.Default;

TO

fullscreenparameters.PresentationInterval = PresentInterval.Immediate;


Everything is perfect, no problems at all, so v-sync seems to cause me some problem. o.0 Perhaps it is the root culprit in some way.

Dual Monitors + Fullscreen + PresentInterval.Default = Choppy rendering when I receive input events :/
Change any variable and everything is peachy LOL weird.
Maybe you have a bad driver. Make sure your driver is up-to-date and that you've installed all updates for your system.
Mike Popoloski | Journal | SlimDX
Everything is up to date, i did some more digging and found this
http://www.gamedev.net/topic/592845-vsync-causing-input-lag/

It starts as a lag problem, which is not really what i am seeing, input is pretty responsive, it just causes stuttering, but he later finds that the problem goes away when disconnecting his second monitor. Zone seems to blame it on the message queue, does the message queue in the Form get cleared out each iteration? It seems like slimdx is passing alot of message onto the base Form class.
To narrow down your problem I would remove everything from your render loop, then add functionality back one by one, testing for the lag. There is really only a couple of things that can be the problem:

  • Garbage collection (if the lag is random)
  • CPU is outrunning the GPU (consider a new thread for a message queue that can process the input)
  • Bad driver


In any event you should use PIX to profile your code and see where the delay is coming from.

I have 2 monitors and have never had this problem. When I ask DX for a list of adapters there are 2 adaptors returned with the same name and if I choose the second one the device creation fails so I use the default without issue. DX will give you the default adaptor.

It also might be helpful if you post more information about your rig, like your graphic card, monitors and OS info.

This topic is closed to new replies.

Advertisement