Switches instead of if ladders

This commit is contained in:
Luke Benstead 2022-11-04 19:24:12 +00:00
parent 8ca70a2920
commit b6593acc83

View File

@ -866,14 +866,15 @@ static void generate(SubmissionTarget* target, const GLenum mode, const GLsizei
if(indices) { if(indices) {
generateElementsFastPath(target, first, count, indices, type); generateElementsFastPath(target, first, count, indices, type);
} else { } else {
if(mode == GL_QUADS) { switch(mode) {
generateArraysFastPath_QUADS(target, first, count); case GL_QUADS:
return; // Don't need to do any more processing generateArraysFastPath_QUADS(target, first, count);
} else if(mode == GL_TRIANGLES) { return; // Don't need to do any more processing
generateArraysFastPath_TRIS(target, first, count); case GL_TRIANGLES:
return; // Don't need to do any more processing generateArraysFastPath_TRIS(target, first, count);
} else { return; // Don't need to do any more processing
generateArraysFastPath_ALL(target, first, count); default:
generateArraysFastPath_ALL(target, first, count);
} }
} }
} else { } else {
@ -1088,12 +1089,18 @@ GL_FORCE_INLINE void submitVertices(GLenum mode, GLsizei first, GLuint count, GL
* We optimise the triangle and quad cases. * We optimise the triangle and quad cases.
*/ */
if(mode == GL_POLYGON) { if(mode == GL_POLYGON) {
if(count == 3) { switch(count) {
mode = GL_TRIANGLES; case 2:
} else if(count == 4) { mode = GL_LINES;
mode = GL_QUADS; break;
} else { case 3:
mode = GL_TRIANGLE_FAN; mode = GL_TRIANGLES;
break;
case 4:
mode = GL_QUADS;
break;
default:
mode = GL_TRIANGLE_FAN;
} }
} }