return mMax;
}
+ObjectCounter::ObjectCounter( const char* description )
+:mDescription(description),
+ mCount(0),
+ mPeak(0)
+{}
+
+void ObjectCounter::Increment()
+{
+ ++mCount;
+ if( mCount > mPeak )
+ {
+ mPeak = mCount;
+ }
+}
+
+void ObjectCounter::Decrement()
+{
+ --mCount;
+}
+
+unsigned int ObjectCounter::GetCount() const
+{
+ return mCount;
+}
+unsigned int ObjectCounter::GetPeak() const
+{
+ return mPeak;
+}
+
+const char* ObjectCounter::GetDescription() const
+{
+ return mDescription;
+}
+
GlProxyImplementation::GlProxyImplementation(EnvironmentOptions& environmentOptions)
: mEnvironmentOptions(environmentOptions),
mActiveTextureSampler( "ActiveTexture calls"),
mDrawSampler("Draw calls"),
mUniformSampler("Uniform sets"),
mUseProgramSampler("Used programs"),
- mDrawCount(0),
- mUniformCount(0),
+ mBufferCount( "Buffer Count"),
+ mTextureCount("Texture Count"),
+ mProgramCount("Program Count"),
mFrameCount(0)
{
}
}
}
-void GlProxyImplementation::ActiveTexture( GLenum texture )
-{
- mActiveTextureSampler.Increment();
- GlImplementation::ActiveTexture(texture);
-}
-
void GlProxyImplementation::Clear( GLbitfield mask )
{
mClearSampler.Increment();
GlImplementation::Clear(mask);
}
+void GlProxyImplementation::GenBuffers (GLsizei n, GLuint* buffers)
+{
+ mBufferCount.Increment();
+ GlImplementation::GenBuffers( n, buffers );
+}
+
+void GlProxyImplementation::DeleteBuffers (GLsizei n, const GLuint* buffers)
+{
+ mBufferCount.Decrement();
+ GlImplementation::DeleteBuffers( n, buffers );
+}
+
void GlProxyImplementation::BindBuffer( GLenum target, GLuint buffer )
{
mBindBufferSampler.Increment();
GlImplementation::BindBuffer(target,buffer);
}
+void GlProxyImplementation::GenTextures (GLsizei n, GLuint* textures)
+{
+ mTextureCount.Increment();
+ GlImplementation::GenTextures( n, textures );
+}
+
+void GlProxyImplementation::DeleteTextures (GLsizei n, const GLuint* textures)
+{
+ mTextureCount.Decrement();
+ GlImplementation::DeleteTextures( n, textures );
+}
+
+void GlProxyImplementation::ActiveTexture( GLenum texture )
+{
+ mActiveTextureSampler.Increment();
+ GlImplementation::ActiveTexture(texture);
+}
+
void GlProxyImplementation::BindTexture( GLenum target, GLuint texture )
{
mBindTextureSampler.Increment();
GlImplementation::UniformMatrix4fv(location,count,transpose,value);
}
+GLuint GlProxyImplementation::CreateProgram (void)
+{
+ mProgramCount.Increment();
+ return GlImplementation::CreateProgram();
+}
+
+void GlProxyImplementation::DeleteProgram (GLuint program)
+{
+ mProgramCount.Decrement();
+ GlImplementation::DeleteProgram(program);
+}
+
void GlProxyImplementation::UseProgram( GLuint program )
{
mUseProgramSampler.Increment();
LogCalls( mDrawSampler );
LogCalls( mUniformSampler );
LogCalls( mUseProgramSampler );
+ Debug::LogMessage( Debug::DebugInfo, "OpenGL ES Object Count:\n", mFrameCount );
+ LogObjectCounter( mBufferCount );
+ LogObjectCounter( mTextureCount );
+ LogObjectCounter( mProgramCount );
}
void GlProxyImplementation::LogCalls( const Sampler& sampler )
sampler.GetStandardDeviation() );
}
+void GlProxyImplementation::LogObjectCounter( const ObjectCounter& sampler )
+{
+ Debug::LogMessage( Debug::DebugInfo, " %s : %u (Peak:%u)\n",
+ sampler.GetDescription(),
+ sampler.GetCount(),
+ sampler.GetPeak() );
+}
+
void GlProxyImplementation::ResetSamplers()
{
mActiveTextureSampler.Reset();
};
/**
+ * Helper class to calculate number of OpenGL objects
+ */
+class ObjectCounter
+{
+public:
+ ObjectCounter( const char* description );
+
+ /**
+ * Increment the counter
+ */
+ void Increment();
+
+ /**
+ * Decrement the counter
+ */
+ void Decrement();
+
+ /**
+ * @return The current number of objects
+ */
+ unsigned int GetCount() const;
+
+ /**
+ * @return The maximum number of objects created
+ */
+ unsigned int GetPeak() const;
+
+ /**
+ * @return the description of the sampler
+ */
+ const char* GetDescription() const;
+
+private:
+ const char* mDescription;
+ unsigned int mCount;
+ unsigned int mPeak;
+};
+
+/**
* GlProxyImplementation is a wrapper for the concrete implementation
* of GlAbstraction that also gathers statistical information.
*/
virtual void PostRender();
/* OpenGL ES 2.0 API */
- virtual void ActiveTexture(GLenum texture);
-
virtual void Clear( GLbitfield mask );
+ 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 BindTexture( GLenum target, GLuint texture );
virtual void DrawArrays( GLenum mode, GLint first, GLsizei count );
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 void UseProgram( GLuint program );
private: // Helpers
void AccumulateSamples();
void LogResults();
void LogCalls( const Sampler& sampler );
+ void LogObjectCounter( const ObjectCounter& sampler );
void ResetSamplers();
private: // Data
Sampler mDrawSampler;
Sampler mUniformSampler;
Sampler mUseProgramSampler;
- int mDrawCount;
- int mUniformCount;
+ ObjectCounter mBufferCount;
+ ObjectCounter mTextureCount;
+ ObjectCounter mProgramCount;
+
int mFrameCount;
};