omcfadde / dante

idTech4 OpenGL ES2.0 | #dante (irc.freenode.net)
http://omcfadde.blogspot.fi
GNU General Public License v3.0
111 stars 30 forks source link

RenderShaderPasses and FillDepthBuffer performance improvement #46

Closed Metzelmaennchen closed 9 years ago

Metzelmaennchen commented 9 years ago

Currenty the RenderShaderPasses and FillDepthBuffer function are enabling vertex array attrib 1 and 5 for every drawn surface. Due to the fact that each of these surfaces need at least attrib 1 and 5 it makes sense to enable them once, draw all the surfs and disabling them afterwards. Please have a look at following patch, it will drop a lot of redundant state changes and gain some performance:

diff --git a/neo/renderer/draw_common.cpp b/neo/renderer/draw_common.cpp index 40aba8c..33b25ca 100644 --- a/neo/renderer/draw_common.cpp +++ b/neo/renderer/draw_common.cpp @@ -409,9 +409,7 @@ void RB_T_FillDepthBuffer(const drawSurf_t *surf) }

    idDrawVert *ac = (idDrawVert *)vertexCache.Position(tri->ambientCache);

@@ -916,9 +911,6 @@ void RB_STD_T_RenderShaderPasses(const drawSurf_t *surf) } }

    // reset polygon offset
    if (shader->TestMaterialFlag(MF_POLYGONOFFSET)) {
            glDisable(GL_POLYGON_OFFSET_FILL);

@@ -970,6 +962,7 @@ int RB_STD_DrawShaderPasses(drawSurf_t **drawSurfs, int numDrawSurfs) globalImages->BindNull();

    GL_SelectTexture(0);