[Mesa-dev] [RFC mesa 1/3] egl: deduplicate swap interval clamping logic

Daniel Stone daniel at fooishbar.org
Mon Jul 31 17:07:41 UTC 2017


Hi Eric,

On 31 July 2017 at 18:04, Eric Engestrom <eric.engestrom at imgtec.com> wrote:
> @@ -956,16 +956,9 @@ dri2_x11_swap_interval(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf,
>     struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
>     struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
>
> -   if (interval > surf->Config->MaxSwapInterval)
> -      interval = surf->Config->MaxSwapInterval;
> -   else if (interval < surf->Config->MinSwapInterval)
> -      interval = surf->Config->MinSwapInterval;
> -
> -   if (interval != surf->SwapInterval && dri2_dpy->swap_available)
> +   if (dri2_dpy->swap_available)
>        xcb_dri2_swap_interval(dri2_dpy->conn, dri2_surf->drawable, interval);
>
> -   surf->SwapInterval = interval;
> -
>     return EGL_TRUE;
>  }
>
> diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
> index 000368a46a..9ebc3670b4 100644
> --- a/src/egl/main/eglapi.c
> +++ b/src/egl/main/eglapi.c
> @@ -1201,6 +1201,12 @@ eglSwapInterval(EGLDisplay dpy, EGLint interval)
>     if (_eglGetSurfaceHandle(surf) == EGL_NO_SURFACE)
>        RETURN_EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE);
>
> +   interval = CLAMP(interval,
> +                    surf->Config->MinSwapInterval,
> +                    surf->Config->MaxSwapInterval);
> +
> +   surf->SwapInterval = interval;
> +
>     ret = drv->API.SwapInterval(drv, disp, surf, interval);

Should probably do what the X11 code did and only call into
drv->API.SwapInterval() if the interval actually changed. That aside,
for the series:
Reviewed-by: Daniel Stone <daniels at collabora.com>

Cheers,
Daniel


More information about the mesa-dev mailing list