Added cumulative statistics option and actual call count to GLES call debug counters 31/60831/3
authorTom Robinson <tom.robinson@samsung.com>
Wed, 2 Mar 2016 10:58:14 +0000 (10:58 +0000)
committerTom Robinson <tom.robinson@samsung.com>
Wed, 2 Mar 2016 16:53:04 +0000 (16:53 +0000)
Change-Id: Id3c1cfd6c1185d653ca48108e79d1ef7837d84db

adaptors/base/environment-options.cpp
adaptors/base/environment-options.h
adaptors/base/environment-variables.h
adaptors/common/gl/gl-proxy-implementation.cpp
adaptors/common/gl/gl-proxy-implementation.h

index b5e293c..a029a30 100644 (file)
@@ -101,11 +101,12 @@ EnvironmentOptions::EnvironmentOptions()
   mPanGestureSmoothingAmount(-1.0f),
   mPanMinimumDistance(-1),
   mPanMinimumEvents(-1),
-  mGlesCallTime(0),
+  mGlesCallTime( 0 ),
   mWindowWidth( 0 ),
   mWindowHeight( 0 ),
   mThreadingMode( ThreadingMode::COMBINED_UPDATE_RENDER ),
   mRenderRefreshRate( 1 ),
+  mGlesCallAccumulate( false ),
   mLogFunction( NULL )
 {
   ParseEnvironmentOptions();
@@ -227,6 +228,11 @@ int EnvironmentOptions::GetGlesCallTime() const
   return mGlesCallTime;
 }
 
+bool EnvironmentOptions::GetGlesCallAccumulate() const
+{
+  return mGlesCallAccumulate;
+}
+
 const std::string& EnvironmentOptions::GetWindowName() const
 {
   return mWindowName;
@@ -341,6 +347,12 @@ void EnvironmentOptions::ParseEnvironmentOptions()
     mGlesCallTime = glesCallTime;
   }
 
+  int glesCallAccumulate( 0 );
+  if ( GetIntegerEnvironmentVariable( DALI_GLES_CALL_ACCUMULATE, glesCallAccumulate ) )
+  {
+    mGlesCallAccumulate = glesCallAccumulate != 0;
+  }
+
   int windowWidth(0), windowHeight(0);
   if ( GetIntegerEnvironmentVariable( DALI_WINDOW_WIDTH, windowWidth ) && GetIntegerEnvironmentVariable( DALI_WINDOW_HEIGHT, windowHeight ) )
   {
index 78528a2..792f8ba 100644 (file)
@@ -174,6 +174,11 @@ public:
   int GetGlesCallTime() const;
 
   /**
+   * @brief Get whether or not to accumulate gles call statistics
+   */
+  bool GetGlesCallAccumulate() const;
+
+  /**
    * @return true if performance server is required
    */
   bool PerformanceServerRequired() const;
@@ -232,6 +237,7 @@ private: // Data
   unsigned int mWindowHeight;                     ///< height of the window
   ThreadingMode::Type mThreadingMode;             ///< threading mode
   unsigned int mRenderRefreshRate;                ///< render refresh rate
+  bool mGlesCallAccumulate;                       ///< Whether or not to accumulate gles call statistics
 
   Dali::Integration::Log::LogFunction mLogFunction;
 
index e62bc0a..a3c2963 100644 (file)
@@ -79,6 +79,8 @@ namespace Adaptor
 
 #define DALI_GLES_CALL_TIME "DALI_GLES_CALL_TIME"
 
+#define DALI_GLES_CALL_ACCUMULATE "DALI_GLES_CALL_ACCUMULATE"
+
 #define DALI_WINDOW_WIDTH "DALI_WINDOW_WIDTH"
 
 #define DALI_WINDOW_HEIGHT "DALI_WINDOW_HEIGHT"
index 58714d0..03eec98 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@
 
 namespace
 {
-const int NUM_FRAMES_PER_SECOND(60);
+const int NUM_FRAMES_PER_SECOND( 60 );
 }
 
 
@@ -41,12 +41,12 @@ namespace Adaptor
 
 Sampler::Sampler( const char* description )
 : mDescription( description ),
-  mAccumulated(0.0f),
-  mAccumulatedSquare(0.0f),
-  mMin(0.0f),
-  mMax(0.0f),
-  mNumSamples(0),
-  mCurrentFrameCount(0)
+  mAccumulatedSquare( 0 ),
+  mAccumulated( 0 ),
+  mNumSamples( 0 ),
+  mMin( 0.0f ),
+  mMax( 0.0f ),
+  mCurrentFrameCount( 0 )
 {
 }
 
@@ -57,11 +57,11 @@ void Sampler::Increment()
 
 void Sampler::Reset()
 {
-  mAccumulated = 0.0f;
-  mAccumulatedSquare= 0.0f;
+  mAccumulatedSquare = 0;
+  mAccumulated = 0;
+  mNumSamples = 0;
   mMin = 0.0f;
   mMax = 0.0f;
-  mNumSamples = 0;
   mCurrentFrameCount = 0;
 }
 
@@ -74,11 +74,11 @@ void Sampler::Accumulate()
   }
   else
   {
-    if(mCurrentFrameCount < mMin)
+    if( mCurrentFrameCount < mMin )
     {
       mMin = mCurrentFrameCount;
     }
-    if(mCurrentFrameCount > mMax)
+    if( mCurrentFrameCount > mMax )
     {
       mMax = mCurrentFrameCount;
     }
@@ -87,7 +87,7 @@ void Sampler::Accumulate()
   mNumSamples++;
 
   mAccumulated += mCurrentFrameCount;
-  mAccumulatedSquare += (mCurrentFrameCount * mCurrentFrameCount);
+  mAccumulatedSquare += ( mCurrentFrameCount * mCurrentFrameCount );
   mCurrentFrameCount = 0;
 }
 const char* Sampler::GetDescription() const
