Browse Source

Added BGFX_DEBUG_PROFILER.

Branimir Karadžić 8 years ago
parent
commit
167db342bd
6 changed files with 20 additions and 8 deletions
  1. 4 1
      examples/common/entry/entry.cpp
  2. 2 1
      include/bgfx/defines.h
  3. 1 1
      src/renderer.h
  4. 1 1
      src/renderer_d3d11.cpp
  5. 5 4
      src/renderer_gl.cpp
  6. 7 0
      src/renderer_gl.h

+ 4 - 1
examples/common/entry/entry.cpp

@@ -283,7 +283,9 @@ BX_PRAGMA_DIAGNOSTIC_POP();
 			else if (setOrToggle(s_debug, "stats",     BGFX_DEBUG_STATS,     1, _argc, _argv)
 				 ||  setOrToggle(s_debug, "ifh",       BGFX_DEBUG_IFH,       1, _argc, _argv)
 				 ||  setOrToggle(s_debug, "text",      BGFX_DEBUG_TEXT,      1, _argc, _argv)
-				 ||  setOrToggle(s_debug, "wireframe", BGFX_DEBUG_WIREFRAME, 1, _argc, _argv) )
+				 ||  setOrToggle(s_debug, "wireframe", BGFX_DEBUG_WIREFRAME, 1, _argc, _argv)
+				 ||  setOrToggle(s_debug, "profiler",  BGFX_DEBUG_PROFILER,  1, _argc, _argv)
+				    )
 			{
 				bgfx::setDebug(s_debug);
 				return bx::kExitSuccess;
@@ -340,6 +342,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
 		{ entry::Key::F4,           entry::Modifier::None,      1, NULL, "graphics hmd"                      },
 		{ entry::Key::F4,           entry::Modifier::LeftShift, 1, NULL, "graphics hmdrecenter"              },
 		{ entry::Key::F4,           entry::Modifier::LeftCtrl,  1, NULL, "graphics hmddbg"                   },
+		{ entry::Key::F6,           entry::Modifier::None,      1, NULL, "graphics profiler"                 },
 		{ entry::Key::F7,           entry::Modifier::None,      1, NULL, "graphics vsync"                    },
 		{ entry::Key::F8,           entry::Modifier::None,      1, NULL, "graphics msaa"                     },
 		{ entry::Key::F9,           entry::Modifier::None,      1, NULL, "graphics flush"                    },

+ 2 - 1
include/bgfx/defines.h

@@ -6,7 +6,7 @@
 #ifndef BGFX_DEFINES_H_HEADER_GUARD
 #define BGFX_DEFINES_H_HEADER_GUARD
 
-#define BGFX_API_VERSION UINT32_C(46)
+#define BGFX_API_VERSION UINT32_C(47)
 
 /// Color RGB/alpha/depth write. When it's not specified write will be disabled.
 #define BGFX_STATE_RGB_WRITE               UINT64_C(0x0000000000000001) //!< Enable RGB write.
@@ -284,6 +284,7 @@
 #define BGFX_DEBUG_IFH                   UINT32_C(0x00000002) //!< Enable infinitely fast hardware test. No draw calls will be submitted to driver. It’s useful when profiling to quickly assess bottleneck between CPU and GPU.
 #define BGFX_DEBUG_STATS                 UINT32_C(0x00000004) //!< Enable statistics display.
 #define BGFX_DEBUG_TEXT                  UINT32_C(0x00000008) //!< Enable debug text display.
+#define BGFX_DEBUG_PROFILER              UINT32_C(0x00000010) //!< Enable profiler.
 
 ///
 #define BGFX_BUFFER_NONE                 UINT16_C(0x0000) //!<

+ 1 - 1
src/renderer.h

@@ -504,7 +504,7 @@ namespace bgfx
 			, m_gpuTimer(_gpuTimer)
 			, m_queryIdx(UINT32_MAX)
 			, m_numViews(0)
-			, m_enabled(_enabled)
+			, m_enabled(_enabled && 0 != (_frame->m_debug & BGFX_DEBUG_PROFILER) )
 		{
 		}
 

+ 1 - 1
src/renderer_d3d11.cpp

@@ -5549,7 +5549,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
 			  _render
 			, m_gpuTimer
 			, s_viewName
-			, false //m_timerQuerySupport
+			, m_timerQuerySupport
 			);
 
 		m_occlusionQuery.resolve(_render);

+ 5 - 4
src/renderer_gl.cpp

@@ -6570,9 +6570,10 @@ namespace bgfx { namespace gl
 		uint16_t discardFlags = BGFX_CLEAR_NONE;
 
 		const bool blendIndependentSupported = s_extension[Extension::ARB_draw_buffers_blend].m_supported;
-		const bool computeSupported = (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) && s_extension[Extension::ARB_compute_shader].m_supported)
-									|| BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES >= 31)
-									;
+		const bool computeSupported = false
+			|| (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) && s_extension[Extension::ARB_compute_shader].m_supported)
+			||  BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES >= 31)
+			;
 
 		uint32_t statsNumPrimsSubmitted[BX_COUNTOF(s_primInfo)] = {};
 		uint32_t statsNumPrimsRendered[BX_COUNTOF(s_primInfo)] = {};
@@ -6584,7 +6585,7 @@ namespace bgfx { namespace gl
 			  _render
 			, m_gpuTimer
 			, s_viewName
-			, false //m_timerQuerySupport && !BX_ENABLED(BX_PLATFORM_OSX)
+			, m_timerQuerySupport && !BX_ENABLED(BX_PLATFORM_OSX)
 			);
 
 		if (m_occlusionQuerySupport)

+ 7 - 0
src/renderer_gl.h

@@ -1302,9 +1302,16 @@ namespace bgfx { namespace gl
 			for (uint32_t ii = 0; ii < BX_COUNTOF(m_query); ++ii)
 			{
 				Query& query = m_query[ii];
+				query.m_ready = false;
 				GL_CHECK(glGenQueries(1, &query.m_begin) );
 				GL_CHECK(glGenQueries(1, &query.m_end) );
 			}
+
+			for (uint32_t ii = 0; ii < BX_COUNTOF(m_result); ++ii)
+			{
+				Result& result = m_result[ii];
+				result.reset();
+			}
 		}
 
 		void destroy()