[Mesa-dev] 2 util_format patches

Brian Paul brianp at vmware.com
Mon May 3 10:42:32 PDT 2010


Marek Olšák wrote:
> José,
> 
> the first patch removes the PIPE_FORMAT_ prefix in a string returned by 
> util_format_name, it makes debug logs shorter. The second patch adds 
> util_format_is_plain.

I'd prefer to keep the long format names.

I was recently burned by the Gallium docs omitting the prefixes on a 
set of enums which I was grepping for.

With the full names it's easier to grep for format names and to 
copy&paste for debugging.


util_format_is_plain() is fine, but please put a comment on it to 
describe what "plain" means to the newbie.

-Brian


> 
> diff --git a/src/gallium/auxiliary/util/u_format.h 
> b/src/gallium/auxiliary/util/u_format.h
> index fb6ade5..d851c31 100644
> --- a/src/gallium/auxiliary/util/u_format.h
> +++ b/src/gallium/auxiliary/util/u_format.h
> @@ -332,10 +332,10 @@ util_format_name(enum pipe_format format)
>  
>     assert(desc);
>     if (!desc) {
> -      return "PIPE_FORMAT_???";
> +      return "???";
>     }
>  
> -   return desc->name;
> +   return desc->name+12;
>  }
>  
>  static INLINE boolean
> 
> diff --git a/src/gallium/auxiliary/util/u_format.h 
> b/src/gallium/auxiliary/util/u_format.h
> index d851c31..350b817 100644
> --- a/src/gallium/auxiliary/util/u_format.h
> +++ b/src/gallium/auxiliary/util/u_format.h
> @@ -338,6 +338,18 @@ util_format_name(enum pipe_format format)
>     return desc->name+12;
>  }
>  
> +static INLINE boolean
> +util_format_is_plain(enum pipe_format format)
> +{
> +   const struct util_format_description *desc = 
> util_format_description(format);
> +
> +   if (!format) {
> +      return FALSE;
> +   }
> +
> +   return desc->layout == UTIL_FORMAT_LAYOUT_PLAIN ? TRUE : FALSE;
> +}
> +
>  static INLINE boolean
>  util_format_is_s3tc(enum pipe_format format)
>  {
> 
> May I push them?
> 
> -Marek
> 



More information about the mesa-dev mailing list