From 7714c6172db45f1e4fbb5b71272fcef2488b3f86 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Thu, 28 Jan 2021 16:42:14 +0200 Subject: [PATCH] gl-renderer: add missing glActiveTexture calls Various functions leave the current active texture as whatever. The functions touched in this commit forgot to reset the active texture to slot 0 before binding their textures. If not explicitly unbound, this could leave textures lingering in unused slots, perhaps. Not sure if that could cause any harm, but for consistency's sake, always use slot 0 when not multitexturing. Found by code inspection. Signed-off-by: Pekka Paalanen --- libweston/renderer-gl/gl-renderer.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libweston/renderer-gl/gl-renderer.c b/libweston/renderer-gl/gl-renderer.c index c87a03ee..0ef6552c 100644 --- a/libweston/renderer-gl/gl-renderer.c +++ b/libweston/renderer-gl/gl-renderer.c @@ -1721,6 +1721,8 @@ gl_renderer_flush_damage(struct weston_surface *surface) data = wl_shm_buffer_get_data(buffer->shm_buffer); + glActiveTexture(GL_TEXTURE0); + if (gs->needs_full_upload || quirks->gl_force_full_upload) { glPixelStorei(GL_UNPACK_SKIP_PIXELS_EXT, 0); glPixelStorei(GL_UNPACK_SKIP_ROWS_EXT, 0); @@ -1786,6 +1788,8 @@ ensure_textures(struct gl_surface_state *gs, int num_textures) if (num_textures <= gs->num_textures) return; + glActiveTexture(GL_TEXTURE0); + for (i = gs->num_textures; i < num_textures; i++) { glGenTextures(1, &gs->textures[i]); glBindTexture(gs->target, gs->textures[i]); @@ -2861,6 +2865,7 @@ gl_renderer_surface_copy_content(struct weston_surface *surface, if (!gl_renderer_use_program(gr, &shader)) return -1; + glActiveTexture(GL_TEXTURE0); glGenTextures(1, &tex); glBindTexture(GL_TEXTURE_2D, tex); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, cw, ch,