We are noticing around 10% performance drop when MSAA is turned on (compared to MSAA turned off) during rendering to FBO.
Is it normal to see this amount of performance drop?
Example code for creting and rendering FBO:
[pre]
void Createframebuffer()
{
int width = 1920;
int height = 720;
int m_iMaxSamples = 0;
glGetIntegerv( GL_MAX_SAMPLES_IMG, &m_iMaxSamples );
m_iMaxSamples = m_iMaxSamples >> 1;
glGenFramebuffers( 1, m_iFrameBuffer);
glGenTextures( 1, m_iFrameTexture);
glGenRenderbuffers( 1, &m_iDepthBuffer);
glBindTexture(GL_TEXTURE_2D,m_iFrameTexture);
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL );
/// Texture Parameter Setting
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
/// Render Buffer Bind ( Depth )
glBindRenderbuffer( GL_RENDERBUFFER, m_iDepthBuffer );
if( true == m_b_IMG_multisampled_FBO)
{
glRenderbufferStorageMultisampleIMG( GL_RENDERBUFFER, m_iMaxSamples, GL_DEPTH_COMPONENT16, width, height );
}
else
{
glRenderbufferStorage( GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height );
}
/// Frame Buffer Bind
glBindFramebuffer(GL_FRAMEBUFFER, m_iFrameBuffer);
if( true == m_b_IMG_multisampled_FBO)
{
glFramebufferTexture2DMultisampleIMG( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_iFrameTexture, 0, m_iMaxSamples);
}
else
{
glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_iFrameTexture, 0);
}
/// Attaching a Renderbuffer as a Framebuffer Attachment
glFramebufferRenderbuffer( GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_iDepthBuffer);
glBindFramebuffer(GL_FRAMEBUFFER, m_iDefaultFrameBuffer);
}
void Drawdone()
{
glBindFramebuffer(GL_FRAMEBUFFER, 0);
float VertexList[] =
{
-1.0f, -1.0f, 0.0f, 0.0f,
1.0f, -1.0f, 1.0f, 0.0f,
-1.0f, 1.0f, 0.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f
};
glBindTexture(GL_TEXTURE_2D, m_iFrameTexture);
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glEnableVertexAttribArray( 0 );
glEnableVertexAttribArray( 1 );
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), VertexList);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), (VertexList + 2));
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glDisableVertexAttribArray( 0 );
glDisableVertexAttribArray( 1 );
eglSwapBuffers( m_eglDisplay, m_eglSurface );
glBindFramebuffer(GL_FRAMEBUFFER, m_iFrameBuffer);
}
[/pre]
Also, does increasing/decreasing number of samples affect the performance?
Thanks in advance