@@ -100,17 +100,17 @@ float Sampler::GetMeanValue() const
   float meanValue = 0;
   if( mNumSamples > 0 )
   {
-    meanValue = mAccumulated / (float)mNumSamples;
+    meanValue = static_cast<double>( mAccumulated ) / static_cast<double>( mNumSamples );
   }
   return meanValue;
 }
 
 float Sampler::GetStandardDeviation() const
 {
-  float standardDeviation=0.0f;
+  float standardDeviation = 0.0f;
   if( mNumSamples > 0 )
   {
-    standardDeviation = sqrtf( mNumSamples * mAccumulatedSquare - (mAccumulated*mAccumulated)) / mNumSamples;
+    standardDeviation = sqrtf( mNumSamples * mAccumulatedSquare - ( mAccumulated * mAccumulated ) ) / mNumSamples;
   }
   return standardDeviation;
 }
@@ -125,10 +125,15 @@ float Sampler::GetMax() const
   return mMax;
 }
 
+uint64_t Sampler::GetCount() const
+{
+  return mAccumulated;
+}
+
 ObjectCounter::ObjectCounter( const char* description )
-:mDescription(description),
mCount(0),
mPeak(0)
+: mDescription( description ),
 mCount( 0 ),
 mPeak( 0 )
 {}
 
 void ObjectCounter::Increment()
@@ -159,19 +164,20 @@ const char* ObjectCounter::GetDescription() const
   return mDescription;
 }
 
