Mesa (pipe-format-simplify): Simplify the redundant meaning of format layout.

Michał Król michal at kemper.freedesktop.org
Tue Dec 8 11:49:03 PST 2009


Module: Mesa
Branch: pipe-format-simplify
Commit: eb926ddf9eee1095c7fc12013f0b8375bbaeca6f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=eb926ddf9eee1095c7fc12013f0b8375bbaeca6f

Author: Michal Krol <michal at vmware.com>
Date:   Tue Dec  8 20:48:47 2009 +0100

Simplify the redundant meaning of format layout.

We really just need to know whether the format is compressed or not.
For more detailed information format colorspace should suffice.

---

 src/gallium/auxiliary/util/u_format.h         |    7 ++-----
 src/gallium/auxiliary/util/u_format_table.py  |   10 +++++++---
 src/gallium/drivers/llvmpipe/lp_screen.c      |    8 ++------
 src/gallium/drivers/r300/r300_state_inlines.h |    6 ++----
 src/mesa/state_tracker/st_format.c            |    5 ++---
 5 files changed, 15 insertions(+), 21 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h
index 25a06a8..bb7c2ad 100644
--- a/src/gallium/auxiliary/util/u_format.h
+++ b/src/gallium/auxiliary/util/u_format.h
@@ -34,11 +34,8 @@
 
 
 enum util_format_layout {
-   UTIL_FORMAT_LAYOUT_SCALAR = 0,
-   UTIL_FORMAT_LAYOUT_ARITH = 1,
-   UTIL_FORMAT_LAYOUT_ARRAY = 2,
-   UTIL_FORMAT_LAYOUT_YUV = 3,
-   UTIL_FORMAT_LAYOUT_DXT = 4
+   UTIL_FORMAT_LAYOUT_PLAIN = 0, /*< RGB, depth-stencil */
+   UTIL_FORMAT_LAYOUT_DXT = 1
 };
 
 
diff --git a/src/gallium/auxiliary/util/u_format_table.py b/src/gallium/auxiliary/util/u_format_table.py
index 8713594..c772a75 100755
--- a/src/gallium/auxiliary/util/u_format_table.py
+++ b/src/gallium/auxiliary/util/u_format_table.py
@@ -35,8 +35,12 @@ import sys
 from u_format_parse import *
 
 
-def layout_map(layout):
-    return 'UTIL_FORMAT_LAYOUT_' + str(layout).upper()
+layout_map = {
+    'arith': 'UTIL_FORMAT_LAYOUT_PLAIN',
+    'array': 'UTIL_FORMAT_LAYOUT_PLAIN',
+    'yuv':   'UTIL_FORMAT_LAYOUT_PLAIN',
+    'dxt':   'UTIL_FORMAT_LAYOUT_DXT',
+}
 
 
 def colorspace_map(colorspace):
@@ -104,7 +108,7 @@ def write_format_table(formats):
         print "      %s," % (format.name,)
         print "      \"%s\"," % (format.name,)
         print "      {%u, %u, %u}, /* block */" % (format.block_width, format.block_height, format.block_size())
-        print "      %s," % (layout_map(format.layout),)
+        print "      %s," % (layout_map[format.layout],)
         print "      {"
         for i in range(4):
             type = format.in_types[i]
diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c
index a6ecaa0..3641e1d 100644
--- a/src/gallium/drivers/llvmpipe/lp_screen.c
+++ b/src/gallium/drivers/llvmpipe/lp_screen.c
@@ -158,9 +158,7 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen,
          format_desc->block.height != 1)
          return FALSE;
 
-      if(format_desc->layout != UTIL_FORMAT_LAYOUT_SCALAR &&
-         format_desc->layout != UTIL_FORMAT_LAYOUT_ARITH &&
-         format_desc->layout != UTIL_FORMAT_LAYOUT_ARRAY)
+      if(format_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN)
          return FALSE;
 
       if(format_desc->colorspace != UTIL_FORMAT_COLORSPACE_RGB &&
@@ -188,9 +186,7 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen,
          format_desc->block.height != 1)
          return FALSE;
 
-      if(format_desc->layout != UTIL_FORMAT_LAYOUT_SCALAR &&
-         format_desc->layout != UTIL_FORMAT_LAYOUT_ARITH &&
-         format_desc->layout != UTIL_FORMAT_LAYOUT_ARRAY)
+      if(format_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN)
          return FALSE;
 
       if(format_desc->colorspace != UTIL_FORMAT_COLORSPACE_RGB &&
diff --git a/src/gallium/drivers/r300/r300_state_inlines.h b/src/gallium/drivers/r300/r300_state_inlines.h
index 7cd1f87..c71305e 100644
--- a/src/gallium/drivers/r300/r300_state_inlines.h
+++ b/src/gallium/drivers/r300/r300_state_inlines.h
@@ -476,8 +476,7 @@ r300_translate_vertex_data_type(enum pipe_format format) {
 
     desc = util_format_description(format);
 
-    if (desc->layout != UTIL_FORMAT_LAYOUT_ARITH &&
-        desc->layout != UTIL_FORMAT_LAYOUT_ARRAY) {
+    if (desc->layout != UTIL_FORMAT_LAYOUT_PLAIN) {
         debug_printf("r300: Bad format %s in %s:%d\n", pf_name(format),
             __FUNCTION__, __LINE__);
         assert(0);
@@ -541,8 +540,7 @@ r300_translate_vertex_data_swizzle(enum pipe_format format) {
 
     assert(format);
 
-    if (desc->layout != UTIL_FORMAT_LAYOUT_ARITH &&
-        desc->layout != UTIL_FORMAT_LAYOUT_ARRAY) {
+    if (desc->layout != UTIL_FORMAT_LAYOUT_PLAIN) {
         debug_printf("r300: Bad format %s in %s:%d\n",
             pf_name(format), __FUNCTION__, __LINE__);
         return 0;
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index 329ae03..2056dce 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -83,8 +83,7 @@ st_get_format_info(enum pipe_format format, struct pipe_format_info *pinfo)
    desc = util_format_description(format);
    assert(desc);
 
-   if (desc->layout == UTIL_FORMAT_LAYOUT_ARITH ||
-       desc->layout == UTIL_FORMAT_LAYOUT_ARRAY) {
+   if (desc->layout == UTIL_FORMAT_LAYOUT_PLAIN) {
 #if 0
       printf("%s\n", pf_name( format ) );
 #endif
@@ -147,7 +146,7 @@ st_get_format_info(enum pipe_format format, struct pipe_format_info *pinfo)
 
       pinfo->mesa_format = st_pipe_format_to_mesa_format(format);
    }
-   else if (desc->layout == UTIL_FORMAT_LAYOUT_YUV) {
+   else if (desc->colorspace == UTIL_FORMAT_COLORSPACE_YUV) {
       pinfo->mesa_format = MESA_FORMAT_YCBCR;
       pinfo->datatype = GL_UNSIGNED_SHORT;
       pinfo->size = 2; /* two bytes per "texel" */



More information about the mesa-commit mailing list