GLES2: disable texcoord when not using it (see bug #5235) similar to opengl backend code: - glDisableVertexAttribArray doesn't need to depend on 'drawstate.texture' value - move binding code to SetCopyState()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c
index ec7517b..4a326e5 100644
--- a/src/render/opengles2/SDL_render_gles2.c
+++ b/src/render/opengles2/SDL_render_gles2.c
@@ -898,39 +898,14 @@ SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, const GLES2_I
data->drawstate.cliprect_dirty = SDL_FALSE;
}
- if (texture != data->drawstate.texture) {
- if ((texture != NULL) != data->drawstate.texturing) {
- if (texture == NULL) {
- data->glDisableVertexAttribArray((GLenum) GLES2_ATTRIBUTE_TEXCOORD);
- data->drawstate.texturing = SDL_FALSE;
- } else {
- data->glEnableVertexAttribArray((GLenum) GLES2_ATTRIBUTE_TEXCOORD);
- data->drawstate.texturing = SDL_TRUE;
- }
- }
-
- if (texture) {
- GLES2_TextureData *tdata = (GLES2_TextureData *) texture->driverdata;
-#if SDL_HAVE_YUV
- if (tdata->yuv) {
- data->glActiveTexture(GL_TEXTURE2);
- data->glBindTexture(tdata->texture_type, tdata->texture_v);
-
- data->glActiveTexture(GL_TEXTURE1);
- data->glBindTexture(tdata->texture_type, tdata->texture_u);
-
- data->glActiveTexture(GL_TEXTURE0);
- } else if (tdata->nv12) {
- data->glActiveTexture(GL_TEXTURE1);
- data->glBindTexture(tdata->texture_type, tdata->texture_u);
-
- data->glActiveTexture(GL_TEXTURE0);
- }
-#endif
- data->glBindTexture(tdata->texture_type, tdata->texture);
+ if ((texture != NULL) != data->drawstate.texturing) {
+ if (texture == NULL) {
+ data->glDisableVertexAttribArray((GLenum) GLES2_ATTRIBUTE_TEXCOORD);
+ data->drawstate.texturing = SDL_FALSE;
+ } else {
+ data->glEnableVertexAttribArray((GLenum) GLES2_ATTRIBUTE_TEXCOORD);
+ data->drawstate.texturing = SDL_TRUE;
}
-
- data->drawstate.texture = texture;
}
if (texture) {
@@ -988,6 +963,7 @@ SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, void *vertice
GLES2_RenderData *data = (GLES2_RenderData *) renderer->driverdata;
GLES2_ImageSource sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
SDL_Texture *texture = cmd->data.draw.texture;
+ int ret;
/* Pick an appropriate shader */
if (renderer->target) {
@@ -1093,7 +1069,31 @@ SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, void *vertice
}
}
- return SetDrawState(data, cmd, sourceType, vertices);
+ ret = SetDrawState(data, cmd, sourceType, vertices);
+
+ if (texture != data->drawstate.texture) {
+ GLES2_TextureData *tdata = (GLES2_TextureData *) texture->driverdata;
+#if SDL_HAVE_YUV
+ if (tdata->yuv) {
+ data->glActiveTexture(GL_TEXTURE2);
+ data->glBindTexture(tdata->texture_type, tdata->texture_v);
+
+ data->glActiveTexture(GL_TEXTURE1);
+ data->glBindTexture(tdata->texture_type, tdata->texture_u);
+
+ data->glActiveTexture(GL_TEXTURE0);
+ } else if (tdata->nv12) {
+ data->glActiveTexture(GL_TEXTURE1);
+ data->glBindTexture(tdata->texture_type, tdata->texture_u);
+
+ data->glActiveTexture(GL_TEXTURE0);
+ }
+#endif
+ data->glBindTexture(tdata->texture_type, tdata->texture);
+ data->drawstate.texture = texture;
+ }
+
+ return ret;
}
static int