[client] main: dont push an invalid value into the timings buffers

This commit is contained in:
Geoffrey McRae 2021-07-10 14:20:28 +10:00
parent 23f9855768
commit 8e3df5a38f
2 changed files with 16 additions and 4 deletions

View File

@ -152,8 +152,13 @@ static int renderThread(void * unused)
const uint64_t t = nanotime(); const uint64_t t = nanotime();
const uint64_t delta = t - g_state.lastRenderTime; const uint64_t delta = t - g_state.lastRenderTime;
g_state.lastRenderTime = t; g_state.lastRenderTime = t;
if (g_state.lastRenderTimeValid)
{
const float fdelta = (float)delta / 1000000.0f; const float fdelta = (float)delta / 1000000.0f;
ringbuffer_push(g_state.renderTimings, &fdelta); ringbuffer_push(g_state.renderTimings, &fdelta);
}
g_state.lastRenderTimeValid = true;
if (g_state.showFPS) if (g_state.showFPS)
{ {
@ -601,8 +606,13 @@ int main_frameThread(void * unused)
const uint64_t t = nanotime(); const uint64_t t = nanotime();
const uint64_t delta = t - g_state.lastFrameTime; const uint64_t delta = t - g_state.lastFrameTime;
g_state.lastFrameTime = t; g_state.lastFrameTime = t;
if (g_state.lastFrameTimeValid)
{
const float fdelta = (float)delta / 1000000.0f; const float fdelta = (float)delta / 1000000.0f;
ringbuffer_push(g_state.frameTimings, &fdelta); ringbuffer_push(g_state.frameTimings, &fdelta);
}
g_state.lastFrameTimeValid = true;
atomic_fetch_add_explicit(&g_state.frameCount, 1, memory_order_relaxed); atomic_fetch_add_explicit(&g_state.frameCount, 1, memory_order_relaxed);
lgSignalEvent(e_frame); lgSignalEvent(e_frame);

View File

@ -96,8 +96,10 @@ struct AppState
bool formatValid; bool formatValid;
atomic_uint_least64_t frameTime; atomic_uint_least64_t frameTime;
uint64_t lastFrameTime; uint64_t lastFrameTime;
bool lastFrameTimeValid;
uint64_t renderTime; uint64_t renderTime;
uint64_t lastRenderTime; uint64_t lastRenderTime;
bool lastRenderTimeValid;
atomic_uint_least64_t frameCount; atomic_uint_least64_t frameCount;
uint64_t renderCount; uint64_t renderCount;
RingBuffer renderTimings; RingBuffer renderTimings;