diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index d7aeab9a27..0862106d72 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -2,6 +2,7 @@ #define __VERTEXBUFFER_H #include "tarray.h" +#include "gl/utility/gl_clock.h" struct vertex_t; struct secplane_t; @@ -74,11 +75,15 @@ public: return diff; } #ifdef __GL_PCH_H // we need the system includes for this but we cannot include them ourselves without creating #define clashes. The affected files wouldn't try to draw anyway. - void RenderCurrent(FFlatVertex *newptr, unsigned int primtype) + void RenderCurrent(FFlatVertex *newptr, unsigned int primtype, unsigned int *poffset = NULL, unsigned int *pcount = NULL) { unsigned int offset; unsigned int count = GetCount(newptr, &offset); + drawcalls.Clock(); glDrawArrays(primtype, offset, count); + drawcalls.Unclock(); + if (poffset) *poffset = offset; + if (pcount) *pcount = count; } #endif void Reset() @@ -135,7 +140,7 @@ private: void SkyVertex(int r, int c, bool yflip); void CreateSkyHemisphere(int hemi); void CreateDome(); - void RenderRow(int prim, int row, bool color); + void RenderRow(int prim, int row); public: diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 71bb2197b4..39731bf740 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -332,7 +332,9 @@ void GLFlat::DrawSubsectors(int pass, bool istrans) if (gl_drawinfo->ss_renderflags[sub-subsectors]&renderflags || istrans) { if (pass == GLPASS_ALL) lightsapplied = SetupSubsectorLights(lightsapplied, sub); + drawcalls.Clock(); glDrawArrays(GL_TRIANGLE_FAN, index, sub->numlines); + drawcalls.Unclock(); flatvertices += sub->numlines; flatprimitives++; } diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 63c7bd46b3..e36dd4b0e8 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -300,8 +300,7 @@ void GLSprite::Draw(int pass) ptr++; ptr->Set(v4[0], v4[1], v4[2], ur, vb); ptr++; - count = GLRenderer->mVBO->GetCount(ptr, &offset); - glDrawArrays(GL_TRIANGLE_STRIP, offset, count); + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP, &offset, &count); } if (foglayer) diff --git a/src/gl/utility/gl_clock.cpp b/src/gl/utility/gl_clock.cpp index 7759f5582f..d8d3c28be2 100644 --- a/src/gl/utility/gl_clock.cpp +++ b/src/gl/utility/gl_clock.cpp @@ -23,6 +23,7 @@ glcycle_t All, Finish, PortalAll, Bsp; glcycle_t ProcessAll; glcycle_t RenderAll; glcycle_t Dirty; +glcycle_t drawcalls; int vertexcount, flatvertices, flatprimitives; int rendered_lines,rendered_flats,rendered_sprites,render_vertexsplit,render_texsplit,rendered_decals, rendered_portals; @@ -96,6 +97,7 @@ void ResetProfilingData() SetupFlat.Reset(); RenderSprite.Reset(); SetupSprite.Reset(); + drawcalls.Reset(); flatvertices=flatprimitives=vertexcount=0; render_texsplit=render_vertexsplit=rendered_lines=rendered_flats=rendered_sprites=rendered_decals=rendered_portals = 0; @@ -116,10 +118,10 @@ static void AppendRenderTimes(FString &str) str.AppendFormat("W: Render=%2.3f, Split = %2.3f, Setup=%2.3f, Clip=%2.3f\n" "F: Render=%2.3f, Setup=%2.3f\n" "S: Render=%2.3f, Setup=%2.3f\n" - "All=%2.3f, Render=%2.3f, Setup=%2.3f, BSP = %2.3f, Portal=%2.3f, Finish=%2.3f\n", + "All=%2.3f, Render=%2.3f, Setup=%2.3f, BSP = %2.3f, Portal=%2.3f, Drawcalls=%2.3f, Finish=%2.3f\n", RenderWall.TimeMS(), SplitWall.TimeMS(), setupwall, clipwall, RenderFlat.TimeMS(), SetupFlat.TimeMS(), RenderSprite.TimeMS(), SetupSprite.TimeMS(), All.TimeMS() + Finish.TimeMS(), RenderAll.TimeMS(), - ProcessAll.TimeMS(), bsp, PortalAll.TimeMS(), Finish.TimeMS()); + ProcessAll.TimeMS(), bsp, PortalAll.TimeMS(), drawcalls.TimeMS(), Finish.TimeMS()); } static void AppendRenderStats(FString &out) diff --git a/src/gl/utility/gl_clock.h b/src/gl/utility/gl_clock.h index cb9d0173ef..604a40a02b 100644 --- a/src/gl/utility/gl_clock.h +++ b/src/gl/utility/gl_clock.h @@ -108,6 +108,7 @@ extern glcycle_t All, Finish, PortalAll, Bsp; extern glcycle_t ProcessAll; extern glcycle_t RenderAll; extern glcycle_t Dirty; +extern glcycle_t drawcalls; extern int iter_dlightf, iter_dlight, draw_dlight, draw_dlightf; extern int rendered_lines,rendered_flats,rendered_sprites,rendered_decals,render_vertexsplit,render_texsplit;