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
This commit is contained in:
Simon Ser 2020-05-20 12:39:35 +02:00 committed by Drew DeVault
parent 72f28ed0b3
commit af2f69e6c1
5 changed files with 2 additions and 14 deletions

View File

@ -556,8 +556,6 @@ static bool drm_connector_commit(struct wlr_output *output) {
} }
} }
wlr_egl_unset_current(&drm->renderer.egl);
return true; return true;
} }
@ -967,8 +965,6 @@ static bool drm_connector_set_cursor(struct wlr_output *output,
return false; return false;
} }
wlr_egl_unset_current(&plane->surf.renderer->egl);
plane->cursor_enabled = true; plane->cursor_enabled = true;
} }

View File

@ -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_clear(renderer, (float[]){ 0.0, 0.0, 0.0, 1.0 });
wlr_renderer_end(renderer); wlr_renderer_end(renderer);
wlr_egl_unset_current(&surf->renderer->egl);
return true; return true;
} }
@ -415,8 +413,6 @@ struct gbm_bo *drm_fb_acquire(struct wlr_drm_fb *fb, struct wlr_drm_backend *drm
return NULL; return NULL;
} }
wlr_egl_unset_current(&mgpu->renderer->egl);
fb->mgpu_bo = gbm_surface_lock_front_buffer(mgpu->gbm); fb->mgpu_bo = gbm_surface_lock_front_buffer(mgpu->gbm);
if (!fb->mgpu_bo) { if (!fb->mgpu_bo) {
wlr_log(WLR_ERROR, "Failed to lock front buffer"); wlr_log(WLR_ERROR, "Failed to lock front buffer");

View File

@ -300,8 +300,6 @@ static bool output_commit(struct wlr_output *wlr_output) {
} }
} }
wlr_egl_unset_current(&output->backend->egl);
return true; 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_swap_buffers(&backend->egl, egl_surface, NULL);
wlr_egl_destroy_surface(&backend->egl, egl_surface); wlr_egl_destroy_surface(&backend->egl, egl_surface);
wlr_egl_unset_current(&backend->egl);
} else { } else {
wl_surface_attach(surface, NULL, 0, 0); wl_surface_attach(surface, NULL, 0, 0);
wl_surface_commit(surface); wl_surface_commit(surface);
@ -584,7 +581,6 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *wlr_backend) {
NULL)) { NULL)) {
goto error; goto error;
} }
wlr_egl_unset_current(&output->backend->egl);
wl_list_insert(&backend->outputs, &output->link); wl_list_insert(&backend->outputs, &output->link);
wlr_output_update_enabled(wlr_output, true); wlr_output_update_enabled(wlr_output, true);

View File

@ -157,8 +157,6 @@ static bool output_commit(struct wlr_output *wlr_output) {
wlr_output_send_present(wlr_output, NULL); wlr_output_send_present(wlr_output, NULL);
} }
wlr_egl_unset_current(&x11->egl);
return true; return true;
} }

View File

@ -449,6 +449,8 @@ bool wlr_egl_swap_buffers(struct wlr_egl *egl, EGLSurface surface,
wlr_log(WLR_ERROR, "eglSwapBuffers failed"); wlr_log(WLR_ERROR, "eglSwapBuffers failed");
return false; return false;
} }
wlr_egl_unset_current(egl);
return true; return true;
} }