DebugStats.h 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _DEBUG_STATS_H_
  23. #define _DEBUG_STATS_H_
  24. #ifndef _PROFILER_H_
  25. #include "debug/profiler.h"
  26. #endif
  27. #ifndef _TORQUE_TYPES_H_
  28. #include "platform\types.h"
  29. #endif
  30. #ifndef _PLATFORM_MEMORY_H_
  31. #include "platform/platformMemory.h"
  32. #endif
  33. #ifndef BOX2D_H
  34. #include "Box2D/Box2D.h"
  35. #endif
  36. //-----------------------------------------------------------------------------
  37. class DebugStats
  38. {
  39. public:
  40. DebugStats()
  41. {
  42. reset();
  43. }
  44. inline void updateRanges( void )
  45. {
  46. // Debug Profiling.
  47. PROFILE_SCOPE(DebugStats_UpdateRanges);
  48. // Frames per-second.
  49. if ( fps > 0.0f )
  50. {
  51. if ( fps < minFPS ) minFPS = fps;
  52. if ( fps > maxFPS ) maxFPS = fps;
  53. }
  54. // Bodies, joints, contacts and proxies.
  55. if ( bodyCount > maxBodyCount ) maxBodyCount = bodyCount;
  56. if ( jointCount > maxJointCount ) maxJointCount = jointCount;
  57. if ( contactCount > maxContactCount ) maxContactCount = contactCount;
  58. if ( proxyCount > maxProxyCount ) maxProxyCount = proxyCount;
  59. // Objects.
  60. if ( objectsCount > maxObjectsCount ) maxObjectsCount = objectsCount;
  61. if ( objectsEnabled > maxObjectsEnabled ) maxObjectsEnabled = objectsEnabled;
  62. if ( objectsVisible > maxObjectsVisible ) maxObjectsVisible = objectsVisible;
  63. if ( objectsAwake > maxObjectsAwake ) maxObjectsAwake = objectsAwake;
  64. // Render pick/requests.
  65. if ( renderPicked > maxRenderPicked ) maxRenderPicked = renderPicked;
  66. if ( renderRequests > maxRenderRequests ) maxRenderRequests = renderRequests;
  67. if ( renderFallbacks > maxRenderFallbacks ) maxRenderFallbacks = renderFallbacks;
  68. // Batching.
  69. if ( batchTrianglesSubmitted > maxBatchTrianglesSubmitted ) maxBatchTrianglesSubmitted = batchTrianglesSubmitted;
  70. if ( batchDrawCallsStrict > maxBatchDrawCallsStrict ) maxBatchDrawCallsStrict = batchDrawCallsStrict;
  71. if ( batchDrawCallsSorted > maxBatchDrawCallsSorted ) maxBatchDrawCallsSorted = batchDrawCallsSorted;
  72. if ( batchFlushes > maxBatchFlushes ) maxBatchFlushes = batchFlushes;
  73. if ( batchBlendStateFlush > maxBatchBlendStateFlush ) maxBatchBlendStateFlush = batchBlendStateFlush;
  74. if ( batchColorStateFlush > maxBatchColorStateFlush ) maxBatchColorStateFlush = batchColorStateFlush;
  75. if ( batchAlphaStateFlush > maxBatchAlphaStateFlush ) maxBatchAlphaStateFlush = batchAlphaStateFlush;
  76. if ( batchTextureChangeFlush > maxBatchTextureChangeFlushes ) maxBatchTextureChangeFlushes = batchTextureChangeFlush;
  77. if ( batchBufferFullFlush > maxBatchBufferFullFlush ) maxBatchBufferFullFlush = batchBufferFullFlush;
  78. if ( batchIsolatedFlush > maxBatchIsolatedFlush ) maxBatchIsolatedFlush = batchIsolatedFlush;
  79. if ( batchLayerFlush > maxBatchLayerFlush ) maxBatchLayerFlush = batchLayerFlush;
  80. if ( batchNoBatchFlush > maxBatchNoBatchFlush ) maxBatchNoBatchFlush = batchNoBatchFlush;
  81. if ( batchAnonymousFlush > maxBatchAnonymousFlush ) maxBatchAnonymousFlush = batchAnonymousFlush;
  82. // Particles.
  83. if ( particlesUsed > maxParticlesUsed ) maxParticlesUsed = particlesUsed;
  84. // World profile.
  85. if ( worldProfile.step > maxWorldProfile.step ) maxWorldProfile.step = worldProfile.step;
  86. if ( worldProfile.collide > maxWorldProfile.collide ) maxWorldProfile.collide = worldProfile.collide;
  87. if ( worldProfile.solve > maxWorldProfile.solve ) maxWorldProfile.solve = worldProfile.solve;
  88. if ( worldProfile.solveInit > maxWorldProfile.solveInit ) maxWorldProfile.solveInit = worldProfile.solveInit;
  89. if ( worldProfile.solveVelocity > maxWorldProfile.solveVelocity ) maxWorldProfile.solveVelocity = worldProfile.solveVelocity;
  90. if ( worldProfile.solvePosition > maxWorldProfile.solvePosition ) maxWorldProfile.solvePosition = worldProfile.solvePosition;
  91. if ( worldProfile.broadphase > maxWorldProfile.broadphase ) maxWorldProfile.broadphase = worldProfile.broadphase;
  92. if ( worldProfile.solveTOI > maxWorldProfile.solveTOI ) maxWorldProfile.solveTOI = worldProfile.solveTOI;
  93. }
  94. /// Reset debug stats.
  95. void reset( void )
  96. {
  97. objectsCount = 0;
  98. maxObjectsCount = 0;
  99. objectsEnabled = 0;
  100. maxObjectsEnabled = 0;
  101. objectsVisible = 0;
  102. maxObjectsVisible = 0;
  103. objectsAwake = 0;
  104. maxObjectsAwake = 0;
  105. renderPicked = 0;
  106. maxRenderPicked = 0;
  107. renderRequests = 0;
  108. maxRenderRequests = 0;
  109. renderFallbacks = 0;
  110. maxRenderFallbacks = 0;
  111. bodyCount = 0;
  112. maxBodyCount = 0;
  113. jointCount = 0;
  114. maxJointCount = 0;
  115. contactCount = 0;
  116. maxContactCount = 0;
  117. proxyCount = 0;
  118. maxProxyCount = 0;
  119. batchTrianglesSubmitted = 0;
  120. maxBatchTrianglesSubmitted = 0;
  121. batchMaxVertexBuffer = 0;
  122. batchMaxTriangleDrawn = 0;
  123. batchDrawCallsStrict = 0;
  124. maxBatchDrawCallsStrict = 0;
  125. batchDrawCallsSorted = 0;
  126. maxBatchDrawCallsSorted = 0;
  127. batchFlushes = 0;
  128. maxBatchFlushes = 0;
  129. batchBlendStateFlush = 0;
  130. maxBatchBlendStateFlush = 0;
  131. batchColorStateFlush = 0;
  132. maxBatchColorStateFlush = 0;
  133. batchAlphaStateFlush = 0;
  134. maxBatchAlphaStateFlush = 0;
  135. batchTextureChangeFlush = 0;
  136. maxBatchTextureChangeFlushes = 0;
  137. batchBufferFullFlush = 0;
  138. maxBatchBufferFullFlush = 0;
  139. batchIsolatedFlush = 0;
  140. maxBatchIsolatedFlush = 0;
  141. batchLayerFlush = 0;
  142. maxBatchLayerFlush = 0;
  143. batchNoBatchFlush = 0;
  144. maxBatchNoBatchFlush = 0;
  145. batchAnonymousFlush = 0;
  146. maxBatchAnonymousFlush = 0;
  147. particlesAlloc = 0;
  148. particlesFree = 0;
  149. particlesUsed = 0;
  150. maxParticlesUsed = 0;
  151. fps = 0.0f;
  152. minFPS = 10000.0f;
  153. maxFPS = 0.0f;
  154. frameCount = 0;
  155. dMemset( &worldProfile, 0, sizeof(worldProfile) );
  156. dMemset( &maxWorldProfile, 0, sizeof(maxWorldProfile) );
  157. }
  158. U32 objectsCount;
  159. U32 maxObjectsCount;
  160. U32 objectsEnabled;
  161. U32 maxObjectsEnabled;
  162. U32 objectsVisible;
  163. U32 maxObjectsVisible;
  164. U32 objectsAwake;
  165. U32 maxObjectsAwake;
  166. U32 renderPicked;
  167. U32 maxRenderPicked;
  168. U32 renderRequests;
  169. U32 maxRenderRequests;
  170. U32 renderFallbacks;
  171. U32 maxRenderFallbacks;
  172. U32 bodyCount;
  173. U32 maxBodyCount;
  174. U32 jointCount;
  175. U32 maxJointCount;
  176. U32 contactCount;
  177. U32 maxContactCount;
  178. U32 proxyCount;
  179. U32 maxProxyCount;
  180. U32 batchTrianglesSubmitted;
  181. U32 maxBatchTrianglesSubmitted;
  182. U32 batchMaxVertexBuffer;
  183. U32 batchMaxTriangleDrawn;
  184. U32 batchDrawCallsStrict;
  185. U32 maxBatchDrawCallsStrict;
  186. U32 batchDrawCallsSorted;
  187. U32 maxBatchDrawCallsSorted;
  188. U32 batchFlushes;
  189. U32 maxBatchFlushes;
  190. U32 batchBlendStateFlush;
  191. U32 maxBatchBlendStateFlush;
  192. U32 batchColorStateFlush;
  193. U32 maxBatchColorStateFlush;
  194. U32 batchAlphaStateFlush;
  195. U32 maxBatchAlphaStateFlush;
  196. U32 batchTextureChangeFlush;
  197. U32 maxBatchTextureChangeFlushes;
  198. U32 batchBufferFullFlush;
  199. U32 maxBatchBufferFullFlush;
  200. U32 batchIsolatedFlush;
  201. U32 maxBatchIsolatedFlush;
  202. U32 batchLayerFlush;
  203. U32 maxBatchLayerFlush;
  204. U32 batchNoBatchFlush;
  205. U32 maxBatchNoBatchFlush;
  206. U32 batchAnonymousFlush;
  207. U32 maxBatchAnonymousFlush;
  208. U32 particlesAlloc;
  209. U32 particlesFree;
  210. U32 particlesUsed;
  211. U32 maxParticlesUsed;
  212. F32 fps;
  213. F32 minFPS;
  214. F32 maxFPS;
  215. U32 frameCount;
  216. b2Profile worldProfile;
  217. b2Profile maxWorldProfile;
  218. };
  219. #endif // _DEBUG_STATS_H_