Browse Source

Added BGFX_PROFILER_SCOPE.

Branimir Karadžić 10 years ago
parent
commit
5cd89ff624
3 changed files with 25 additions and 1 deletions
  1. 3 1
      src/bgfx.cpp
  2. 14 0
      src/bgfx_p.h
  3. 8 0
      src/config.h

+ 3 - 1
src/bgfx.cpp

@@ -1416,8 +1416,10 @@ namespace bgfx
 
 	bool Context::renderFrame()
 	{
+		BGFX_PROFILER_SCOPE("bgfx", "renderFrame", 0xff2040ff)
+
 		if (m_rendererInitialized
-		&&  !m_flipAfterRender)
+		&& !m_flipAfterRender)
 		{
 			m_renderCtx->flip(m_render->m_hmd);
 		}

+ 14 - 0
src/bgfx_p.h

@@ -49,6 +49,18 @@
 				, _handleAlloc.getMaxHandles() \
 				)
 
+#ifndef BGFX_PROFILER_SCOPE
+#	if BGFX_CONFIG_PROFILER_MICROPROFILE
+#		include <microprofile.h>
+#		define BGFX_PROFILER_SCOPE(_group, _name, _color) MICROPROFILE_SCOPEI(_group, _name, _color)
+#	elif BGFX_CONFIG_PROFILER_REMOTERY
+#		include <remotery.h>
+#		define BGFX_PROFILER_SCOPE(_group, _name, _color) rmt_ScopedCPUSample(_name)
+#	else
+#		define BGFX_PROFILER_SCOPE(_group, _name, _color) BX_NOOP()
+#	endif // BGFX_CONFIG_PROFILER_*
+#endif // BGFX_PROFILER_SCOPE
+
 namespace bgfx
 {
 #if BX_COMPILER_CLANG_ANALYZER
@@ -3783,6 +3795,7 @@ namespace bgfx
 		{
 			if (!m_singleThreaded)
 			{
+				BGFX_PROFILER_SCOPE("bgfx", "main thread wait", 0xff2040ff)
 				int64_t start = bx::getHPCounter();
 				bool ok = m_gameSem.wait();
 				BX_CHECK(ok, "Semaphore wait failed."); BX_UNUSED(ok);
@@ -3802,6 +3815,7 @@ namespace bgfx
 		{
 			if (!m_singleThreaded)
 			{
+				BGFX_PROFILER_SCOPE("bgfx", "render thread wait", 0xff2040ff)
 				int64_t start = bx::getHPCounter();
 				bool ok = m_renderSem.wait();
 				BX_CHECK(ok, "Semaphore wait failed."); BX_UNUSED(ok);

+ 8 - 0
src/config.h

@@ -300,4 +300,12 @@
 
 #define BGFX_CONFIG_DRAW_INDIRECT_STRIDE 32
 
+#ifndef BGFX_CONFIG_PROFILER_MICROPROFILE
+#	define BGFX_CONFIG_PROFILER_MICROPROFILE 0
+#endif // BGFX_CONFIG_PROFILER_MICROPROFILE
+
+#ifndef BGFX_CONFIG_PROFILER_REMOTERY
+#	define BGFX_CONFIG_PROFILER_REMOTERY 0
+#endif // BGFX_CONFIG_PROFILER_REMOTERY
+
 #endif // BGFX_CONFIG_H_HEADER_GUARD