From af2f69e6c1578f848d3e3222804444ff9cff83df Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 20 May 2020 12:39:35 +0200 Subject: [PATCH] render/egl: unset current context after swapping buffers After swapping buffers, it doesn't make sense to perform more rendering operations. Unset the context to reflect this. This commit makes it so the context is always only current between wlr_egl_make_current and wlr_egl_swap_buffers. This is an alternative to [1]. [1]: https://github.com/swaywm/wlroots/pull/2212 --- backend/drm/drm.c | 4 ---- backend/drm/renderer.c | 4 ---- backend/wayland/output.c | 4 ---- backend/x11/output.c | 2 -- render/egl.c | 2 ++ 5 files changed, 2 insertions(+), 14 deletions(-) diff --git a/backend/drm/drm.c b/backend/drm/drm.c index 8a16b1f5..65734631 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -556,8 +556,6 @@ static bool drm_connector_commit(struct wlr_output *output) { } } - wlr_egl_unset_current(&drm->renderer.egl); - return true; } @@ -967,8 +965,6 @@ static bool drm_connector_set_cursor(struct wlr_output *output, return false; } - wlr_egl_unset_current(&plane->surf.renderer->egl); - plane->cursor_enabled = true; } diff --git a/backend/drm/renderer.c b/backend/drm/renderer.c index 4d83bf31..c82663e6 100644 --- a/backend/drm/renderer.c +++ b/backend/drm/renderer.c @@ -370,8 +370,6 @@ bool drm_surface_render_black_frame(struct wlr_drm_surface *surf) { wlr_renderer_clear(renderer, (float[]){ 0.0, 0.0, 0.0, 1.0 }); wlr_renderer_end(renderer); - wlr_egl_unset_current(&surf->renderer->egl); - return true; } @@ -415,8 +413,6 @@ struct gbm_bo *drm_fb_acquire(struct wlr_drm_fb *fb, struct wlr_drm_backend *drm return NULL; } - wlr_egl_unset_current(&mgpu->renderer->egl); - fb->mgpu_bo = gbm_surface_lock_front_buffer(mgpu->gbm); if (!fb->mgpu_bo) { wlr_log(WLR_ERROR, "Failed to lock front buffer"); diff --git a/backend/wayland/output.c b/backend/wayland/output.c index 7f4f083e..f816e8ad 100644 --- a/backend/wayland/output.c +++ b/backend/wayland/output.c @@ -300,8 +300,6 @@ static bool output_commit(struct wlr_output *wlr_output) { } } - wlr_egl_unset_current(&output->backend->egl); - return true; } @@ -377,7 +375,6 @@ static bool output_set_cursor(struct wlr_output *wlr_output, wlr_egl_swap_buffers(&backend->egl, egl_surface, NULL); wlr_egl_destroy_surface(&backend->egl, egl_surface); - wlr_egl_unset_current(&backend->egl); } else { wl_surface_attach(surface, NULL, 0, 0); wl_surface_commit(surface); @@ -584,7 +581,6 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *wlr_backend) { NULL)) { goto error; } - wlr_egl_unset_current(&output->backend->egl); wl_list_insert(&backend->outputs, &output->link); wlr_output_update_enabled(wlr_output, true); diff --git a/backend/x11/output.c b/backend/x11/output.c index 9366191c..953c2ba2 100644 --- a/backend/x11/output.c +++ b/backend/x11/output.c @@ -157,8 +157,6 @@ static bool output_commit(struct wlr_output *wlr_output) { wlr_output_send_present(wlr_output, NULL); } - wlr_egl_unset_current(&x11->egl); - return true; } diff --git a/render/egl.c b/render/egl.c index ec00a12f..3003c9c5 100644 --- a/render/egl.c +++ b/render/egl.c @@ -449,6 +449,8 @@ bool wlr_egl_swap_buffers(struct wlr_egl *egl, EGLSurface surface, wlr_log(WLR_ERROR, "eglSwapBuffers failed"); return false; } + + wlr_egl_unset_current(egl); return true; }