DebugStats.h 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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 ( batchDrawCallsStrictSingle > maxBatchDrawCallsStrictSingle ) maxBatchDrawCallsStrictSingle = batchDrawCallsStrictSingle;
  71. if ( batchDrawCallsStrictMultiple > maxBatchDrawCallsStrictMultiple ) maxBatchDrawCallsStrictMultiple = batchDrawCallsStrictMultiple;
  72. if ( batchDrawCallsSorted > maxBatchDrawCallsSorted ) maxBatchDrawCallsSorted = batchDrawCallsSorted;
  73. if ( batchFlushes > maxBatchFlushes ) maxBatchFlushes = batchFlushes;
  74. if ( batchBlendStateFlush > maxBatchBlendStateFlush ) maxBatchBlendStateFlush = batchBlendStateFlush;
  75. if ( batchColorStateFlush > maxBatchColorStateFlush ) maxBatchColorStateFlush = batchColorStateFlush;
  76. if ( batchAlphaStateFlush > maxBatchAlphaStateFlush ) maxBatchAlphaStateFlush = batchAlphaStateFlush;
  77. if ( batchTextureChangeFlush > maxBatchTextureChangeFlushes ) maxBatchTextureChangeFlushes = batchTextureChangeFlush;
  78. if ( batchBufferFullFlush > maxBatchBufferFullFlush ) maxBatchBufferFullFlush = batchBufferFullFlush;
  79. if ( batchIsolatedFlush > maxBatchIsolatedFlush ) maxBatchIsolatedFlush = batchIsolatedFlush;
  80. if ( batchLayerFlush > maxBatchLayerFlush ) maxBatchLayerFlush = batchLayerFlush;
  81. if ( batchNoBatchFlush > maxBatchNoBatchFlush ) maxBatchNoBatchFlush = batchNoBatchFlush;
  82. if ( batchAnonymousFlush > maxBatchAnonymousFlush ) maxBatchAnonymousFlush = batchAnonymousFlush;
  83. // Particles.
  84. if ( particlesUsed > maxParticlesUsed ) maxParticlesUsed = particlesUsed;
  85. // World profile.
  86. if ( worldProfile.step > maxWorldProfile.step ) maxWorldProfile.step = worldProfile.step;
  87. if ( worldProfile.collide > maxWorldProfile.collide ) maxWorldProfile.collide = worldProfile.collide;
  88. if ( worldProfile.solve > maxWorldProfile.solve ) maxWorldProfile.solve = worldProfile.solve;
  89. if ( worldProfile.solveInit > maxWorldProfile.solveInit ) maxWorldProfile.solveInit = worldProfile.solveInit;
  90. if ( worldProfile.solveVelocity > maxWorldProfile.solveVelocity ) maxWorldProfile.solveVelocity = worldProfile.solveVelocity;
  91. if ( worldProfile.solvePosition > maxWorldProfile.solvePosition ) maxWorldProfile.solvePosition = worldProfile.solvePosition;
  92. if ( worldProfile.broadphase > maxWorldProfile.broadphase ) maxWorldProfile.broadphase = worldProfile.broadphase;
  93. if ( worldProfile.solveTOI > maxWorldProfile.solveTOI ) maxWorldProfile.solveTOI = worldProfile.solveTOI;
  94. }
  95. /// Reset debug stats.
  96. void reset( void )
  97. {
  98. objectsCount = 0;
  99. maxObjectsCount = 0;
  100. objectsEnabled = 0;
  101. maxObjectsEnabled = 0;
  102. objectsVisible = 0;
  103. maxObjectsVisible = 0;
  104. objectsAwake = 0;
  105. maxObjectsAwake = 0;
  106. renderPicked = 0;
  107. maxRenderPicked = 0;
  108. renderRequests = 0;
  109. maxRenderRequests = 0;
  110. renderFallbacks = 0;
  111. maxRenderFallbacks = 0;
  112. bodyCount = 0;
  113. maxBodyCount = 0;
  114. jointCount = 0;
  115. maxJointCount = 0;
  116. contactCount = 0;
  117. maxContactCount = 0;
  118. proxyCount = 0;
  119. maxProxyCount = 0;
  120. batchTrianglesSubmitted = 0;
  121. maxBatchTrianglesSubmitted = 0;
  122. batchMaxVertexBuffer = 0;
  123. batchMaxTriangleDrawn = 0;
  124. batchDrawCallsStrictSingle = 0;
  125. maxBatchDrawCallsStrictSingle = 0;
  126. batchDrawCallsStrictMultiple = 0;
  127. maxBatchDrawCallsStrictMultiple = 0;
  128. batchDrawCallsSorted = 0;
  129. maxBatchDrawCallsSorted = 0;
  130. batchFlushes = 0;
  131. maxBatchFlushes = 0;
  132. batchBlendStateFlush = 0;
  133. maxBatchBlendStateFlush = 0;
  134. batchColorStateFlush = 0;
  135. maxBatchColorStateFlush = 0;
  136. batchAlphaStateFlush = 0;
  137. maxBatchAlphaStateFlush = 0;
  138. batchTextureChangeFlush = 0;
  139. maxBatchTextureChangeFlushes = 0;
  140. batchBufferFullFlush = 0;
  141. maxBatchBufferFullFlush = 0;
  142. batchIsolatedFlush = 0;
  143. maxBatchIsolatedFlush = 0;
  144. batchLayerFlush = 0;
  145. maxBatchLayerFlush = 0;
  146. batchNoBatchFlush = 0;
  147. maxBatchNoBatchFlush = 0;
  148. batchAnonymousFlush = 0;
  149. maxBatchAnonymousFlush = 0;
  150. particlesAlloc = 0;
  151. particlesFree = 0;
  152. particlesUsed = 0;
  153. maxParticlesUsed = 0;
  154. fps = 0.0f;
  155. minFPS = 10000.0f;
  156. maxFPS = 0.0f;
  157. frameCount = 0;
  158. dMemset( &worldProfile, 0, sizeof(worldProfile) );
  159. dMemset( &maxWorldProfile, 0, sizeof(maxWorldProfile) );
  160. }
  161. U32 objectsCount;
  162. U32 maxObjectsCount;
  163. U32 objectsEnabled;
  164. U32 maxObjectsEnabled;
  165. U32 objectsVisible;
  166. U32 maxObjectsVisible;
  167. U32 objectsAwake;
  168. U32 maxObjectsAwake;
  169. U32 renderPicked;
  170. U32 maxRenderPicked;
  171. U32 renderRequests;
  172. U32 maxRenderRequests;
  173. U32 renderFallbacks;
  174. U32 maxRenderFallbacks;
  175. U32 bodyCount;
  176. U32 maxBodyCount;
  177. U32 jointCount;
  178. U32 maxJointCount;
  179. U32 contactCount;
  180. U32 maxContactCount;
  181. U32 proxyCount;
  182. U32 maxProxyCount;
  183. U32 batchTrianglesSubmitted;
  184. U32 maxBatchTrianglesSubmitted;
  185. U32 batchMaxVertexBuffer;
  186. U32 batchMaxTriangleDrawn;
  187. U32 batchDrawCallsStrictSingle;
  188. U32 maxBatchDrawCallsStrictSingle;
  189. U32 batchDrawCallsStrictMultiple;
  190. U32 maxBatchDrawCallsStrictMultiple;
  191. U32 batchDrawCallsSorted;
  192. U32 maxBatchDrawCallsSorted;
  193. U32 batchFlushes;
  194. U32 maxBatchFlushes;
  195. U32 batchBlendStateFlush;
  196. U32 maxBatchBlendStateFlush;
  197. U32 batchColorStateFlush;
  198. U32 maxBatchColorStateFlush;
  199. U32 batchAlphaStateFlush;
  200. U32 maxBatchAlphaStateFlush;
  201. U32 batchTextureChangeFlush;
  202. U32 maxBatchTextureChangeFlushes;
  203. U32 batchBufferFullFlush;
  204. U32 maxBatchBufferFullFlush;
  205. U32 batchIsolatedFlush;
  206. U32 maxBatchIsolatedFlush;
  207. U32 batchLayerFlush;
  208. U32 maxBatchLayerFlush;
  209. U32 batchNoBatchFlush;
  210. U32 maxBatchNoBatchFlush;
  211. U32 batchAnonymousFlush;
  212. U32 maxBatchAnonymousFlush;
  213. U32 particlesAlloc;
  214. U32 particlesFree;
  215. U32 particlesUsed;
  216. U32 maxParticlesUsed;
  217. F32 fps;
  218. F32 minFPS;
  219. F32 maxFPS;
  220. U32 frameCount;
  221. b2Profile worldProfile;
  222. b2Profile maxWorldProfile;
  223. };
  224. #endif // _DEBUG_STATS_H_