Przeglądaj źródła

waitRender and waitSubmit in the stats

Mikulas Florek 9 lat temu
rodzic
commit
16c73cd71b

+ 3 - 1
examples/17-drawstress/drawstress.cpp

@@ -246,7 +246,9 @@ class ExampleDrawStress : public entry::AppI
 			const bgfx::Stats* stats = bgfx::getStats();
 			imguiLabel("GPU %0.6f [ms]", double(stats->gpuTimeEnd - stats->gpuTimeBegin)*1000.0/stats->gpuTimerFreq);
 			imguiLabel("CPU %0.6f [ms]", double(stats->cpuTimeEnd - stats->cpuTimeBegin)*1000.0/stats->cpuTimerFreq);
-
+			imguiLabel("Waiting for render thread %0.6f [ms]", double(stats->waitRender) * toMs);
+			imguiLabel("Waiting for submit thread %0.6f [ms]", double(stats->waitSubmit) * toMs);
+			
 			imguiEndScrollArea();
 			imguiEndFrame();
 

+ 3 - 0
include/bgfx/bgfx.h

@@ -640,6 +640,9 @@ namespace bgfx
 		uint64_t gpuTimeBegin; //!< GPU frame begin time.
 		uint64_t gpuTimeEnd;   //!< GPU frame end time.
 		uint64_t gpuTimerFreq; //!< GPU timer frequency.
+
+		int64_t waitRender;    //!< Render wait time.
+		int64_t waitSubmit;    //!< Submit wait time.
 	};
 
 	/// Vertex declaration.

+ 2 - 0
include/bgfx/c99/bgfx.h

@@ -307,6 +307,8 @@ typedef struct bgfx_stats
     uint64_t gpuTimeEnd;
     uint64_t gpuTimerFreq;
 
+	int64_t waitRender;
+	int64_t waitSubmit;
 } bgfx_stats_t;
 
 /**/

+ 2 - 0
src/bgfx_p.h

@@ -3892,6 +3892,7 @@ namespace bgfx
 				bool ok = m_gameSem.wait();
 				BX_CHECK(ok, "Semaphore wait failed."); BX_UNUSED(ok);
 				m_render->m_waitSubmit = bx::getHPCounter()-start;
+				m_submit->m_perfStats.waitSubmit = m_submit->m_waitSubmit;
 			}
 		}
 
@@ -3912,6 +3913,7 @@ namespace bgfx
 				bool ok = m_renderSem.wait();
 				BX_CHECK(ok, "Semaphore wait failed."); BX_UNUSED(ok);
 				m_submit->m_waitRender = bx::getHPCounter() - start;
+				m_submit->m_perfStats.waitRender = m_submit->m_waitRender;
 			}
 		}