Jump to content
  • Advertisement
Sign in to follow this  
cottonvibes

How to get vsync rate in Directx9

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

Hey guys I'm wondering if there's any method directx9 (or windows) provides to give me a precise vsync rate value.

I've seen some windows code to give me the monitor refresh rate in hz as an integer, but i want something more precise than that.
When i enable vsync in my app it really limits the fps to 59.94hz, whereas all the example code i've seen so far will report that the refresh rate is 60hz.
I want a function that will give me the precise "59.94" value, instead of the inaccurate "60" value.

So any method/function i can use to give me a precise value?
Thanks in advance

Edited: Clarified what i meant.

Share this post


Link to post
Share on other sites
Advertisement
Wouldn't 59.94 be the precise value? I think you are looking at it being exactly 60.00hz... am I wrong? From my understanding most monitors aren't exactly 60hz but rather 59.XX.

Share this post


Link to post
Share on other sites
Ah sorry what i wrote was a bit confusing.
I meant that the functions i've seen will only return "60" as they deal with the hz integer value.
I want a function that will return "59.94".
I want that precise 59.xx value or w/e the monitor is really running at since rounding to the nearest integer value is very inaccurate for anything that requires precise timing.

A hacky way to get this value would be to time the frames myself with vsync enabled using a high precision timer, but I want to know if there's a better way to do this instead of relying on hacks.

Share this post


Link to post
Share on other sites
What do you need the exact timing for? (Using refresh rate to manage the timing of a simulation isn't very common, I don't think.)

Share this post


Link to post
Share on other sites
Agreed w/ jyk. Plus just how precise do you need the measurement? At some level the refresh rate will vary from update to update, even if only one part in a million or something. You're possibly better off measuring update period using a high performance timer and possibly treating the results statistically to get the best estimate.

Share this post


Link to post
Share on other sites

What do you need the exact timing for? (Using refresh rate to manage the timing of a simulation isn't very common, I don't think.)


I'm generating sound samples in real time, and need the measurement to get the average sound samples that will be generated in a second so i can configure directsound and other parts of my program with that information.
i.e. if my program expects to be running at 60.0fps, and then it really runs at 59.9fps then eventually not enough sound samples will have been generated to send to directsound.

I assume then there's no api method to do this then aside from taking measurements myself.


Agreed w/ jyk. Plus just how precise do you need the measurement? At some level the refresh rate will vary from update to update, even if only one part in a million or something. You're possibly better off measuring update period using a high performance timer and possibly treating the results statistically to get the best estimate.


The rate in kHz would probably be sufficient.

I'm going to experiment with changing directsounds' sample rates on the fly based on results from a high precision timer, but i was thinking this might not work out too well.

Share this post


Link to post
Share on other sites
I may be missing something important here, and if I am, I expect someone will offer a correction.

But, what you're describing sounds both atypical and impractical. Is there a reference you're working from that suggests using the refresh rate for timing in this way? Is the objective to v-sync the rendering and then base the timing on the expected elapsed time per update as determined by the monitor refresh rate?

(Again, I may be missing something obvious or important here, in which case please ignore the above.)

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!