Change from using glDrawElements/glDrawElementsBaseVertex to glDrawRangeElements/glDrawRangeElementsBaseVertex. On Mali, this reduces a internal function usage from 8% to off the charts.

This commit is contained in:
Ryan Houdek 2013-07-26 14:50:51 +00:00
parent bff2bc1288
commit 6887a0c341
2 changed files with 7 additions and 6 deletions

View File

@ -31,6 +31,7 @@
#define GL_SRC1_ALPHA 0 #define GL_SRC1_ALPHA 0
#define GL_BGRA GL_RGBA #define GL_BGRA GL_RGBA
#define glDrawElementsBaseVertex #define glDrawElementsBaseVertex
#define glDrawRangeElementsBaseVertex
#define GLRENDERBUFFERFORMAT 0x8058 /* RGBA8_OES */ #define GLRENDERBUFFERFORMAT 0x8058 /* RGBA8_OES */
#endif #endif
#else #else

View File

@ -120,33 +120,33 @@ void VertexManager::Draw(u32 stride)
if(g_ogl_config.bSupportsGLBaseVertex) { if(g_ogl_config.bSupportsGLBaseVertex) {
if (triangle_index_size > 0) if (triangle_index_size > 0)
{ {
glDrawElementsBaseVertex(triangle_mode, triangle_index_size, GL_UNSIGNED_SHORT, (u8*)NULL+s_offset[0], s_baseVertex); glDrawRangeElementsBaseVertex(triangle_mode, 0, IndexGenerator::GetNumTriangles() * 3, triangle_index_size, GL_UNSIGNED_SHORT, (u8*)NULL+s_offset[0], s_baseVertex);
INCSTAT(stats.thisFrame.numIndexedDrawCalls); INCSTAT(stats.thisFrame.numIndexedDrawCalls);
} }
if (line_index_size > 0) if (line_index_size > 0)
{ {
glDrawElementsBaseVertex(GL_LINES, line_index_size, GL_UNSIGNED_SHORT, (u8*)NULL+s_offset[1], s_baseVertex); glDrawRangeElementsBaseVertex(GL_LINES, 0, IndexGenerator::GetNumLines() * 2, line_index_size, GL_UNSIGNED_SHORT, (u8*)NULL+s_offset[1], s_baseVertex);
INCSTAT(stats.thisFrame.numIndexedDrawCalls); INCSTAT(stats.thisFrame.numIndexedDrawCalls);
} }
if (point_index_size > 0) if (point_index_size > 0)
{ {
glDrawElementsBaseVertex(GL_POINTS, point_index_size, GL_UNSIGNED_SHORT, (u8*)NULL+s_offset[2], s_baseVertex); glDrawRangeElementsBaseVertex(GL_POINTS, 0, IndexGenerator::GetNumPoints(), point_index_size, GL_UNSIGNED_SHORT, (u8*)NULL+s_offset[2], s_baseVertex);
INCSTAT(stats.thisFrame.numIndexedDrawCalls); INCSTAT(stats.thisFrame.numIndexedDrawCalls);
} }
} else { } else {
if (triangle_index_size > 0) if (triangle_index_size > 0)
{ {
glDrawElements(triangle_mode, triangle_index_size, GL_UNSIGNED_SHORT, (u8*)NULL+s_offset[0]); glDrawRangeElements(triangle_mode, 0, IndexGenerator::GetNumTriangles() * 3, triangle_index_size, GL_UNSIGNED_SHORT, (u8*)NULL+s_offset[0]);
INCSTAT(stats.thisFrame.numIndexedDrawCalls); INCSTAT(stats.thisFrame.numIndexedDrawCalls);
} }
if (line_index_size > 0) if (line_index_size > 0)
{ {
glDrawElements(GL_LINES, line_index_size, GL_UNSIGNED_SHORT, (u8*)NULL+s_offset[1]); glDrawRangeElements(GL_LINES, 0, IndexGenerator::GetNumLines() * 2, line_index_size, GL_UNSIGNED_SHORT, (u8*)NULL+s_offset[1]);
INCSTAT(stats.thisFrame.numIndexedDrawCalls); INCSTAT(stats.thisFrame.numIndexedDrawCalls);
} }
if (point_index_size > 0) if (point_index_size > 0)
{ {
glDrawElements(GL_POINTS, point_index_size, GL_UNSIGNED_SHORT, (u8*)NULL+s_offset[2]); glDrawRangeElements(GL_POINTS, 0, IndexGenerator::GetNumPoints(), point_index_size, GL_UNSIGNED_SHORT, (u8*)NULL+s_offset[2]);
INCSTAT(stats.thisFrame.numIndexedDrawCalls); INCSTAT(stats.thisFrame.numIndexedDrawCalls);
} }
} }