Skip to main content
gamedev.net
🔒 Locked

INTERVAL_ONE

Started by PlayGGY Feb 2, 2004 at 11:33 PM 1 replies 1.5k views
Original Post
PlayGGY
PlayGGY
When using that flag, does the program stall while waiting for the monitor to be ready to refresh? Or does it simply not refresh until the monitor is ready? [edited by - PlayGGY on February 2, 2004 12:34:18 AM]
And the rockets' red glare, the bombs bursting in air,gave proof through the fight that our flag was still there.Oh say, does that star-spangled banner yet waveover the land of the free and the home of the brave?
Namethatnobodyelsetook
Namethatnobodyelsetook
It stalls the GPU. The CPU can continue to add more stuff to be rendered. If there are already 3 frames queued up for render the CPU will stall too. The CPU unstalls when something like half the buffer is empty. This can cause problems where you render a few frames quickly, wait, render a few frames quickly, wait, etc... Your animation is based on processing time, not the time things are displayed and you get jerky looking animation, even though you have good framerate.

A trick often used is to lock the back buffer, causing a stall until both GPU and CPU are in sync again. You should delay this as much as possible...ie:

ProcessAI
ProcessSound
ProcessInputs
UpdateObjects
Frustum/Occlusion cull (if software occ. cull like Zhang HOM)
Sort
Lock backbuffer
Unlock backbuffer
Clear
BeginScene
Render
Present
EndScene

By delaying the lock until just before we render we gain GPU parallelism while doing AI,Sound,Input,and render preparation. This means our game must now run slightly better than 60Hz to acheive 60Hz, but it''s better than the jerky animation alternative.
AndyTX
AndyTX
Another (less expensive) way in Direct Draw to resync the devices is to use GetBlitStatus (or GetFlipStatus... I think both will work). Just loop in a while until these return true, the body being "Sleep(1)". The advantage of this is that it will cause your program not to take 100% CPU anymore as well

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.