Jump to content
  • Advertisement
Sign in to follow this  
Infinisearch

latching on to vsync

This topic is 1517 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

I don't know if this is the right forum for this, so if a mod could place this in the right forum thank you.

 

Is it possible to be informed of when a vsync happens on a particular monitor?

Share this post


Link to post
Share on other sites
Advertisement

It's really not a good idea unless you're writing a device driver... what do you want to use this for?

 

It's easy to find a lot of old / outdated material on this - e.g.

IDirectDraw::WaitForVerticalBlank

http://www.compuphase.com/vretrace.htm

http://ftp.tuebingen.mpg.de/pub/pub_dahl/stmdev10_D/Matlab6/Toolboxes/Psychtoolbox/PsychDocumentation/BeampositionQueries.m

slightly newer:

D3DPRESENTSTATS / D3DRASTER_STATUS

newer again:

IDXGIOutput::WaitForVBlank

 

But again, this is not something you want to do in 99.9% of cases... There might be an alternative solution to your actual problem.

Share this post


Link to post
Share on other sites


Something like nVidia G-SYNC?

No I mean does the video card send the CPU an interrupt when Vsync occurs and is there a way for the OS to notify your application it just occurred.

 


It's really not a good idea unless you're writing a device driver... what do you want to use this for?

Well I was thinking about sampling input at some multiple of the screen refresh rate and some other timing sensitive thoughts I was mulling over.  But I want the phase of the samples to be in sync with refresh.

Share this post


Link to post
Share on other sites

Well I was thinking about sampling input at some multiple of the screen refresh rate and some other timing sensitive thoughts I was mulling over.  But I want the phase of the samples to be in sync with refresh.

Yeah there's no reliable way to do that, that I know of -- aside from writing a busy loop that eats up 100% CPU usage until the next vblank sad.png 

On older systems, the video-out hardware will send the CPU an interrupt on vblanking, and the CPU will then quickly flip the buffer pointers around.
However, modern systems will not involve the CPU at all -- the CPU will queue up multiple frame's worth of drawing commands to the GPU, and the GPU will be responsible for waiting on vblanks, flipping pointers, and syncing on back/front buffer availability...

By isolating these details inside the device drivers, the OS is able to evolve in this way... instead of being stuck with the old interrupt model, wasting CPU time, for the sake of compatibility with old software wink.png

 

You probably just want to create a background thread, and put it to sleep with small intervals similar to the refresh rate.

e.g. in doom 3, their input gathering thread is hard-coded to 16.66ms / 60Hz.

Edited by Hodgman

Share this post


Link to post
Share on other sites


newer again:
IDXGIOutput::WaitForVBlank


 But I want the phase of the samples to be in sync with refresh.


You probably just want to create a background thread, and put it to sleep with small intervals similar to the refresh rate.

Sounds like a plan, although it will probably stray after some time.  Thanks for your help Hodgman, by chance do you have a good resource on timing related calls windows exposes?  Also it was a long time ago but IIRC there was problems with time returned (i think the perf counters) when power management was enabled (clock throttling), do you know if these problems were fixed in hardware or software? or is this something I'll have to take into account myself?

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!