Improved OpenGL point drawing performance (thanks @slime73!)

We'll do proper call batching for the SDL 2.0.22 release
This commit is contained in:
Sam Lantinga 2022-01-08 14:05:50 -08:00
parent 1a73c45a08
commit b82af9dfbf
1 changed files with 7 additions and 6 deletions

View File

@ -1111,8 +1111,7 @@ SetDrawState(GL_RenderData *data, const SDL_RenderCommand *cmd, const GL_Shader
} }
} }
vertex_array = cmd->command == SDL_RENDERCMD_DRAW_POINTS vertex_array = cmd->command == SDL_RENDERCMD_DRAW_LINES
|| cmd->command == SDL_RENDERCMD_DRAW_LINES
|| cmd->command == SDL_RENDERCMD_GEOMETRY; || cmd->command == SDL_RENDERCMD_GEOMETRY;
color_array = cmd->command == SDL_RENDERCMD_GEOMETRY; color_array = cmd->command == SDL_RENDERCMD_GEOMETRY;
texture_array = cmd->data.draw.texture != NULL; texture_array = cmd->data.draw.texture != NULL;
@ -1190,6 +1189,7 @@ GL_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertic
{ {
/* !!! FIXME: it'd be nice to use a vertex buffer instead of immediate mode... */ /* !!! FIXME: it'd be nice to use a vertex buffer instead of immediate mode... */
GL_RenderData *data = (GL_RenderData *) renderer->driverdata; GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
size_t i;
if (GL_ActivateRenderer(renderer) < 0) { if (GL_ActivateRenderer(renderer) < 0) {
return -1; return -1;
@ -1280,10 +1280,11 @@ GL_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertic
const size_t count = cmd->data.draw.count; const size_t count = cmd->data.draw.count;
const GLfloat *verts = (GLfloat *) (((Uint8 *) vertices) + cmd->data.draw.first); const GLfloat *verts = (GLfloat *) (((Uint8 *) vertices) + cmd->data.draw.first);
SetDrawState(data, cmd, SHADER_SOLID); SetDrawState(data, cmd, SHADER_SOLID);
data->glBegin(GL_POINTS);
/* SetDrawState handles glEnableClientState. */ for (i = 0; i < count; i++, verts += 2) {
data->glVertexPointer(2, GL_FLOAT, sizeof(float) * 2, verts); data->glVertex2f(verts[0], verts[1]);
data->glDrawArrays(GL_POINTS, 0, (GLsizei) count); }
data->glEnd();
break; break;
} }