From 41b29a34a6ed31e53ca8e2fb2d06a31f3bd58ae4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Fri, 22 Sep 2017 22:26:56 -0700 Subject: [PATCH] GL: Fixed GPU timer frequency. --- examples/common/example-glue.cpp | 13 +++++++------ src/renderer_gl.cpp | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/examples/common/example-glue.cpp b/examples/common/example-glue.cpp index b8c456645..c44eb5c20 100644 --- a/examples/common/example-glue.cpp +++ b/examples/common/example-glue.cpp @@ -162,14 +162,15 @@ void showExampleDialog(entry::AppI* _app, const char* _errorText) #endif // 0 const bgfx::Stats* stats = bgfx::getStats(); - const double toMs = 1000.0/stats->cpuTimerFreq; + const double toMsCpu = 1000.0/stats->cpuTimerFreq; + const double toMsGpu = 1000.0/stats->gpuTimerFreq; ImGui::Text("Frame %0.3f" - , double(stats->cpuTimeFrame)*toMs + , double(stats->cpuTimeFrame)*toMsCpu ); ImGui::Text("Submit CPU %0.3f, GPU %0.3f (L: %d)" - , double(stats->cpuTimeEnd - stats->cpuTimeBegin)*toMs - , double(stats->gpuTimeEnd - stats->gpuTimeBegin)*toMs + , double(stats->cpuTimeEnd - stats->cpuTimeBegin)*toMsCpu + , double(stats->gpuTimeEnd - stats->gpuTimeBegin)*toMsGpu , stats->maxGpuLatency ); @@ -190,8 +191,8 @@ void showExampleDialog(entry::AppI* _app, const char* _errorText) { ImGuiListClipper clipper(stats->numViews, itemHeight); - const double toCpuMs = 1000.0/stats->cpuTimerFreq; - const double toGpuMs = 1000.0/stats->gpuTimerFreq; + const double toCpuMs = 1000.0/double(stats->cpuTimerFreq); + const double toGpuMs = 1000.0/double(stats->gpuTimerFreq); const float scale = 3.0f; while (clipper.Step() ) diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index 973f942bc..4e3537ba7 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -7611,7 +7611,7 @@ namespace bgfx { namespace gl m_gpuTimer.end(frameQueryIdx); const TimerQueryGL::Result& result = m_gpuTimer.m_result[BGFX_CONFIG_MAX_VIEWS]; - double toGpuMs = 1000.0 / 1e6; + double toGpuMs = 1000.0 / 1e9; elapsedGpuMs = (result.m_end - result.m_begin) * toGpuMs; maxGpuElapsed = elapsedGpuMs > maxGpuElapsed ? elapsedGpuMs : maxGpuElapsed;