-GlProxyImplementation::GlProxyImplementation(EnvironmentOptions& environmentOptions)
-: mEnvironmentOptions(environmentOptions),
-  mActiveTextureSampler( "ActiveTexture calls"),
-  mClearSampler("Clear calls"),
-  mBindBufferSampler( "Bind buffers"),
-  mBindTextureSampler( "Bind textures"),
-  mDrawSampler("Draw calls"),
-  mUniformSampler("Uniform sets"),
-  mUseProgramSampler("Used programs"),
-  mBufferCount( "Buffer Count"),
-  mTextureCount("Texture Count"),
-  mProgramCount("Program Count"),
-  mFrameCount(0)
+GlProxyImplementation::GlProxyImplementation( EnvironmentOptions& environmentOptions )
+: mEnvironmentOptions( environmentOptions ),
+  mActiveTextureSampler( "ActiveTexture calls" ),
+  mClearSampler( "Clear calls" ),
+  mBindBufferSampler( "Bind buffers" ),
+  mBindTextureSampler( "Bind textures" ),
+  mDrawSampler( "Draw calls" ),
+  mUniformSampler( "Uniform sets" ),
+  mUseProgramSampler( "Used programs" ),
+  mBufferCount( "Buffer Count" ),
+  mTextureCount( "Texture Count" ),
+  mProgramCount( "Program Count" ),
+  mCurrentFrameCount( 0 ),
+  mTotalFrameCount( 0 )
 {
 }
 
@@ -189,11 +195,18 @@ void GlProxyImplementation::PostRender()
   AccumulateSamples();
 
   // When we reach the desired frame count, output the averages from the samples
-  mFrameCount++;
-  if( mFrameCount >= mEnvironmentOptions.GetGlesCallTime() * NUM_FRAMES_PER_SECOND )
+  mTotalFrameCount++;
+  mCurrentFrameCount++;
+
+  if( mCurrentFrameCount >= mEnvironmentOptions.GetGlesCallTime() * NUM_FRAMES_PER_SECOND )
   {
+    mCurrentFrameCount = 0;
     LogResults();
-    ResetSamplers();
+
+    if( !mEnvironmentOptions.GetGlesCallAccumulate() )
+    {
+      ResetSamplers();
+    }
   }
 }
 
@@ -203,13 +216,13 @@ void GlProxyImplementation::Clear( GLbitfield mask )
   GlImplementation::Clear(mask);
 }
 
-void GlProxyImplementation::GenBuffers (GLsizei n, GLuint* buffers)
+void GlProxyImplementation::GenBuffers(GLsizei n, GLuint* buffers)
 {
   mBufferCount.Increment();
   GlImplementation::GenBuffers( n, buffers );
 }
 
