Browse Source

GL: Fixed GPU timer frequency.

Branimir Karadžić 8 years ago
parent
commit
41b29a34a6
2 changed files with 8 additions and 7 deletions
  1. 7 6
      examples/common/example-glue.cpp
  2. 1 1
      src/renderer_gl.cpp

+ 7 - 6
examples/common/example-glue.cpp

@@ -162,14 +162,15 @@ void showExampleDialog(entry::AppI* _app, const char* _errorText)
 #endif // 0
 #endif // 0
 
 
 	const bgfx::Stats* stats = bgfx::getStats();
 	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"
 	ImGui::Text("Frame %0.3f"
-		, double(stats->cpuTimeFrame)*toMs
+		, double(stats->cpuTimeFrame)*toMsCpu
 		);
 		);
 
 
 	ImGui::Text("Submit CPU %0.3f, GPU %0.3f (L: %d)"
 	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
 		, stats->maxGpuLatency
 		);
 		);
 
 
@@ -190,8 +191,8 @@ void showExampleDialog(entry::AppI* _app, const char* _errorText)
 				{
 				{
 					ImGuiListClipper clipper(stats->numViews, itemHeight);
 					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;
 					const float  scale   = 3.0f;
 
 
 					while (clipper.Step() )
 					while (clipper.Step() )

+ 1 - 1
src/renderer_gl.cpp

@@ -7611,7 +7611,7 @@ namespace bgfx { namespace gl
 			m_gpuTimer.end(frameQueryIdx);
 			m_gpuTimer.end(frameQueryIdx);
 
 
 			const TimerQueryGL::Result& result = m_gpuTimer.m_result[BGFX_CONFIG_MAX_VIEWS];
 			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;
 			elapsedGpuMs   = (result.m_end - result.m_begin) * toGpuMs;
 			maxGpuElapsed  = elapsedGpuMs > maxGpuElapsed ? elapsedGpuMs : maxGpuElapsed;
 			maxGpuElapsed  = elapsedGpuMs > maxGpuElapsed ? elapsedGpuMs : maxGpuElapsed;