GLES2: revert https://github.com/libsdl-org/SDL/commit/7bf8c5a388bc41dde830e4baabcb53d507e64448
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 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c
index 6a03706..ec7517b 100644
--- a/src/render/opengles2/SDL_render_gles2.c
+++ b/src/render/opengles2/SDL_render_gles2.c
@@ -857,45 +857,6 @@ GLES2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture
return 0;
}
-static void
-SetTextureState(GLES2_RenderData *data, SDL_Texture *texture)
-{
- 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);
- }
-
- data->drawstate.texture = texture;
- }
-}
-
static int
SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, const GLES2_ImageSource imgsrc, void *vertices)
{
@@ -937,7 +898,40 @@ SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, const GLES2_I
data->drawstate.cliprect_dirty = SDL_FALSE;
}
- SetTextureState(data, texture);
+ 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);
+ }
+
+ data->drawstate.texture = texture;
+ }
if (texture) {
stride = sizeof(SDL_Vertex);
@@ -1358,7 +1352,7 @@ GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
GLES2_ActivateRenderer(renderer);
- SetTextureState(renderdata, NULL); /* we trash this state. */
+ renderdata->drawstate.texture = NULL; /* we trash this state. */
/* Determine the corresponding GLES texture format params */
switch (texture->format)
@@ -1587,7 +1581,7 @@ GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect
return 0;
}
- SetTextureState(data, NULL); /* we trash this state. */
+ data->drawstate.texture = NULL; /* we trash this state. */
/* Create a texture subimage with the supplied data */
data->glBindTexture(tdata->texture_type, tdata->texture);
@@ -1670,7 +1664,7 @@ GLES2_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture,
return 0;
}
- SetTextureState(data, NULL); /* we trash this state. */
+ data->drawstate.texture = NULL; /* we trash this state. */
data->glBindTexture(tdata->texture_type, tdata->texture_v);
GLES2_TexSubImage2D(data, tdata->texture_type,
@@ -1721,7 +1715,7 @@ GLES2_UpdateTextureNV(SDL_Renderer * renderer, SDL_Texture * texture,
return 0;
}
- SetTextureState(data, NULL); /* we trash this state. */
+ data->drawstate.texture = NULL; /* we trash this state. */
data->glBindTexture(tdata->texture_type, tdata->texture_u);
GLES2_TexSubImage2D(data, tdata->texture_type,
@@ -1842,7 +1836,7 @@ GLES2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
GLES2_ActivateRenderer(renderer);
if (data->drawstate.texture == texture) {
- SetTextureState(data, NULL);
+ data->drawstate.texture = NULL;
}
if (data->drawstate.target == texture) {
data->drawstate.target = NULL;
@@ -2195,3 +2189,4 @@ SDL_RenderDriver GLES2_RenderDriver = {
#endif /* SDL_VIDEO_RENDER_OGL_ES2 && !SDL_RENDER_DISABLED */
/* vi: set ts=4 sw=4 expandtab: */
+