-void GlProxyImplementation::DeleteBuffers (GLsizei n, const GLuint* buffers)
+void GlProxyImplementation::DeleteBuffers( GLsizei n, const GLuint* buffers )
 {
   mBufferCount.Decrement();
   GlImplementation::DeleteBuffers( n, buffers );
@@ -218,16 +231,16 @@ void GlProxyImplementation::DeleteBuffers (GLsizei n, const GLuint* buffers)
 void GlProxyImplementation::BindBuffer( GLenum target, GLuint buffer )
 {
   mBindBufferSampler.Increment();
-  GlImplementation::BindBuffer(target,buffer);
+  GlImplementation::BindBuffer( target, buffer );
 }
 
-void GlProxyImplementation::GenTextures (GLsizei n, GLuint* textures)
+void GlProxyImplementation::GenTextures( GLsizei n, GLuint* textures )
 {
   mTextureCount.Increment();
   GlImplementation::GenTextures( n, textures );
 }
 
-void GlProxyImplementation::DeleteTextures (GLsizei n, const GLuint* textures)
+void GlProxyImplementation::DeleteTextures( GLsizei n, const GLuint* textures )
 {
   mTextureCount.Decrement();
   GlImplementation::DeleteTextures( n, textures );
@@ -236,7 +249,7 @@ void GlProxyImplementation::DeleteTextures (GLsizei n, const GLuint* textures)
 void GlProxyImplementation::ActiveTexture( GLenum texture )
 {
   mActiveTextureSampler.Increment();
-  GlImplementation::ActiveTexture(texture);
+  GlImplementation::ActiveTexture( texture );
 }
 
 void GlProxyImplementation::BindTexture( GLenum target, GLuint texture )
@@ -248,145 +261,145 @@ void GlProxyImplementation::BindTexture( GLenum target, GLuint texture )
 void GlProxyImplementation::DrawArrays( GLenum mode, GLint first, GLsizei count )
 {
   mDrawSampler.Increment();
-  GlImplementation::DrawArrays(mode,first,count);
+  GlImplementation::DrawArrays( mode, first, count );
 }
 
 void GlProxyImplementation::DrawElements( GLenum mode, GLsizei count, GLenum type, const void* indices )
 {
   mDrawSampler.Increment();
-  GlImplementation::DrawElements(mode,count,type,indices);
+  GlImplementation::DrawElements( mode, count, type, indices );
 }
 
 void GlProxyImplementation::Uniform1f( GLint location, GLfloat x )
 {
   mUniformSampler.Increment();
-  GlImplementation::Uniform1f(location,x);
+  GlImplementation::Uniform1f( location, x );
 }
 
 void GlProxyImplementation::Uniform1fv( GLint location, GLsizei count, const GLfloat* v )
 {
   mUniformSampler.Increment();
-  GlImplementation::Uniform1fv(location,count,v);
+  GlImplementation::Uniform1fv( location, count, v );
 }
 
 void GlProxyImplementation::Uniform1i( GLint location, GLint x )
 {
   mUniformSampler.Increment();
-  GlImplementation::Uniform1i(location,x);
+  GlImplementation::Uniform1i( location, x );
 }
 
 void GlProxyImplementation::Uniform1iv( GLint location, GLsizei count, const GLint* v )
 {
   mUniformSampler.Increment();
-  GlImplementation::Uniform1iv(location,count,v);
+  GlImplementation::Uniform1iv( location, count, v );
 }
 
 void GlProxyImplementation::Uniform2f( GLint location, GLfloat x, GLfloat y)
 {
   mUniformSampler.Increment();
-  GlImplementation::Uniform2f(location,x,y);
+  GlImplementation::Uniform2f( location, x, y );
 }
 
 void GlProxyImplementation::Uniform2fv( GLint location, GLsizei count, const GLfloat* v )
 {
   mUniformSampler.Increment();
-  GlImplementation::Uniform2fv(location,count,v);
+  GlImplementation::Uniform2fv( location, count, v );
 }
 
 void GlProxyImplementation::Uniform2i( GLint location, GLint x, GLint y )
 {
   mUniformSampler.Increment();
-  GlImplementation::Uniform2i(location,x,y);
+  GlImplementation::Uniform2i( location, x, y );
 }
 
 void GlProxyImplementation::Uniform2iv( GLint location, GLsizei count, const GLint* v )
 {
   mUniformSampler.Increment();
-  GlImplementation::Uniform2iv(location,count,v);
+  GlImplementation::Uniform2iv( location, count, v );
 }
 
-void GlProxyImplementation::Uniform3f( GLint location, GLfloat x, GLfloat y, GLfloat z)
+void GlProxyImplementation::Uniform3f( GLint location, GLfloat x, GLfloat y, GLfloat z )
 {
   mUniformSampler.Increment();
-  GlImplementation::Uniform3f(location,x,y,z);
+  GlImplementation::Uniform3f( location, x, y, z );
 }
 
 void GlProxyImplementation::Uniform3fv( GLint location, GLsizei count, const GLfloat* v )
 {
   mUniformSampler.Increment();
-  GlImplementation::Uniform3fv(location,count,v);
+  GlImplementation::Uniform3fv( location, count, v );
 }
 
 void GlProxyImplementation::Uniform3i( GLint location, GLint x, GLint y, GLint z )
 {
   mUniformSampler.Increment();
-  GlImplementation::Uniform3i(location,x,y,z);
+  GlImplementation::Uniform3i( location, x, y, z );
 }
 
 void GlProxyImplementation::Uniform3iv( GLint location, GLsizei count, const GLint* v )
 {
   mUniformSampler.Increment();
-  GlImplementation::Uniform3iv(location,count,v);
+  GlImplementation::Uniform3iv( location, count, v );
 }
 
 void GlProxyImplementation::Uniform4f( GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w )
 {
   mUniformSampler.Increment();
-  GlImplementation::Uniform4f(location,x,y,z,w);
+  GlImplementation::Uniform4f( location, x, y, z, w );
 }
 
 void GlProxyImplementation::Uniform4fv( GLint location, GLsizei count, const GLfloat* v )
 {
   mUniformSampler.Increment();
-  GlImplementation::Uniform4fv(location,count,v);
+  GlImplementation::Uniform4fv( location, count, v );
 }
 
 void GlProxyImplementation::Uniform4i( GLint location, GLint x, GLint y, GLint z, GLint w )
 {
   mUniformSampler.Increment();
-  GlImplementation::Uniform4i(location,x,y,z,w);
+  GlImplementation::Uniform4i( location, x, y, z, w );
 }
 
 void GlProxyImplementation::Uniform4iv( GLint location, GLsizei count, const GLint* v )
 {
   mUniformSampler.Increment();
-  GlImplementation::Uniform4iv(location,count,v);
+  GlImplementation::Uniform4iv( location, count, v );
 }
 
 void GlProxyImplementation::UniformMatrix2fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value )
 {
   mUniformSampler.Increment();
-  GlImplementation::UniformMatrix2fv(location,count,transpose,value);
+  GlImplementation::UniformMatrix2fv( location, count, transpose, value );
 }
 
 void GlProxyImplementation::UniformMatrix3fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value )
 {
   mUniformSampler.Increment();
-  GlImplementation::UniformMatrix3fv(location,count,transpose,value);
+  GlImplementation::UniformMatrix3fv( location, count, transpose, value );
 }
 
 void GlProxyImplementation::UniformMatrix4fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value )
 {
   mUniformSampler.Increment();
-  GlImplementation::UniformMatrix4fv(location,count,transpose,value);
+  GlImplementation::UniformMatrix4fv( location, count, transpose, value);
 }
 
