Get rid of glGetError() calls in GLES2 renderer.
authorRyan C. Gordon <icculus@icculus.org>
Wed, 02 Oct 2013 22:16:11 -0400
changeset 77734af50952c730
parent 7772 6b3cc8b7c589
child 7774 c5d6c8c001be
Get rid of glGetError() calls in GLES2 renderer.

It's not usually useful, and it causes pipeline stalls.
src/render/opengles2/SDL_render_gles2.c
     1.1 --- a/src/render/opengles2/SDL_render_gles2.c	Tue Oct 01 08:47:06 2013 -0300
     1.2 +++ b/src/render/opengles2/SDL_render_gles2.c	Wed Oct 02 22:16:11 2013 -0400
     1.3 @@ -414,12 +414,7 @@
     1.4      }
     1.5  
     1.6      /* Allocate the texture */
     1.7 -    rdata->glGetError();
     1.8      rdata->glGenTextures(1, &tdata->texture);
     1.9 -    if (rdata->glGetError() != GL_NO_ERROR) {
    1.10 -        SDL_free(tdata);
    1.11 -        return SDL_SetError("Texture creation failed in glGenTextures()");
    1.12 -    }
    1.13      rdata->glActiveTexture(GL_TEXTURE0);
    1.14      rdata->glBindTexture(tdata->texture_type, tdata->texture);
    1.15      rdata->glTexParameteri(tdata->texture_type, GL_TEXTURE_MIN_FILTER, scaleMode);
    1.16 @@ -427,11 +422,6 @@
    1.17      rdata->glTexParameteri(tdata->texture_type, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    1.18      rdata->glTexParameteri(tdata->texture_type, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    1.19      rdata->glTexImage2D(tdata->texture_type, 0, format, texture->w, texture->h, 0, format, type, NULL);
    1.20 -    if (rdata->glGetError() != GL_NO_ERROR) {
    1.21 -        rdata->glDeleteTextures(1, &tdata->texture);
    1.22 -        SDL_free(tdata);
    1.23 -        return SDL_SetError("Texture creation failed");
    1.24 -    }
    1.25      texture->driverdata = tdata;
    1.26  
    1.27      if (texture->access == SDL_TEXTUREACCESS_TARGET) {
    1.28 @@ -526,7 +516,6 @@
    1.29      }
    1.30  
    1.31      /* Create a texture subimage with the supplied data */
    1.32 -    rdata->glGetError();
    1.33      rdata->glActiveTexture(GL_TEXTURE0);
    1.34      rdata->glBindTexture(tdata->texture_type, tdata->texture);
    1.35      rdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    1.36 @@ -541,9 +530,6 @@
    1.37                      src);
    1.38      SDL_free(blob);
    1.39  
    1.40 -    if (rdata->glGetError() != GL_NO_ERROR) {
    1.41 -        return SDL_SetError("Failed to update texture");
    1.42 -    }
    1.43      return 0;
    1.44  }
    1.45  
    1.46 @@ -629,7 +615,6 @@
    1.47      entry->blend_mode = blendMode;
    1.48  
    1.49      /* Create the program and link it */
    1.50 -    rdata->glGetError();
    1.51      entry->id = rdata->glCreateProgram();
    1.52      rdata->glAttachShader(entry->id, vertex->id);
    1.53      rdata->glAttachShader(entry->id, fragment->id);
    1.54 @@ -639,7 +624,7 @@
    1.55      rdata->glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_CENTER, "a_center");
    1.56      rdata->glLinkProgram(entry->id);
    1.57      rdata->glGetProgramiv(entry->id, GL_LINK_STATUS, &linkSuccessful);
    1.58 -    if (rdata->glGetError() != GL_NO_ERROR || !linkSuccessful)
    1.59 +    if (!linkSuccessful)
    1.60      {
    1.61          rdata->glDeleteProgram(entry->id);
    1.62          SDL_free(entry);
    1.63 @@ -754,7 +739,6 @@
    1.64      entry->instance = instance;
    1.65  
    1.66      /* Compile or load the selected shader instance */
    1.67 -    rdata->glGetError();
    1.68      entry->id = rdata->glCreateShader(instance->type);
    1.69      if (instance->format == (GLenum)-1)
    1.70      {
    1.71 @@ -767,7 +751,7 @@
    1.72          rdata->glShaderBinary(1, &entry->id, instance->format, instance->data, instance->length);
    1.73          compileSuccessful = GL_TRUE;
    1.74      }
    1.75 -    if (rdata->glGetError() != GL_NO_ERROR || !compileSuccessful)
    1.76 +    if (!compileSuccessful)
    1.77      {
    1.78          char *info = NULL;
    1.79          int length = 0;
    1.80 @@ -872,13 +856,7 @@
    1.81          goto fault;
    1.82  
    1.83      /* Select that program in OpenGL */
    1.84 -    rdata->glGetError();
    1.85      rdata->glUseProgram(program->id);
    1.86 -    if (rdata->glGetError() != GL_NO_ERROR)
    1.87 -    {
    1.88 -        SDL_SetError("Failed to select program");
    1.89 -        goto fault;
    1.90 -    }
    1.91  
    1.92      /* Set the current program */
    1.93      rdata->current_program = program;
    1.94 @@ -937,11 +915,7 @@
    1.95  
    1.96      /* Set the projection matrix */
    1.97      locProjection = rdata->current_program->uniform_locations[GLES2_UNIFORM_PROJECTION];
    1.98 -    rdata->glGetError();
    1.99      rdata->glUniformMatrix4fv(locProjection, 1, GL_FALSE, (GLfloat *)projection);
   1.100 -    if (rdata->glGetError() != GL_NO_ERROR) {
   1.101 -        return SDL_SetError("Failed to set orthographic projection");
   1.102 -    }
   1.103      return 0;
   1.104  }
   1.105  
   1.106 @@ -1028,8 +1002,6 @@
   1.107      int blendMode = renderer->blendMode;
   1.108      GLuint locColor;
   1.109  
   1.110 -    rdata->glGetError();
   1.111 -
   1.112      GLES2_ActivateRenderer(renderer);
   1.113  
   1.114      GLES2_SetBlendMode(rdata, blendMode);
   1.115 @@ -1080,13 +1052,9 @@
   1.116          vertices[idx * 2] = x;
   1.117          vertices[(idx * 2) + 1] = y;
   1.118      }
   1.119 -    rdata->glGetError();
   1.120      rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
   1.121      rdata->glDrawArrays(GL_POINTS, 0, count);
   1.122      SDL_stack_free(vertices);
   1.123 -    if (rdata->glGetError() != GL_NO_ERROR) {
   1.124 -        return SDL_SetError("Failed to render points");
   1.125 -    }
   1.126      return 0;
   1.127  }
   1.128  
   1.129 @@ -1110,7 +1078,6 @@
   1.130          vertices[idx * 2] = x;
   1.131          vertices[(idx * 2) + 1] = y;
   1.132      }
   1.133 -    rdata->glGetError();
   1.134      rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
   1.135      rdata->glDrawArrays(GL_LINE_STRIP, 0, count);
   1.136  
   1.137 @@ -1120,9 +1087,6 @@
   1.138          rdata->glDrawArrays(GL_POINTS, count-1, 1);
   1.139      }
   1.140      SDL_stack_free(vertices);
   1.141 -    if (rdata->glGetError() != GL_NO_ERROR) {
   1.142 -        return SDL_SetError("Failed to render lines");
   1.143 -    }
   1.144      return 0;
   1.145  }
   1.146  
   1.147 @@ -1138,7 +1102,6 @@
   1.148      }
   1.149  
   1.150      /* Emit a line loop for each rectangle */
   1.151 -    rdata->glGetError();
   1.152      for (idx = 0; idx < count; ++idx) {
   1.153          const SDL_FRect *rect = &rects[idx];
   1.154  
   1.155 @@ -1158,9 +1121,6 @@
   1.156          rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
   1.157          rdata->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
   1.158      }
   1.159 -    if (rdata->glGetError() != GL_NO_ERROR) {
   1.160 -        return SDL_SetError("Failed to render filled rects");
   1.161 -    }
   1.162      return 0;
   1.163  }
   1.164  
   1.165 @@ -1266,7 +1226,6 @@
   1.166  
   1.167      /* Select the target texture */
   1.168      locTexture = rdata->current_program->uniform_locations[GLES2_UNIFORM_TEXTURE];
   1.169 -    rdata->glGetError();
   1.170      rdata->glActiveTexture(GL_TEXTURE0);
   1.171      rdata->glBindTexture(tdata->texture_type, tdata->texture);
   1.172      rdata->glUniform1i(locTexture, 0);
   1.173 @@ -1314,9 +1273,6 @@
   1.174      texCoords[7] = (srcrect->y + srcrect->h) / (GLfloat)texture->h;
   1.175      rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_TEXCOORD, 2, GL_FLOAT, GL_FALSE, 0, texCoords);
   1.176      rdata->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
   1.177 -    if (rdata->glGetError() != GL_NO_ERROR) {
   1.178 -        return SDL_SetError("Failed to render texture");
   1.179 -    }
   1.180      return 0;
   1.181  }
   1.182  
   1.183 @@ -1432,7 +1388,6 @@
   1.184  
   1.185      /* Select the target texture */
   1.186      locTexture = rdata->current_program->uniform_locations[GLES2_UNIFORM_TEXTURE];
   1.187 -    rdata->glGetError();
   1.188      rdata->glActiveTexture(GL_TEXTURE0);
   1.189      rdata->glBindTexture(tdata->texture_type, tdata->texture);
   1.190      rdata->glUniform1i(locTexture, 0);
   1.191 @@ -1496,9 +1451,6 @@
   1.192      rdata->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
   1.193      rdata->glDisableVertexAttribArray(GLES2_ATTRIBUTE_CENTER);
   1.194      rdata->glDisableVertexAttribArray(GLES2_ATTRIBUTE_ANGLE);
   1.195 -    if (rdata->glGetError() != GL_NO_ERROR) {
   1.196 -        return SDL_SetError("Failed to render texture");
   1.197 -    }
   1.198      return 0;
   1.199  }
   1.200  
   1.201 @@ -1695,7 +1647,6 @@
   1.202  
   1.203      /* Determine supported shader formats */
   1.204      /* HACK: glGetInteger is broken on the Zune HD's compositor, so we just hardcode this */
   1.205 -    rdata->glGetError();
   1.206  #ifdef ZUNE_HD
   1.207      nFormats = 1;
   1.208  #else /* !ZUNE_HD */
   1.209 @@ -1716,12 +1667,6 @@
   1.210      rdata->shader_formats[0] = GL_NVIDIA_PLATFORM_BINARY_NV;
   1.211  #else /* !ZUNE_HD */
   1.212      rdata->glGetIntegerv(GL_SHADER_BINARY_FORMATS, (GLint *)rdata->shader_formats);
   1.213 -    if (rdata->glGetError() != GL_NO_ERROR)
   1.214 -    {
   1.215 -        GLES2_DestroyRenderer(renderer);
   1.216 -        SDL_SetError("Failed to query supported shader formats");
   1.217 -        return NULL;
   1.218 -    }
   1.219      if (hasCompiler)
   1.220          rdata->shader_formats[nFormats - 1] = (GLenum)-1;
   1.221  #endif /* ZUNE_HD */