Jump to content
  • Advertisement
Sign in to follow this  
BleuBleu

Direct3D Windowed mode + vsync = Jerky

This topic is 2588 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi!

I have a small D3D9 application moving an object at a regular speed. I use the time delta between 2 frame to compute how much my object should be moved. Plain old Euler method.

My application is windowed, vsynced and I use a swap interval of 2. This mean that if my desktop resolution is a 60Hz, my app should run at 30FPS as long as my frametime is less than 33ms, which it is. Nothing special here.

The problem is, every now and then, Direct3D will give me a ridiculously short frametime. Something like 4ms and my object will start to studder. As if the CPU had been able to process the frame very quickly and didnt wait on the GPU. Since I see the object studdering, I assume the frame should be 33ms like every others, but why am I not hitting the vsync and waiting? The problem does not happen in fullscreen mode.

Here is a short snippet of my log file. You can see most frames are exactly 33ms, except some random short frames.


21:33:30: TimeStep: 0.030000
21:33:30: TimeStep: 0.033000
21:33:30: TimeStep: 0.004000
21:33:30: SMALL TIME STEP!!!
21:33:30: TimeStep: 0.030000
21:33:30: TimeStep: 0.033000
21:33:30: TimeStep: 0.035000
21:33:30: TimeStep: 0.032000
21:33:30: TimeStep: 0.033000
21:33:30: TimeStep: 0.034000
21:33:30: TimeStep: 0.033000
21:33:30: TimeStep: 0.003000
21:33:30: SMALL TIME STEP!!!
21:33:30: TimeStep: 0.030000
21:33:30: TimeStep: 0.033000
21:33:30: TimeStep: 0.005000
21:33:30: SMALL TIME STEP!!!
21:33:30: TimeStep: 0.030000
21:33:30: TimeStep: 0.032000
21:33:30: TimeStep: 0.033000
21:33:30: TimeStep: 0.004000
21:33:30: SMALL TIME STEP!!!
21:33:30: TimeStep: 0.030000
21:33:30: TimeStep: 0.033000
21:33:30: TimeStep: 0.003000
21:33:30: SMALL TIME STEP!!!
21:33:30: TimeStep: 0.031000
21:33:30: TimeStep: 0.033000
21:33:30: TimeStep: 0.035000
21:33:30: TimeStep: 0.003000
21:33:30: SMALL TIME STEP!!!
21:33:30: TimeStep: 0.029000
21:33:30: SMALL TIME STEP!!!
21:33:30: TimeStep: 0.033000
21:33:30: TimeStep: 0.034000
21:33:30: TimeStep: 0.032000
21:33:30: TimeStep: 0.004000
21:33:30: SMALL TIME STEP!!!


Can somebody help me understand what is going on?
I've seen other topics about this issue, but I never really read a clear answer on why it does that.

Thanks.

-Mat

Share this post


Link to post
Share on other sites
Advertisement

I didn't think it was posibble to vsync in windowed mode.
From the docs:


Remarks
Windowed mode supports D3DPRESENT_INTERVAL_DEFAULT, D3DPRESENT_INTERVAL_IMMEDIATE, and D3DPRESENT_INTERVAL_ONE. D3DPRESENT_INTERVAL_DEFAULT and the D3DPRESENT_INTERVAL_ONE are nearly equivalent (see the information regarding timer resolution below). They perform similarly to COPY_VSYNC in that there is only one present per frame, and they prevent tearing with beam-following. In contrast, D3DPRESENT_INTERVAL_IMMEDIATE will attempt to provide an unlimited presentation rate.

Full-screen mode supports similar usage as windowed mode by supporting D3DPRESENT_INTERVAL_IMMEDIATE regardless of the refresh rate or swap effect. D3DPRESENT_INTERVAL_DEFAULT uses the default system timer resolution whereas the D3DPRESENT_INTERVAL_ONE calls timeBeginPeriod to enhance system timer resolution. This improves the quality of vertical sync, but consumes slightly more processing time. Both parameters attempt to synchronize vertically.



As for the actual problem; you could try using D3DPRESENT_INTERVAL_ONE and see if that makes things any better. Also, are you rendering anything between Present() calls? You could try removing everything except Clear() and Present() calls and see if that makes a difference.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!