[Mesa-dev] 2 util_format patches

2010-05-03 Thread Marek Olšák
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.

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
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] 2 util_format patches

2010-05-03 Thread José Fonseca
On Mon, 2010-05-03 at 10:25 -0700, 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.
 
 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;
  }

Just return desc-short_name. It's lower case so it's easier to read.

Also  please modify src/gallium/drivers/trace/tr_dump_state.c to use the
full caps name, as retrace relies on it.

  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;
 +}
 +

This is fine.

I have no problem with adding more such functions here, but for the
record, a better practice would be to call util_format_description once
and then do necessary operations with it. And typically there are
several. That is I'd rather see all inline functions in u_format.h
taking as argument the struct util_format_description *desc, expect
util_format_description().

  static INLINE boolean 
  util_format_is_s3tc(enum pipe_format format)
  {
 
 May I push them?

Jose


___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] 2 util_format patches

2010-05-03 Thread José Fonseca
On Mon, 2010-05-03 at 10:42 -0700, Brian Paul wrote:
 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 
 copypaste for debugging.

Fair enough. I really don't have a preference here.

Marek, if you really want to use short names in the drivers you maintain
then I'd suggest using the desc-short_name there (add a new
util_format_short_name()), but lets keep the long names elsewhere.

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

Yeah, I'm terrible with names. There's a description of what plain
format means in UTIL_FORMAT_LAYOUT_PLAIN's comment.

Jose
 
  
  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
  
 


___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev