mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-12-23 14:21:57 +00:00
[client] adjusted presentation time to be more accurate
This commit is contained in:
parent
032602f336
commit
1d5f98db32
1 changed files with 9 additions and 11 deletions
|
@ -161,19 +161,17 @@ inline uint64_t microtime()
|
||||||
|
|
||||||
uint64_t detectPresentTime()
|
uint64_t detectPresentTime()
|
||||||
{
|
{
|
||||||
// warm up first as the GPU driver may have multiple buffers
|
|
||||||
for(int i = 0; i < 10; ++i)
|
|
||||||
SDL_RenderPresent(state.renderer);
|
|
||||||
|
|
||||||
// time 10 iterations and compute the average
|
|
||||||
const uint64_t start = microtime();
|
|
||||||
for(int i = 0; i < 10; ++i)
|
|
||||||
SDL_RenderPresent(state.renderer);
|
|
||||||
const uint64_t t = (microtime() - start) / 10;
|
|
||||||
|
|
||||||
// ensure all buffers are flushed
|
|
||||||
glFinish();
|
glFinish();
|
||||||
|
|
||||||
|
// time 20 iterations and compute the average
|
||||||
|
const uint64_t start = microtime();
|
||||||
|
for(int i = 0; i < 20; ++i)
|
||||||
|
{
|
||||||
|
SDL_RenderPresent(state.renderer);
|
||||||
|
glFinish();
|
||||||
|
}
|
||||||
|
const uint64_t t = (microtime() - start) / 20;
|
||||||
|
|
||||||
DEBUG_INFO("detected: %lu (%f Hz)", t, 1000000.0f / t);
|
DEBUG_INFO("detected: %lu (%f Hz)", t, 1000000.0f / t);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue