Hi All,
When performing a glClear with stencil, the processing time increases.
// ...
/*Frame(52)*/
eglSwapBuffers(egl_Display, egl_Surface);
eglGetError();
glGetError();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // no problem! (takes 0.6ms)
glBindTexture(GL_TEXTURE_2D, TO[28]);
glUseProgram(PO[4]);
{
const GLfloat v[]={1.000000};
glProgramUniform1fv(PO[4], UF7, 1, v);
}
{
const GLfloat v[]={1280.000000, 0.000000, 0.000000, 0.000000, 324.000000, 0.000000, 0.000000, 0.000000, 1.000000};
glProgramUniformMatrix3fv(PO[4], UF1, 1, 1, v);
}
GetTimeDrawElementst(0);
glBindTexture(GL_TEXTURE_2D, TO[29]);
{
const GLfloat v[]={648.000000, 0.000000, 317.000000, 0.000000, 324.000000, 0.000000, 0.000000, 0.000000, 1.000000};
glProgramUniformMatrix3fv(PO[4], UF1, 1, 1, v);
}
GetTimeDrawElementst(0);
glBindTexture(GL_TEXTURE_2D, TO[30]);
{
const GLfloat v[]={0.000000, 0.713942, 1.000000, 0.713942, 0.000000, 1.000000, 1.000000, 1.000000};
glProgramUniform2fv(PO[4], UF3, 4, v);
}
{
const GLfloat v[]={1280.000000, 0.000000, 0.000000, 0.000000, 297.500000, 0.000000, 0.000000, 0.000000, 1.000000};
glProgramUniformMatrix3fv(PO[4], UF1, 1, 1, v);
}
GetTimeDrawElementst(0);
glEnable(GL_CULL_FACE);
glFrontFace(GL_CCW);
glCullFace(GL_BACK);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glDepthRangef(0.000000, 1.000000);
glViewport(0, 367, 1280, 480);
glEnable(GL_SCISSOR_TEST);
glScissor(0, 367, 1280, 480);
glClear(GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // problem! (takes time 65ms), If I remove GL_STENCIL_BUFFER_BIT, there is no problem.
GetTimeClear(1);
glDepthFunc(GL_ALWAYS);
glViewport(0, 0, 1920, 720);
glDisable(GL_SCISSOR_TEST);
glDisable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glBindFramebuffer(GL_FRAMEBUFFER, FBO[3]);
glViewport(0, -240, 1920, 720);
glStencilMask(0x000000ff);
glClearStencil(0);
GetTimeClear(2);
glEnable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glViewport(0, 367, 1280, 480);
glEnable(GL_SCISSOR_TEST);
// ...
In the code above, calling glClear takes time 65ms.
Conversely, if I remove the glClear with depth and stencil, the subsequent glClear takes time 0.6ms.
This means that if I render multiple frames and then call glClear with stencil for the first time, the time will only increase (even if subsequent glClears include stencil, the time will not increase).
I’m confused if this is a bug in the GPU driver, or if I’m not following the OpenGL programming rules properly, does anyone know anything about this phenomenon?
I’m using the Mali-G51 GPU.
Thanks.