[PATCH xserver 2/2] glamor: Always purge the FBO cache in BlockHandler

Alex Deucher alexdeucher at gmail.com
Fri Mar 3 15:30:42 UTC 2017


On Fri, Mar 3, 2017 at 3:46 AM, Michel Dänzer <michel at daenzer.net> wrote:
> From: Michel Dänzer <michel.daenzer at amd.com>
>
> Or if the cache watermark is reached, whichever comes earlier.
>
> This slightly simplifies the FBO cache management, and prevents it from
> potentially holding entries for a long time, while preserving the main
> benefit of the cache for bursts of drawing operations.
>
> Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>

Series is:
Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

> ---
>  glamor/glamor.c      |  6 ++----
>  glamor/glamor_fbo.c  | 24 ++++++++----------------
>  glamor/glamor_priv.h |  6 ------
>  3 files changed, 10 insertions(+), 26 deletions(-)
>
> diff --git a/glamor/glamor.c b/glamor/glamor.c
> index feae7a21f..1a0fc4318 100644
> --- a/glamor/glamor.c
> +++ b/glamor/glamor.c
> @@ -254,9 +254,7 @@ glamor_block_handler(ScreenPtr screen)
>      glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
>
>      glamor_make_current(glamor_priv);
> -    glamor_priv->tick++;
>      glFlush();
> -    glamor_fbo_expire(glamor_priv);
>  }
>
>  static void
> @@ -264,8 +262,8 @@ _glamor_block_handler(ScreenPtr screen, void *timeout)
>  {
>      glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
>
> -    glamor_make_current(glamor_priv);
> -    glFlush();
> +    glamor_block_handler(screen);
> +    glamor_fbo_expire(glamor_priv);
>
>      screen->BlockHandler = glamor_priv->saved_procs.block_handler;
>      screen->BlockHandler(screen, timeout);
> diff --git a/glamor/glamor_fbo.c b/glamor/glamor_fbo.c
> index a531f6052..c40de9bd1 100644
> --- a/glamor/glamor_fbo.c
> +++ b/glamor/glamor_fbo.c
> @@ -30,11 +30,6 @@
>
>  #include "glamor_priv.h"
>
> -#define GLAMOR_CACHE_EXPIRE_MAX 100
> -
> -#define GLAMOR_CACHE_DEFAULT    0
> -#define GLAMOR_CACHE_EXACT_SIZE 1
> -
>  //#define NO_FBO_CACHE 1
>  #define FBO_CACHE_THRESHOLD  (256*1024*1024)
>
> @@ -155,9 +150,13 @@ glamor_pixmap_fbo_cache_put(glamor_screen_private *glamor_priv,
>  #else
>      n_format = cache_format(fbo->format);
>
> -    if (fbo->fb == 0 || fbo->external || n_format == -1
> -        || glamor_priv->fbo_cache_watermark >= FBO_CACHE_THRESHOLD) {
> -        glamor_priv->tick += GLAMOR_CACHE_EXPIRE_MAX;
> +    if (fbo->fb == 0 || fbo->external || n_format == -1) {
> +        glamor_purge_fbo(glamor_priv, fbo);
> +        return;
> +    }
> +
> +    glamor_priv->fbo_cache_watermark += fbo->width * fbo->height;
> +    if (glamor_priv->fbo_cache_watermark >= FBO_CACHE_THRESHOLD) {
>          glamor_fbo_expire(glamor_priv);
>          glamor_purge_fbo(glamor_priv, fbo);
>          return;
> @@ -182,9 +181,7 @@ glamor_pixmap_fbo_cache_put(glamor_screen_private *glamor_priv,
>          glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_ALPHA);
>      }
>
> -    glamor_priv->fbo_cache_watermark += fbo->width * fbo->height;
>      xorg_list_add(&fbo->list, cache);
> -    fbo->expire = glamor_priv->tick + GLAMOR_CACHE_EXPIRE_MAX;
>  #endif
>  }
>
> @@ -281,12 +278,6 @@ glamor_fbo_expire(glamor_screen_private *glamor_priv)
>                  cache = &glamor_priv->fbo_cache[i][j][k];
>                  xorg_list_for_each_entry_safe_reverse(fbo_entry, tmp, cache,
>                                                        list) {
> -                    if (GLAMOR_TICK_AFTER(fbo_entry->expire, glamor_priv->tick)) {
> -                        break;
> -                    }
> -
> -                    glamor_priv->fbo_cache_watermark -=
> -                        fbo_entry->width * fbo_entry->height;
>                      xorg_list_del(&fbo_entry->list);
>                      DEBUGF("cache %p fbo %p expired %d current %d \n", cache,
>                             fbo_entry, fbo_entry->expire, glamor_priv->tick);
> @@ -294,6 +285,7 @@ glamor_fbo_expire(glamor_screen_private *glamor_priv)
>                  }
>              }
>
> +    glamor_priv->fbo_cache_watermark = 0;
>  }
>
>  void
> diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
> index a9377ace1..ad7afec7e 100644
> --- a/glamor/glamor_priv.h
> +++ b/glamor/glamor_priv.h
> @@ -189,11 +189,7 @@ struct glamor_saved_procs {
>  #define CACHE_BUCKET_WCOUNT 4
>  #define CACHE_BUCKET_HCOUNT 4
>
> -#define GLAMOR_TICK_AFTER(t0, t1)      \
> -       (((int)(t1) - (int)(t0)) < 0)
> -
>  typedef struct glamor_screen_private {
> -    unsigned int tick;
>      enum glamor_gl_flavor gl_flavor;
>      int glsl_version;
>      Bool has_pack_invert;
> @@ -328,8 +324,6 @@ enum glamor_fbo_state {
>
>  typedef struct glamor_pixmap_fbo {
>      struct xorg_list list; /**< linked list pointers when in the fbo cache */
> -    /** glamor_priv->tick number when this FBO will be expired from the cache. */
> -    unsigned int expire;
>      GLuint tex; /**< GL texture name */
>      GLuint fb; /**< GL FBO name */
>      int width; /**< width in pixels */
> --
> 2.11.0
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: https://lists.x.org/mailman/listinfo/xorg-devel


More information about the xorg-devel mailing list