From 1edc42157bbb01b25ec27750f883fd84ee5908d6 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 19 May 2020 11:54:59 +0200 Subject: render/egl: introduce wlr_egl_unset_current This function can be called after wlr_egl_make_current to cleanup the EGL context. This avoids having lingering EGL contexts that make things work by chance. Closes: https://github.com/swaywm/wlroots/issues/2197 --- backend/headless/output.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'backend/headless') diff --git a/backend/headless/output.c b/backend/headless/output.c index dc0a1478..822afac9 100644 --- a/backend/headless/output.c +++ b/backend/headless/output.c @@ -35,6 +35,8 @@ static bool create_fbo(struct wlr_headless_output *output, GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); glBindFramebuffer(GL_FRAMEBUFFER, 0); + wlr_egl_unset_current(output->backend->egl); + if (status != GL_FRAMEBUFFER_COMPLETE) { wlr_log(WLR_ERROR, "Failed to create FBO"); return false; @@ -52,6 +54,9 @@ static void destroy_fbo(struct wlr_headless_output *output) { glDeleteFramebuffers(1, &output->fbo); glDeleteRenderbuffers(1, &output->rbo); + + wlr_egl_unset_current(output->backend->egl); + output->fbo = 0; output->rbo = 0; } @@ -125,21 +130,23 @@ static bool output_commit(struct wlr_output *wlr_output) { } if (wlr_output->pending.committed & WLR_OUTPUT_STATE_BUFFER) { + glBindFramebuffer(GL_FRAMEBUFFER, 0); + wlr_egl_unset_current(output->backend->egl); + // Nothing needs to be done for FBOs wlr_output_send_present(wlr_output, NULL); } - wlr_egl_make_current(output->backend->egl, EGL_NO_SURFACE, NULL); - glBindFramebuffer(GL_FRAMEBUFFER, 0); - return true; } static void output_rollback(struct wlr_output *wlr_output) { struct wlr_headless_output *output = headless_output_from_output(wlr_output); - wlr_egl_make_current(output->backend->egl, EGL_NO_SURFACE, NULL); - glBindFramebuffer(GL_FRAMEBUFFER, 0); + if (wlr_output->pending.committed & WLR_OUTPUT_STATE_BUFFER) { + glBindFramebuffer(GL_FRAMEBUFFER, 0); + wlr_egl_unset_current(output->backend->egl); + } } static void output_destroy(struct wlr_output *wlr_output) { -- cgit v1.2.3