Hi all, I have implemented a simple batching code. The goal of my batching is to group each VAO by material pass, where each material pass is related with a unique shader program, then I minimized the calls to glUseProgram, doing only one per registered pass type.
In each pass ( one per batch entry ) I have custom variables which are linked as uniforms to the shader, apart of this I have custom GL states, like “GL_DEPTH_TEST” or “glPolygonOffSet” among others.
Here a pseudo code of how it works:
for( BatchGroup *group : this->groups )
{
glUseProgram( group->GetShader()->GetId( ) );
for( BatchEntry *entry : group->entries )
{
// get the material pass, which have custom shader values and GL states
Pass *pass = entry->GetPass( );
// set custom GL states ( glCullMode, glEnable, glDisable ... )
pass->SetGLStates( )
// bind custom variables to shader program
pass->BindUniforms( group->GetShader( ) )
// call glDrawElements ...
entry->Draw( )
}
}
My question is about the line “pass->SetGLStates( )”, is it correct to have differents GL states in the same batch group? or all entries which are drawn in the same group, that is, are using the same shader program, should have the same GL state.
Thanks in advance.