mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-22 05:27:20 +00:00
[client] adjusted presentation time to be more accurate
This commit is contained in:
parent
032602f336
commit
1d5f98db32
@ -161,19 +161,17 @@ inline uint64_t microtime()
|
||||
|
||||
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();
|
||||
|
||||
// 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);
|
||||
return t;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user