Any way to determine the vsync wait time?
Posted: Mon Aug 27, 2018 11:03 pm
tl;dr: I want to determine approximately how much rendering headroom time I have.
Quite some time ago I implemented an adaptive resolution mechanism to adjust the render quality on the fly based on GPU load. However, the big problem with it is that when vsync is on it's difficult to determine how much time is actually being spent on rendering vs. how much is spent simply waiting for vsync. So like if I'm getting 30FPS I don't know if that's because I'm getting a solid 30 or if I could get 60 if I were to just bump my resolution down a little tiny bit (or, conversely, if I'm getting 30FPS I don't know if getting 60 is a lost cause and I could increase my render quality to take advantage of it).
A hack I've used in the short term is to track both the average and variance of the total frame time and if the variance is less than 5% I assume it's sitting stably at the halfway point between vsync intervals, but as you might imagine this doesn't really work all that well.
I can easily determine my update time and deduct that from the frame time to determine render+vsync time (and use that to further determine if it's worth reducing video quality to try to bump up to the next vsync interval), but is there any way to also deduct vsync time? Unfortunately it seems that the entirety of the graphics finalization/buffer swap+vsync are all wrapped up in love.graphics.present() and there's no way I can tell from the API to further pick that apart. I've also tried adding love.graphics.flushBatch() to the end of my love.draw() routine to see if I can capture the timing of that but it doesn't seem to have any significant time usage either.
Quite some time ago I implemented an adaptive resolution mechanism to adjust the render quality on the fly based on GPU load. However, the big problem with it is that when vsync is on it's difficult to determine how much time is actually being spent on rendering vs. how much is spent simply waiting for vsync. So like if I'm getting 30FPS I don't know if that's because I'm getting a solid 30 or if I could get 60 if I were to just bump my resolution down a little tiny bit (or, conversely, if I'm getting 30FPS I don't know if getting 60 is a lost cause and I could increase my render quality to take advantage of it).
A hack I've used in the short term is to track both the average and variance of the total frame time and if the variance is less than 5% I assume it's sitting stably at the halfway point between vsync intervals, but as you might imagine this doesn't really work all that well.
I can easily determine my update time and deduct that from the frame time to determine render+vsync time (and use that to further determine if it's worth reducing video quality to try to bump up to the next vsync interval), but is there any way to also deduct vsync time? Unfortunately it seems that the entirety of the graphics finalization/buffer swap+vsync are all wrapped up in love.graphics.present() and there's no way I can tell from the API to further pick that apart. I've also tried adding love.graphics.flushBatch() to the end of my love.draw() routine to see if I can capture the timing of that but it doesn't seem to have any significant time usage either.