Re: [Mesa-dev] [PATCH] egl/wayland: Try to use wl_surface.damage_buffer for SwapBuffersWithDamage
On Feb 15, 2016 3:24 AM, "Pekka Paalanen"wrote: > > On Thu, 11 Feb 2016 10:34:10 -0600 > Derek Foreman wrote: > > > Since commit d1314de293e9e4a63c35f094c3893aaaed8580b4 we ignore > > damage passed to SwapBuffersWithDamage. > > > > Wayland 1.10 now has functionality that allows us to properly > > process those damage rectangles, and a way to query if it's > > available. > > > > Now we can use wl_surface.damage_buffer and interpret the incoming > > damage as being in buffer co-ordinates. > > > > Signed-off-by: Derek Foreman > > --- > > src/egl/drivers/dri2/platform_wayland.c | 32 +--- > > 1 file changed, 29 insertions(+), 3 deletions(-) > > > > diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c > > index c2438f7..b5a5b59 100644 > > --- a/src/egl/drivers/dri2/platform_wayland.c > > +++ b/src/egl/drivers/dri2/platform_wayland.c > > @@ -653,6 +653,30 @@ create_wl_buffer(struct dri2_egl_surface *dri2_surf) > >_buffer_listener, dri2_surf); > > } > > > > +static EGLBoolean > > +try_damage_buffer(struct dri2_egl_surface *dri2_surf, > > + const EGLint *rects, > > + EGLint n_rects) > > +{ > > +#ifdef WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION > > + int i; > > + > > + if (wl_proxy_get_version((struct wl_proxy *) dri2_surf->wl_win->surface) > > + < WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION) > > + return EGL_FALSE; > > + > > + for (i = 0; i < n_rects; i++) { > > + const int *rect = [i * 4]; > > + > > + wl_surface_damage_buffer(dri2_surf->wl_win->surface, > > + rect[0], > > + dri2_surf->base.Height - rect[1] - rect[3], > > + rect[2], rect[3]); > > + } > > + return EGL_TRUE; > > +#endif > > + return EGL_FALSE; > > +} > > /** > > * Called via eglSwapBuffers(), drv->API.SwapBuffers(). > > */ > > @@ -703,10 +727,12 @@ dri2_wl_swap_buffers_with_damage(_EGLDriver *drv, > > dri2_surf->dx = 0; > > dri2_surf->dy = 0; > > > > - /* We deliberately ignore the damage region and post maximum damage, due to > > + /* If the compositor doesn't support damage_buffer, we deliberately > > +* ignore the damage region and post maximum damage, due to > > * https://bugs.freedesktop.org/78190 */ > > - wl_surface_damage(dri2_surf->wl_win->surface, > > - 0, 0, INT32_MAX, INT32_MAX); > > + if (!n_rects || !try_damage_buffer(dri2_surf, rects, n_rects)) > > + wl_surface_damage(dri2_surf->wl_win->surface, > > +0, 0, INT32_MAX, INT32_MAX); > > > > if (dri2_dpy->is_different_gpu) { > >_EGLContext *ctx = _eglGetCurrentContext(); > > Reviewed-by: Pekka Paalanen > > But I also agree with Emil that having a comment on #ifdef > WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION usage is good to add. > > Bumping the wayland-client requirement to >= 1.10 would be nice, > but currently the requirement seems to be 1.2 so I wonder if there are > other things to be cleaned up too. > > OTOH, with the #ifdef this patch could go to stable branches, couldn't > it? > > How about landing this is as is, tagged for stable, and a follow-up if > wanted to bump the wayland-client dependency on master? Would that be > appropriate? That's a very good idea. I would love to see this back ported a release or two. But we need to move quickly. 11.0 is about to be EOL. > > Thanks, > pq > > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/mesa-dev > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] egl/wayland: Try to use wl_surface.damage_buffer for SwapBuffersWithDamage
On Thu, 11 Feb 2016 10:34:10 -0600 Derek Foremanwrote: > Since commit d1314de293e9e4a63c35f094c3893aaaed8580b4 we ignore > damage passed to SwapBuffersWithDamage. > > Wayland 1.10 now has functionality that allows us to properly > process those damage rectangles, and a way to query if it's > available. > > Now we can use wl_surface.damage_buffer and interpret the incoming > damage as being in buffer co-ordinates. > > Signed-off-by: Derek Foreman > --- > src/egl/drivers/dri2/platform_wayland.c | 32 +--- > 1 file changed, 29 insertions(+), 3 deletions(-) > > diff --git a/src/egl/drivers/dri2/platform_wayland.c > b/src/egl/drivers/dri2/platform_wayland.c > index c2438f7..b5a5b59 100644 > --- a/src/egl/drivers/dri2/platform_wayland.c > +++ b/src/egl/drivers/dri2/platform_wayland.c > @@ -653,6 +653,30 @@ create_wl_buffer(struct dri2_egl_surface *dri2_surf) >_buffer_listener, dri2_surf); > } > > +static EGLBoolean > +try_damage_buffer(struct dri2_egl_surface *dri2_surf, > + const EGLint *rects, > + EGLint n_rects) > +{ > +#ifdef WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION > + int i; > + > + if (wl_proxy_get_version((struct wl_proxy *) dri2_surf->wl_win->surface) > + < WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION) > + return EGL_FALSE; > + > + for (i = 0; i < n_rects; i++) { > + const int *rect = [i * 4]; > + > + wl_surface_damage_buffer(dri2_surf->wl_win->surface, > + rect[0], > + dri2_surf->base.Height - rect[1] - rect[3], > + rect[2], rect[3]); > + } > + return EGL_TRUE; > +#endif > + return EGL_FALSE; > +} > /** > * Called via eglSwapBuffers(), drv->API.SwapBuffers(). > */ > @@ -703,10 +727,12 @@ dri2_wl_swap_buffers_with_damage(_EGLDriver *drv, > dri2_surf->dx = 0; > dri2_surf->dy = 0; > > - /* We deliberately ignore the damage region and post maximum damage, due > to > + /* If the compositor doesn't support damage_buffer, we deliberately > +* ignore the damage region and post maximum damage, due to > * https://bugs.freedesktop.org/78190 */ > - wl_surface_damage(dri2_surf->wl_win->surface, > - 0, 0, INT32_MAX, INT32_MAX); > + if (!n_rects || !try_damage_buffer(dri2_surf, rects, n_rects)) > + wl_surface_damage(dri2_surf->wl_win->surface, > +0, 0, INT32_MAX, INT32_MAX); > > if (dri2_dpy->is_different_gpu) { >_EGLContext *ctx = _eglGetCurrentContext(); Reviewed-by: Pekka Paalanen But I also agree with Emil that having a comment on #ifdef WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION usage is good to add. Bumping the wayland-client requirement to >= 1.10 would be nice, but currently the requirement seems to be 1.2 so I wonder if there are other things to be cleaned up too. OTOH, with the #ifdef this patch could go to stable branches, couldn't it? How about landing this is as is, tagged for stable, and a follow-up if wanted to bump the wayland-client dependency on master? Would that be appropriate? Thanks, pq pgph0hauASsPL.pgp Description: OpenPGP digital signature ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] egl/wayland: Try to use wl_surface.damage_buffer for SwapBuffersWithDamage
On 11 February 2016 at 16:34, Derek Foremanwrote: > Since commit d1314de293e9e4a63c35f094c3893aaaed8580b4 we ignore > damage passed to SwapBuffersWithDamage. > > Wayland 1.10 now has functionality that allows us to properly > process those damage rectangles, and a way to query if it's > available. > > Now we can use wl_surface.damage_buffer and interpret the incoming > damage as being in buffer co-ordinates. > > Signed-off-by: Derek Foreman > --- > src/egl/drivers/dri2/platform_wayland.c | 32 +--- > 1 file changed, 29 insertions(+), 3 deletions(-) > > diff --git a/src/egl/drivers/dri2/platform_wayland.c > b/src/egl/drivers/dri2/platform_wayland.c > index c2438f7..b5a5b59 100644 > --- a/src/egl/drivers/dri2/platform_wayland.c > +++ b/src/egl/drivers/dri2/platform_wayland.c > @@ -653,6 +653,30 @@ create_wl_buffer(struct dri2_egl_surface *dri2_surf) >_buffer_listener, dri2_surf); > } > > +static EGLBoolean > +try_damage_buffer(struct dri2_egl_surface *dri2_surf, > + const EGLint *rects, > + EGLint n_rects) > +{ > +#ifdef WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION > + int i; > + > + if (wl_proxy_get_version((struct wl_proxy *) dri2_surf->wl_win->surface) > + < WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION) > + return EGL_FALSE; > + > + for (i = 0; i < n_rects; i++) { > + const int *rect = [i * 4]; > + > + wl_surface_damage_buffer(dri2_surf->wl_win->surface, > + rect[0], > + dri2_surf->base.Height - rect[1] - rect[3], > + rect[2], rect[3]); > + } > + return EGL_TRUE; > +#endif I'm slightly worried about keeping this compile time. For example if we compile against old wayland, and then run against a capable one... this code won't exist thus will never get executed. Thus leading to a handful of "wtf" moments. I would just ensure it's defined at the top. #ifndef WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION #define WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION foo #endif Cheers, Emil ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] egl/wayland: Try to use wl_surface.damage_buffer for SwapBuffersWithDamage
On 12/02/16 04:46 PM, Emil Velikov wrote: > On 11 February 2016 at 16:34, Derek Foremanwrote: >> Since commit d1314de293e9e4a63c35f094c3893aaaed8580b4 we ignore >> damage passed to SwapBuffersWithDamage. >> >> Wayland 1.10 now has functionality that allows us to properly >> process those damage rectangles, and a way to query if it's >> available. >> >> Now we can use wl_surface.damage_buffer and interpret the incoming >> damage as being in buffer co-ordinates. >> >> Signed-off-by: Derek Foreman >> --- >> src/egl/drivers/dri2/platform_wayland.c | 32 >> +--- >> 1 file changed, 29 insertions(+), 3 deletions(-) >> >> diff --git a/src/egl/drivers/dri2/platform_wayland.c >> b/src/egl/drivers/dri2/platform_wayland.c >> index c2438f7..b5a5b59 100644 >> --- a/src/egl/drivers/dri2/platform_wayland.c >> +++ b/src/egl/drivers/dri2/platform_wayland.c >> @@ -653,6 +653,30 @@ create_wl_buffer(struct dri2_egl_surface *dri2_surf) >>_buffer_listener, dri2_surf); >> } >> >> +static EGLBoolean >> +try_damage_buffer(struct dri2_egl_surface *dri2_surf, >> + const EGLint *rects, >> + EGLint n_rects) >> +{ >> +#ifdef WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION >> + int i; >> + >> + if (wl_proxy_get_version((struct wl_proxy *) dri2_surf->wl_win->surface) >> + < WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION) >> + return EGL_FALSE; >> + >> + for (i = 0; i < n_rects; i++) { >> + const int *rect = [i * 4]; >> + >> + wl_surface_damage_buffer(dri2_surf->wl_win->surface, >> + rect[0], >> + dri2_surf->base.Height - rect[1] - rect[3], >> + rect[2], rect[3]); >> + } >> + return EGL_TRUE; >> +#endif > > I'm slightly worried about keeping this compile time. For example if > we compile against old wayland, and then run against a capable one... > this code won't exist thus will never get executed. Thus leading to a > handful of "wtf" moments. > > I would just ensure it's defined at the top. > > #ifndef WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION > #define WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION foo > #endif If your wayland headers don't have WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION then compilation will fail because wl_proxy_get_version() isn't present. wl_proxy_get_version() will be formally introduced in the same wayland release (next Tuesday's 1.10 release) as wl_surface_damage_buffer(), so I'm intentionally using that as a tricky way to avoid the check entirely. Too tricky? If you prefer I can work out some autoconfy stuff to determine if wl_proxy_get_version() is available? > Cheers, > Emil > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] egl/wayland: Try to use wl_surface.damage_buffer for SwapBuffersWithDamage
On 12 February 2016 at 23:09, Derek Foremanwrote: > On 12/02/16 04:46 PM, Emil Velikov wrote: >> On 11 February 2016 at 16:34, Derek Foreman wrote: >>> Since commit d1314de293e9e4a63c35f094c3893aaaed8580b4 we ignore >>> damage passed to SwapBuffersWithDamage. >>> >>> Wayland 1.10 now has functionality that allows us to properly >>> process those damage rectangles, and a way to query if it's >>> available. >>> >>> Now we can use wl_surface.damage_buffer and interpret the incoming >>> damage as being in buffer co-ordinates. >>> >>> Signed-off-by: Derek Foreman >>> --- >>> src/egl/drivers/dri2/platform_wayland.c | 32 >>> +--- >>> 1 file changed, 29 insertions(+), 3 deletions(-) >>> >>> diff --git a/src/egl/drivers/dri2/platform_wayland.c >>> b/src/egl/drivers/dri2/platform_wayland.c >>> index c2438f7..b5a5b59 100644 >>> --- a/src/egl/drivers/dri2/platform_wayland.c >>> +++ b/src/egl/drivers/dri2/platform_wayland.c >>> @@ -653,6 +653,30 @@ create_wl_buffer(struct dri2_egl_surface *dri2_surf) >>>_buffer_listener, dri2_surf); >>> } >>> >>> +static EGLBoolean >>> +try_damage_buffer(struct dri2_egl_surface *dri2_surf, >>> + const EGLint *rects, >>> + EGLint n_rects) >>> +{ >>> +#ifdef WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION >>> + int i; >>> + >>> + if (wl_proxy_get_version((struct wl_proxy *) dri2_surf->wl_win->surface) >>> + < WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION) >>> + return EGL_FALSE; >>> + >>> + for (i = 0; i < n_rects; i++) { >>> + const int *rect = [i * 4]; >>> + >>> + wl_surface_damage_buffer(dri2_surf->wl_win->surface, >>> + rect[0], >>> + dri2_surf->base.Height - rect[1] - rect[3], >>> + rect[2], rect[3]); >>> + } >>> + return EGL_TRUE; >>> +#endif >> >> I'm slightly worried about keeping this compile time. For example if >> we compile against old wayland, and then run against a capable one... >> this code won't exist thus will never get executed. Thus leading to a >> handful of "wtf" moments. >> >> I would just ensure it's defined at the top. >> >> #ifndef WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION >> #define WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION foo >> #endif > > If your wayland headers don't have > WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION then compilation will fail > because wl_proxy_get_version() isn't present. > > wl_proxy_get_version() will be formally introduced in the same wayland > release (next Tuesday's 1.10 release) as wl_surface_damage_buffer(), so > I'm intentionally using that as a tricky way to avoid the check > entirely. Too tricky? > Slightly confusing/misleading, than anything else. > If you prefer I can work out some autoconfy stuff to determine if > wl_proxy_get_version() is available? > Personally I'd love to bump the wayland requirement... although we cannot do that yet. Can you please add a small comment * above the ifdef line. "wayland XX introduced wl_proxy_get_version() and CRAZY_LONG_MACRO_NAME" or anything that you feel will make it dead obvious. Thanks Emil ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] egl/wayland: Try to use wl_surface.damage_buffer for SwapBuffersWithDamage
On Thu, Feb 11, 2016 at 8:34 AM, Derek Foremanwrote: > Since commit d1314de293e9e4a63c35f094c3893aaaed8580b4 we ignore > damage passed to SwapBuffersWithDamage. > > Wayland 1.10 now has functionality that allows us to properly > process those damage rectangles, and a way to query if it's > available. > > Now we can use wl_surface.damage_buffer and interpret the incoming > damage as being in buffer co-ordinates. > > Signed-off-by: Derek Foreman > Reviewed-by: Jason Ekstrand > --- > src/egl/drivers/dri2/platform_wayland.c | 32 > +--- > 1 file changed, 29 insertions(+), 3 deletions(-) > > diff --git a/src/egl/drivers/dri2/platform_wayland.c > b/src/egl/drivers/dri2/platform_wayland.c > index c2438f7..b5a5b59 100644 > --- a/src/egl/drivers/dri2/platform_wayland.c > +++ b/src/egl/drivers/dri2/platform_wayland.c > @@ -653,6 +653,30 @@ create_wl_buffer(struct dri2_egl_surface *dri2_surf) >_buffer_listener, dri2_surf); > } > > +static EGLBoolean > +try_damage_buffer(struct dri2_egl_surface *dri2_surf, > + const EGLint *rects, > + EGLint n_rects) > +{ > +#ifdef WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION > + int i; > + > + if (wl_proxy_get_version((struct wl_proxy *) > dri2_surf->wl_win->surface) > + < WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION) > + return EGL_FALSE; > + > + for (i = 0; i < n_rects; i++) { > + const int *rect = [i * 4]; > + > + wl_surface_damage_buffer(dri2_surf->wl_win->surface, > + rect[0], > + dri2_surf->base.Height - rect[1] - rect[3], > + rect[2], rect[3]); > + } > + return EGL_TRUE; > +#endif > + return EGL_FALSE; > +} > /** > * Called via eglSwapBuffers(), drv->API.SwapBuffers(). > */ > @@ -703,10 +727,12 @@ dri2_wl_swap_buffers_with_damage(_EGLDriver *drv, > dri2_surf->dx = 0; > dri2_surf->dy = 0; > > - /* We deliberately ignore the damage region and post maximum damage, > due to > + /* If the compositor doesn't support damage_buffer, we deliberately > +* ignore the damage region and post maximum damage, due to > * https://bugs.freedesktop.org/78190 */ > - wl_surface_damage(dri2_surf->wl_win->surface, > - 0, 0, INT32_MAX, INT32_MAX); > + if (!n_rects || !try_damage_buffer(dri2_surf, rects, n_rects)) > + wl_surface_damage(dri2_surf->wl_win->surface, > +0, 0, INT32_MAX, INT32_MAX); > > if (dri2_dpy->is_different_gpu) { >_EGLContext *ctx = _eglGetCurrentContext(); > -- > 2.7.0 > > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/mesa-dev > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] egl/wayland: Try to use wl_surface.damage_buffer for SwapBuffersWithDamage
Since commit d1314de293e9e4a63c35f094c3893aaaed8580b4 we ignore damage passed to SwapBuffersWithDamage. Wayland 1.10 now has functionality that allows us to properly process those damage rectangles, and a way to query if it's available. Now we can use wl_surface.damage_buffer and interpret the incoming damage as being in buffer co-ordinates. Signed-off-by: Derek Foreman--- src/egl/drivers/dri2/platform_wayland.c | 32 +--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c index c2438f7..b5a5b59 100644 --- a/src/egl/drivers/dri2/platform_wayland.c +++ b/src/egl/drivers/dri2/platform_wayland.c @@ -653,6 +653,30 @@ create_wl_buffer(struct dri2_egl_surface *dri2_surf) _buffer_listener, dri2_surf); } +static EGLBoolean +try_damage_buffer(struct dri2_egl_surface *dri2_surf, + const EGLint *rects, + EGLint n_rects) +{ +#ifdef WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION + int i; + + if (wl_proxy_get_version((struct wl_proxy *) dri2_surf->wl_win->surface) + < WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION) + return EGL_FALSE; + + for (i = 0; i < n_rects; i++) { + const int *rect = [i * 4]; + + wl_surface_damage_buffer(dri2_surf->wl_win->surface, + rect[0], + dri2_surf->base.Height - rect[1] - rect[3], + rect[2], rect[3]); + } + return EGL_TRUE; +#endif + return EGL_FALSE; +} /** * Called via eglSwapBuffers(), drv->API.SwapBuffers(). */ @@ -703,10 +727,12 @@ dri2_wl_swap_buffers_with_damage(_EGLDriver *drv, dri2_surf->dx = 0; dri2_surf->dy = 0; - /* We deliberately ignore the damage region and post maximum damage, due to + /* If the compositor doesn't support damage_buffer, we deliberately +* ignore the damage region and post maximum damage, due to * https://bugs.freedesktop.org/78190 */ - wl_surface_damage(dri2_surf->wl_win->surface, - 0, 0, INT32_MAX, INT32_MAX); + if (!n_rects || !try_damage_buffer(dri2_surf, rects, n_rects)) + wl_surface_damage(dri2_surf->wl_win->surface, +0, 0, INT32_MAX, INT32_MAX); if (dri2_dpy->is_different_gpu) { _EGLContext *ctx = _eglGetCurrentContext(); -- 2.7.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev