Browse Source

Added resource stats.

Branimir Karadžić 8 years ago
parent
commit
6adb0090d0
5 changed files with 90 additions and 31 deletions
  1. 22 0
      examples/common/example-glue.cpp
  2. 42 30
      include/bgfx/bgfx.h
  3. 12 0
      include/bgfx/c99/bgfx.h
  4. 1 1
      include/bgfx/defines.h
  5. 13 0
      src/bgfx_p.h

+ 22 - 0
examples/common/example-glue.cpp

@@ -151,6 +151,8 @@ void showExampleDialog(entry::AppI* _app, const char* _errorText)
 		const char* items[bgfx::RendererType::Count];
 
 		int32_t current = 0;
+
+
 		for (uint8_t ii = 0; ii < num; ++ii)
 		{
 			items[ii] = bgfx::getRendererName(supportedRenderers[ii]);
@@ -218,6 +220,26 @@ void showExampleDialog(entry::AppI* _app, const char* _errorText)
 		ImGui::Text("GPU mem: %s / %s", tmp0, tmp1);
 	}
 
+	if (ImGui::CollapsingHeader("Resources") )
+	{
+		const bgfx::Caps* caps = bgfx::getCaps();
+
+		ImGui::PushFont(ImGui::Font::Mono);
+		ImGui::Text("Res: Num  / Max");
+		ImGui::Text("DIB: %4d / %4d", stats->numDynamicIndexBuffers,  caps->limits.maxDynamicIndexBuffers);
+		ImGui::Text("DVB: %4d / %4d", stats->numDynamicVertexBuffers, caps->limits.maxDynamicVertexBuffers);
+		ImGui::Text(" FB: %4d / %4d", stats->numFrameBuffers,         caps->limits.maxFrameBuffers);
+		ImGui::Text(" IB: %4d / %4d", stats->numIndexBuffers,         caps->limits.maxIndexBuffers);
+		ImGui::Text(" OQ: %4d / %4d", stats->numOcclusionQueries,     caps->limits.maxOcclusionQueries);
+		ImGui::Text("  P: %4d / %4d", stats->numPrograms,             caps->limits.maxPrograms);
+		ImGui::Text("  S: %4d / %4d", stats->numShaders,              caps->limits.maxShaders);
+		ImGui::Text("  T: %4d / %4d", stats->numTextures,             caps->limits.maxTextures);
+		ImGui::Text("  U: %4d / %4d", stats->numUniforms,             caps->limits.maxUniforms);
+		ImGui::Text(" VB: %4d / %4d", stats->numVertexBuffers,        caps->limits.maxVertexBuffers);
+		ImGui::Text(" VD: %4d / %4d", stats->numVertexDecls,          caps->limits.maxVertexDecls);
+		ImGui::PopFont();
+	}
+
 	if (0 != stats->numViews)
 	{
 		if (ImGui::CollapsingHeader(ICON_FA_CLOCK_O " Profiler") )

+ 42 - 30
include/bgfx/bgfx.h

@@ -805,36 +805,48 @@ namespace bgfx
 	///
 	struct Stats
 	{
-		int64_t cpuTimeFrame;       //!< CPU time between two `bgfx::frame` calls.
-		int64_t cpuTimeBegin;       //!< Render thread CPU submit begin time.
-		int64_t cpuTimeEnd;         //!< Render thread CPU submit end time.
-		int64_t cpuTimerFreq;       //!< CPU timer frequency.
-
-		int64_t gpuTimeBegin;       //!< GPU frame begin time.
-		int64_t gpuTimeEnd;         //!< GPU frame end time.
-		int64_t gpuTimerFreq;       //!< GPU timer frequency.
-
-		int64_t waitRender;         //!< Time spent waiting for render backend thread to finish issuing
-		                            //!  draw commands to underlying graphics API.
-		int64_t waitSubmit;         //!< Time spent waiting for submit thread to advance to next frame.
-
-		uint32_t numDraw;           //!< Number of draw calls submitted.
-		uint32_t numCompute;        //!< Number of compute calls submitted.
-		uint32_t maxGpuLatency;     //!< GPU driver latency.
-
-		int64_t gpuMemoryMax;       //!< Maximum available GPU memory for application.
-		int64_t gpuMemoryUsed;      //!< Amount of GPU memory used.
-
-		uint16_t width;             //!< Backbuffer width in pixels.
-		uint16_t height;            //!< Backbuffer height in pixels.
-		uint16_t textWidth;         //!< Debug text width in characters.
-		uint16_t textHeight;        //!< Debug text height in characters.
-
-		uint16_t   numViews;        //!< Number of view stats.
-		ViewStats* viewStats;       //!< View stats.
-
-		uint8_t       numEncoders;  //!< Number of encoders used during frame.
-		EncoderStats* encoderStats; //!< Encoder stats.
+		int64_t cpuTimeFrame;             //!< CPU time between two `bgfx::frame` calls.
+		int64_t cpuTimeBegin;             //!< Render thread CPU submit begin time.
+		int64_t cpuTimeEnd;               //!< Render thread CPU submit end time.
+		int64_t cpuTimerFreq;             //!< CPU timer frequency.
+
+		int64_t gpuTimeBegin;             //!< GPU frame begin time.
+		int64_t gpuTimeEnd;               //!< GPU frame end time.
+		int64_t gpuTimerFreq;             //!< GPU timer frequency.
+
+		int64_t waitRender;               //!< Time spent waiting for render backend thread to finish issuing
+		                                  //!  draw commands to underlying graphics API.
+		int64_t waitSubmit;               //!< Time spent waiting for submit thread to advance to next frame.
+
+		uint32_t numDraw;                 //!< Number of draw calls submitted.
+		uint32_t numCompute;              //!< Number of compute calls submitted.
+		uint32_t maxGpuLatency;           //!< GPU driver latency.
+
+		uint16_t numDynamicIndexBuffers;  //!<
+		uint16_t numDynamicVertexBuffers; //!<
+		uint16_t numFrameBuffers;         //!<
+		uint16_t numIndexBuffers;         //!<
+		uint16_t numOcclusionQueries;     //!<
+		uint16_t numPrograms;             //!<
+		uint16_t numShaders;              //!<
+		uint16_t numTextures;             //!<
+		uint16_t numUniforms;             //!<
+		uint16_t numVertexBuffers;        //!<
+		uint16_t numVertexDecls;          //!<
+
+		int64_t gpuMemoryMax;             //!< Maximum available GPU memory for application.
+		int64_t gpuMemoryUsed;            //!< Amount of GPU memory used.
+
+		uint16_t width;                   //!< Backbuffer width in pixels.
+		uint16_t height;                  //!< Backbuffer height in pixels.
+		uint16_t textWidth;               //!< Debug text width in characters.
+		uint16_t textHeight;              //!< Debug text height in characters.
+
+		uint16_t   numViews;              //!< Number of view stats.
+		ViewStats* viewStats;             //!< View stats.
+
+		uint8_t       numEncoders;        //!< Number of encoders used during frame.
+		EncoderStats* encoderStats;       //!< Encoder stats.
 	};
 
 	/// Encoder for submitting draw calls from multiple threads. Use `bgfx::begin()`

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

@@ -374,6 +374,18 @@ typedef struct bgfx_stats
     uint32_t numCompute;
     uint32_t maxGpuLatency;
 
+    uint16_t numDynamicIndexBuffers;
+    uint16_t numDynamicVertexBuffers;
+    uint16_t numFrameBuffers;
+    uint16_t numIndexBuffers;
+    uint16_t numOcclusionQueries;
+    uint16_t numPrograms;
+    uint16_t numShaders;
+    uint16_t numTextures;
+    uint16_t numUniforms;
+    uint16_t numVertexBuffers;
+    uint16_t numVertexDecls;
+
     int64_t gpuMemoryMax;
     int64_t gpuMemoryUsed;
 

+ 1 - 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(58)
+#define BGFX_API_VERSION UINT32_C(59)
 
 /// 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.

+ 13 - 0
src/bgfx_p.h

@@ -2722,6 +2722,19 @@ namespace bgfx
 			stats.textWidth  = tvm->m_width;
 			stats.textHeight = tvm->m_height;
 			stats.encoderStats = m_encoderStats;
+
+			stats.numDynamicIndexBuffers  = m_dynamicIndexBufferHandle.getNumHandles();
+			stats.numDynamicVertexBuffers = m_dynamicVertexBufferHandle.getNumHandles();
+			stats.numFrameBuffers         = m_frameBufferHandle.getNumHandles();
+			stats.numIndexBuffers         = m_indexBufferHandle.getNumHandles();
+			stats.numOcclusionQueries     = m_occlusionQueryHandle.getNumHandles();
+			stats.numPrograms             = m_programHandle.getNumHandles();
+			stats.numShaders              = m_shaderHandle.getNumHandles();
+			stats.numTextures             = m_textureHandle.getNumHandles();
+			stats.numUniforms             = m_uniformHandle.getNumHandles();
+			stats.numVertexBuffers        = m_vertexBufferHandle.getNumHandles();
+			stats.numVertexDecls          = m_vertexDeclHandle.getNumHandles();
+
 			return &stats;
 		}