-GLuint GlProxyImplementation::CreateProgram (void)
+GLuint GlProxyImplementation::CreateProgram( void )
 {
   mProgramCount.Increment();
   return GlImplementation::CreateProgram();
 }
 
-void GlProxyImplementation::DeleteProgram (GLuint program)
+void GlProxyImplementation::DeleteProgram( GLuint program )
 {
   mProgramCount.Decrement();
-  GlImplementation::DeleteProgram(program);
+  GlImplementation::DeleteProgram( program );
 }
 
 void GlProxyImplementation::UseProgram( GLuint program )
 {
   mUseProgramSampler.Increment();
-  GlImplementation::UseProgram(program);
+  GlImplementation::UseProgram( program );
 }
 
 void GlProxyImplementation::AccumulateSamples()
@@ -403,7 +416,7 @@ void GlProxyImplementation::AccumulateSamples()
 
 void GlProxyImplementation::LogResults()
 {
-  Debug::LogMessage( Debug::DebugInfo, "OpenGL ES statistics sampled over %d frames) operations per frame:\n", mFrameCount );
+  Debug::LogMessage( Debug::DebugInfo, "OpenGL ES statistics sampled over %d frames) operations per frame:\n", mTotalFrameCount );
   LogCalls( mActiveTextureSampler );
   LogCalls( mClearSampler );
   LogCalls( mBindBufferSampler );
@@ -411,7 +424,7 @@ void GlProxyImplementation::LogResults()
   LogCalls( mDrawSampler );
   LogCalls( mUniformSampler );
   LogCalls( mUseProgramSampler );
-  Debug::LogMessage( Debug::DebugInfo, "OpenGL ES Object Count:\n", mFrameCount );
+  Debug::LogMessage( Debug::DebugInfo, "OpenGL ES Object Count:\n" );
   LogObjectCounter( mBufferCount );
   LogObjectCounter( mTextureCount );
   LogObjectCounter( mProgramCount );
@@ -419,10 +432,11 @@ void GlProxyImplementation::LogResults()
 
 void GlProxyImplementation::LogCalls( const Sampler& sampler )
 {
-  Debug::LogMessage( Debug::DebugInfo, "  %s : Mean %5.2f  (Min:%5.2f, Max:%5.2f, StdDev:%5.2f)\n",
+  Debug::LogMessage( Debug::DebugInfo, "  %s : Mean %5.2f  (Min:%5.2f, Max:%5.2f, StdDev:%5.2f, Actual:%d)\n",
                      sampler.GetDescription(),
                      sampler.GetMeanValue(), sampler.GetMin(), sampler.GetMax(),
-                     sampler.GetStandardDeviation() );
+                     sampler.GetStandardDeviation(),
+                     sampler.GetCount() );
 }
 
 void GlProxyImplementation::LogObjectCounter( const ObjectCounter& sampler )
@@ -442,7 +456,7 @@ void GlProxyImplementation::ResetSamplers()
   mDrawSampler.Reset();
   mUniformSampler.Reset();
   mUseProgramSampler.Reset();
-  mFrameCount = 0;
+  mTotalFrameCount = 0;
 }
 
 } // namespace Adaptor
