egl/wayland: Allow EGLSurface to outlive wl_egl_window
According to the EGL spec, it is entirely valid for an EGLSurface to outlive the native_window it was created from, provided that SwapBuffers and MakeCurrent return EGL_BAD_NATIVE_WINDOW. We don't have any facility to error on MakeCurrent, so just make sure we can bundle on safely through rendering for now, then return EGL_BAD_NATIVE_WINDOW from SwapBuffers. Signed-off-by: Daniel Stone <daniels@collabora.com> Reviewed-by: Simon Ser <contact@emersion.fr> Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2251 Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4902 Cc: mesa-stable Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11979>
This commit is contained in:
@@ -653,8 +653,9 @@ update_buffers(struct dri2_egl_surface *dri2_surf)
|
||||
struct dri2_egl_display *dri2_dpy =
|
||||
dri2_egl_display(dri2_surf->base.Resource.Display);
|
||||
|
||||
if (dri2_surf->base.Width != dri2_surf->wl_win->width ||
|
||||
dri2_surf->base.Height != dri2_surf->wl_win->height) {
|
||||
if (dri2_surf->wl_win &&
|
||||
(dri2_surf->base.Width != dri2_surf->wl_win->width ||
|
||||
dri2_surf->base.Height != dri2_surf->wl_win->height)) {
|
||||
|
||||
dri2_surf->base.Width = dri2_surf->wl_win->width;
|
||||
dri2_surf->base.Height = dri2_surf->wl_win->height;
|
||||
@@ -662,8 +663,9 @@ update_buffers(struct dri2_egl_surface *dri2_surf)
|
||||
dri2_surf->dy = dri2_surf->wl_win->dy;
|
||||
}
|
||||
|
||||
if (dri2_surf->base.Width != dri2_surf->wl_win->attached_width ||
|
||||
dri2_surf->base.Height != dri2_surf->wl_win->attached_height) {
|
||||
if (dri2_surf->wl_win &&
|
||||
(dri2_surf->base.Width != dri2_surf->wl_win->attached_width ||
|
||||
dri2_surf->base.Height != dri2_surf->wl_win->attached_height)) {
|
||||
dri2_wl_release_buffers(dri2_surf);
|
||||
}
|
||||
|
||||
@@ -1043,6 +1045,9 @@ dri2_wl_swap_buffers_with_damage(_EGLDisplay *disp,
|
||||
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
|
||||
struct dri2_egl_surface *dri2_surf = dri2_egl_surface(draw);
|
||||
|
||||
if (!dri2_surf->wl_win)
|
||||
return _eglError(EGL_BAD_NATIVE_WINDOW, "dri2_swap_buffers");
|
||||
|
||||
while (dri2_surf->throttle_callback != NULL)
|
||||
if (wl_display_dispatch_queue(dri2_dpy->wl_dpy,
|
||||
dri2_surf->wl_queue) == -1)
|
||||
@@ -1686,8 +1691,9 @@ swrast_update_buffers(struct dri2_egl_surface *dri2_surf)
|
||||
if (dri2_surf->back)
|
||||
return 0;
|
||||
|
||||
if (dri2_surf->base.Width != dri2_surf->wl_win->width ||
|
||||
dri2_surf->base.Height != dri2_surf->wl_win->height) {
|
||||
if (dri2_surf->wl_win &&
|
||||
(dri2_surf->base.Width != dri2_surf->wl_win->width ||
|
||||
dri2_surf->base.Height != dri2_surf->wl_win->height)) {
|
||||
|
||||
dri2_wl_release_buffers(dri2_surf);
|
||||
|
||||
@@ -1933,6 +1939,9 @@ dri2_wl_swrast_swap_buffers(_EGLDisplay *disp, _EGLSurface *draw)
|
||||
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
|
||||
struct dri2_egl_surface *dri2_surf = dri2_egl_surface(draw);
|
||||
|
||||
if (!dri2_surf->wl_win)
|
||||
return _eglError(EGL_BAD_NATIVE_WINDOW, "dri2_swap_buffers");
|
||||
|
||||
dri2_dpy->core->swapBuffers(dri2_surf->dri_drawable);
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
Reference in New Issue
Block a user