backend/drm: fix current EGL context on multi-GPU

get_tex_for_bo changes the current EGL context. Rendering operations
must immediately follow drm_surface_make_current.

Closes: https://github.com/swaywm/wlroots/issues/2209
This commit is contained in:
Simon Ser 2020-05-19 17:41:47 +02:00 committed by Drew DeVault
parent 1edc42157b
commit cfed5766b7
1 changed files with 4 additions and 5 deletions

View File

@ -390,20 +390,19 @@ struct gbm_bo *drm_fb_acquire(struct wlr_drm_fb *fb, struct wlr_drm_backend *drm
/* Perform copy across GPUs */
struct wlr_renderer *renderer = mgpu->renderer->wlr_rend;
if (!drm_surface_make_current(mgpu, NULL)) {
struct wlr_texture *tex = get_tex_for_bo(mgpu->renderer, fb->bo);
if (!tex) {
return NULL;
}
struct wlr_texture *tex = get_tex_for_bo(mgpu->renderer, fb->bo);
if (!tex) {
if (!drm_surface_make_current(mgpu, NULL)) {
return NULL;
}
float mat[9];
wlr_matrix_projection(mat, 1, 1, WL_OUTPUT_TRANSFORM_NORMAL);
struct wlr_renderer *renderer = mgpu->renderer->wlr_rend;
wlr_renderer_begin(renderer, mgpu->width, mgpu->height);
wlr_renderer_clear(renderer, (float[]){ 0.0, 0.0, 0.0, 0.0 });
wlr_render_texture_with_matrix(renderer, tex, mat, 1.0f);