index 7c2a6eb..e2c1640 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_INTERNAL_GL_PROXY_IMPLEMENTATION_H__
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -45,17 +45,17 @@ public:
   /**
    * Increment the counter for this frame
    */
-  void  Increment();
+  void Increment();
 
   /**
    * Reset the counter
    */
-  void  Reset();
+  void Reset();
 
   /**
    * Accumulate the count onto statistics
    */
-  void  Accumulate();
+  void Accumulate();
 
   /**
    * @return the description of the sampler
@@ -82,14 +82,20 @@ public:
    */
   float GetMax() const;
 
+  /**
+   * @return the current count
+   */
+  uint64_t GetCount() const;
+
 private: // Data
 
   const char* mDescription;
-  float mAccumulated;
-  float mAccumulatedSquare;
+
+  uint64_t mAccumulatedSquare;
+  uint64_t mAccumulated;
+  uint64_t mNumSamples;
   float mMin;
   float mMax;
-  unsigned int mNumSamples;
   unsigned int mCurrentFrameCount;
 };
 
@@ -104,7 +110,7 @@ public:
   /**
    * Increment the counter
    */
-  void  Increment();
+  void Increment();
 
   /**
    * Decrement the counter
@@ -144,7 +150,7 @@ public:
    * Constructor
    * @param environmentOptions to check how often to log results
    */
-  GlProxyImplementation(EnvironmentOptions& environmentOptions);
+  GlProxyImplementation( EnvironmentOptions& environmentOptions );
 
   /**
    * Virtual destructor
@@ -164,13 +170,13 @@ public:
   /* OpenGL ES 2.0 API */
   virtual void Clear( GLbitfield mask );
 
-  virtual void GenBuffers (GLsizei n, GLuint* buffers);
-  virtual void DeleteBuffers (GLsizei n, const GLuint* buffers);
+  virtual void GenBuffers( GLsizei n, GLuint* buffers );
+  virtual void DeleteBuffers( GLsizei n, const GLuint* buffers );
   virtual void BindBuffer( GLenum target, GLuint buffer );
 
-  virtual void GenTextures (GLsizei n, GLuint* textures);
-  virtual void DeleteTextures (GLsizei n, const GLuint* textures);
-  virtual void ActiveTexture(GLenum texture);
+  virtual void GenTextures( GLsizei n, GLuint* textures );
+  virtual void DeleteTextures( GLsizei n, const GLuint* textures );
+  virtual void ActiveTexture( GLenum texture );
   virtual void BindTexture( GLenum target, GLuint texture );
 
   virtual void DrawArrays( GLenum mode, GLint first, GLsizei count );
@@ -196,8 +202,8 @@ public:
   virtual void UniformMatrix3fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value );
   virtual void UniformMatrix4fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value );
 
-  virtual GLuint CreateProgram (void);
-  virtual void DeleteProgram (GLuint program);
+  virtual GLuint CreateProgram( void );
+  virtual void DeleteProgram( GLuint program );
   virtual void UseProgram( GLuint program );
 
 private: // Helpers
@@ -222,8 +228,8 @@ private: // Data
   ObjectCounter mTextureCount;
   ObjectCounter mProgramCount;
 
-  int mFrameCount;
-
+  int mCurrentFrameCount;
+  int mTotalFrameCount;
 };
 
 } // namespace Adaptor