From 75cf82005dd2630a6dba984e0d8edf17181ef159 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 22 Feb 2024 09:39:45 -0500 Subject: [PATCH] egl/wayland/sw: move partial->full copy promotion to swapbuffers this will ensure that the wl_buffer data is always fully updated Acked-by: Daniel Stone Part-of: --- src/egl/drivers/dri2/platform_wayland.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c index ee5cda9d7e5..f1c1b08b0b9 100644 --- a/src/egl/drivers/dri2/platform_wayland.c +++ b/src/egl/drivers/dri2/platform_wayland.c @@ -2472,11 +2472,6 @@ dri2_wl_swrast_put_image2(__DRIdrawable *draw, int op, int x, int y, int w, dst = dri2_wl_swrast_get_backbuffer_data(dri2_surf); - /* partial copy, copy old content */ - if (copy_width < dst_stride) - dri2_wl_swrast_get_image(draw, 0, 0, dri2_surf->base.Width, - dri2_surf->base.Height, dst, loaderPrivate); - dst += x_offset; dst += y * dst_stride; @@ -2519,9 +2514,22 @@ dri2_wl_swrast_swap_buffers_with_damage(_EGLDisplay *disp, _EGLSurface *draw, if (!disp->Options.Zink) (void)swrast_update_buffers(dri2_surf); - if (!disp->Options.Zink) + if (!disp->Options.Zink) { dri2_wl_swrast_attach_backbuffer(dri2_surf); + /* guarantee full copy for partial update */ + int w = n_rects == 1 ? (rects[2] - rects[0]) : 0; + int copy_width = dri2_wl_swrast_get_stride_for_format(dri2_surf->format, w); + int dst_stride = dri2_wl_swrast_get_stride_for_format(dri2_surf->format, + dri2_surf->base.Width); + char *dst = dri2_wl_swrast_get_backbuffer_data(dri2_surf); + + /* partial copy, copy old content */ + if (copy_width < dst_stride) + dri2_wl_swrast_get_image(NULL, 0, 0, dri2_surf->base.Width, + dri2_surf->base.Height, dst, dri2_surf); + } + if (n_rects) dri2_dpy->core->swapBuffersWithDamage(dri2_surf->dri_drawable, n_rects, rects); else