[PATCH 16/27] glamor: Replace some goofy enum-likes with a real enum.

Markus Wick markus at selfnet.de
Wed Mar 12 12:26:58 PDT 2014


Am 2014-03-11 22:30, schrieb Eric Anholt:
> This unpacks the bitfield into an int size, but my experience has been
> that packing bitfields doesn't matter for performance.
> 
> Signed-off-by: Eric Anholt <eric at anholt.net>
> ---
>  glamor/glamor_fbo.c  |  2 +-
>  glamor/glamor_priv.h | 25 ++++++++++++++++---------
>  2 files changed, 17 insertions(+), 10 deletions(-)
> 
> diff --git a/glamor/glamor_fbo.c b/glamor/glamor_fbo.c
> index 281cf83..640b6fd 100644
> --- a/glamor/glamor_fbo.c
> +++ b/glamor/glamor_fbo.c
> @@ -505,7 +505,7 @@ glamor_pixmap_attach_fbo(PixmapPtr pixmap,
> glamor_pixmap_fbo *fbo)
>      case GLAMOR_TEXTURE_LARGE:
>      case GLAMOR_TEXTURE_ONLY:
>      case GLAMOR_TEXTURE_DRM:
> -        pixmap_priv->base.gl_fbo = 1;
> +        pixmap_priv->base.gl_fbo = GLAMOR_FBO_NORMAL;
>          if (fbo->tex != 0)
>              pixmap_priv->base.gl_tex = 1;
>          else {
> diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
> index 4dc2c75..52dad35 100644
> --- a/glamor/glamor_priv.h
> +++ b/glamor/glamor_priv.h
> @@ -291,8 +291,21 @@ typedef enum glamor_access {
>      GLAMOR_ACCESS_WO,
>  } glamor_access_t;
> 
> -#define GLAMOR_FBO_NORMAL     1
> -#define GLAMOR_FBO_DOWNLOADED 2
> +enum glamor_fbo_state {
> +    /** There is no storage attached to the pixmap. */
> +    GLAMOR_FBO_UNATTACHED,
> +    /**
> +     * The pixmap has FBO storage attached, but devPrivate.ptr doesn't
> +     * point at anything.
> +     */
> +    GLAMOR_FBO_NORMAL,
> +    /**
> +     * The FBO is present and can be accessed as a linear memory
> +     * mapping through devPrivate.ptr.
> +     */
> +    GLAMOR_FBO_DOWNLOADED,
> +};
> +
>  /* glamor_pixmap_fbo:
>   * @list:    to be used to link to the cache pool list.
>   * @expire:  when push to cache pool list, set a expire count.
> @@ -324,12 +337,6 @@ typedef struct glamor_pixmap_fbo {
> 
>  /*
>   * glamor_pixmap_private - glamor pixmap's private structure.
> - * @gl_fbo:
> - * 	0 		  	- The pixmap doesn't has a fbo attached to it.
> - * 	GLAMOR_FBO_NORMAL 	- The pixmap has a fbo and can be accessed 
> normally.
> - * 	GLAMOR_FBO_DOWNLOADED 	- The pixmap has a fbo and already 
> downloaded to
> - * 				  CPU, so it can only be treated as a in-memory pixmap
> - * 				  if this bit is set.
>   * @gl_tex:  The pixmap is in a gl texture originally.
>   * @is_picture: The drawable is attached to a picture.
>   * @pict_format: the corresponding picture's format.
> @@ -403,7 +410,7 @@ typedef struct glamor_pixmap_clipped_regions {
> 
>  typedef struct glamor_pixmap_private_base {
>      glamor_pixmap_type_t type;
> -    unsigned char gl_fbo:2;
> +    enum glamor_fbo_state gl_fbo;
>      unsigned char is_picture:1;
>      unsigned char gl_tex:1;
>      glamor_pixmap_fbo *fbo;

base.gl_fbo seems often to be compared vs 0 instead of 
GLAMOR_FBO_UNATTACHED.

To be honest, I'm a bit confused about this flag. Is this really about 
fbo or more likely about general textures?


More information about the xorg-devel mailing list