From 7fc75ef7d43038385b5fba73a67f1e4783b045d6 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 3 Dec 2009 18:18:46 +0000 Subject: util: Fix generated swizzle comments. --- src/gallium/auxiliary/util/u_format_table.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/gallium/auxiliary/util/u_format_table.py') diff --git a/src/gallium/auxiliary/util/u_format_table.py b/src/gallium/auxiliary/util/u_format_table.py index 8834568e8e..2cd0f95678 100755 --- a/src/gallium/auxiliary/util/u_format_table.py +++ b/src/gallium/auxiliary/util/u_format_table.py @@ -44,11 +44,10 @@ def colorspace_map(colorspace): colorspace_channels_map = { - 'rgb': 'rgba', - 'rgba': 'rgba', - 'zs': 'zs', - 'yuv': ['y1', 'y2', 'u', 'v'], - 'dxt': [] + 'rgb': ['r', 'g', 'b', 'a'], + 'srgb': ['sr', 'sg', 'sb', 'a'], + 'zs': ['z', 's'], + 'yuv': ['y', 'u', 'v'], } @@ -94,7 +93,7 @@ def write_format_table(formats): print " {" print " %s," % (format.name,) print " \"%s\"," % (format.name,) - print " {%u, %u, %u}, /* block */" % (format.block_width, format.block_height, format.block_size()) + print " {%u, %u, %u},\t/* block */" % (format.block_width, format.block_height, format.block_size()) print " %s," % (layout_map(format.layout),) print " {" for i in range(4): @@ -103,7 +102,7 @@ def write_format_table(formats): sep = "," else: sep = "" - print " {%s, %s, %u}%s /* %s */" % (kind_map[type.kind], bool_map(type.norm), type.size, sep, "xyzw"[i]) + print " {%s, %s, %u}%s\t/* %s */" % (kind_map[type.kind], bool_map(type.norm), type.size, sep, "xyzw"[i]) print " }," print " {" for i in range(4): @@ -113,10 +112,10 @@ def write_format_table(formats): else: sep = "" try: - comment = layout_channels_map[format.layout][i] - except: + comment = colorspace_channels_map[format.colorspace][i] + except (KeyError, IndexError): comment = 'ignored' - print " %s%s /* %s */" % (swizzle_map[swizzle], sep, comment) + print " %s%s\t/* %s */" % (swizzle_map[swizzle], sep, comment) print " }," print " %s," % (colorspace_map(format.colorspace),) print " }," -- cgit v1.2.3 From ddbd2d08b7c5b5653981db8fec58d5c3244049cd Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Tue, 8 Dec 2009 15:46:15 +0100 Subject: util/format: Take advantage of sequential nature of pipe_format enum. Make sure the format descriptor table can be indexed directly. --- src/gallium/auxiliary/util/u_format.c | 15 +++++++-------- src/gallium/auxiliary/util/u_format.csv | 8 ++++---- src/gallium/auxiliary/util/u_format_table.py | 18 +++++++++--------- 3 files changed, 20 insertions(+), 21 deletions(-) (limited to 'src/gallium/auxiliary/util/u_format_table.py') diff --git a/src/gallium/auxiliary/util/u_format.c b/src/gallium/auxiliary/util/u_format.c index 98ea13b60b..e0724a1a8b 100644 --- a/src/gallium/auxiliary/util/u_format.c +++ b/src/gallium/auxiliary/util/u_format.c @@ -32,15 +32,14 @@ const struct util_format_description * util_format_description(enum pipe_format format) { - const struct util_format_description *desc = util_format_description_table; + const struct util_format_description *desc; - while(TRUE) { - if(desc->format == format) - return desc; + if (format >= PIPE_FORMAT_COUNT) { + return NULL; + } - if(desc->format == PIPE_FORMAT_NONE) - return NULL; + desc = &util_format_description_table[format]; + assert(desc->format == format); - ++desc; - }; + return desc; } diff --git a/src/gallium/auxiliary/util/u_format.csv b/src/gallium/auxiliary/util/u_format.csv index b9cc2aa716..866b18ff16 100644 --- a/src/gallium/auxiliary/util/u_format.csv +++ b/src/gallium/auxiliary/util/u_format.csv @@ -11,6 +11,8 @@ PIPE_FORMAT_A8_UNORM , arith , 1, 1, un8 , , , , 000x, PIPE_FORMAT_I8_UNORM , arith , 1, 1, un8 , , , , xxxx, rgb PIPE_FORMAT_A8L8_UNORM , arith , 1, 1, un8 , un8 , , , xxxy, rgb PIPE_FORMAT_L16_UNORM , arith , 1, 1, un16, , , , xxx1, rgb +PIPE_FORMAT_YCBCR , yuv , 2, 1, x32 , , , , xyz1, yuv +PIPE_FORMAT_YCBCR_REV , yuv , 2, 1, x32 , , , , xyz1, yuv PIPE_FORMAT_Z16_UNORM , array , 1, 1, un16, , , , x___, zs PIPE_FORMAT_Z32_UNORM , array , 1, 1, un32, , , , x___, zs PIPE_FORMAT_Z32_FLOAT , array , 1, 1, f32 , , , , x___, zs @@ -97,13 +99,11 @@ PIPE_FORMAT_B8G8R8A8_SRGB , arith , 1, 1, u8 , u8 , u8 , u8 , zyxw, PIPE_FORMAT_B8G8R8X8_SRGB , arith , 1, 1, u8 , u8 , u8 , u8 , zyx1, srgb PIPE_FORMAT_X8UB8UG8SR8S_NORM , arith , 1, 1, sn8 , sn8 , un8 , x8 , 1zyx, rgb PIPE_FORMAT_B6UG5SR5S_NORM , arith , 1, 1, sn5 , sn5 , un6 , , xyz1, rgb -PIPE_FORMAT_YCBCR , yuv , 2, 1, x32 , , , , xyz1, yuv -PIPE_FORMAT_YCBCR_REV , yuv , 2, 1, x32 , , , , xyz1, yuv -PIPE_FORMAT_DXT1_RGBA , dxt , 4, 4, x64 , , , , xyzw, rgb PIPE_FORMAT_DXT1_RGB , dxt , 4, 4, x64 , , , , xyz1, rgb +PIPE_FORMAT_DXT1_RGBA , dxt , 4, 4, x64 , , , , xyzw, rgb PIPE_FORMAT_DXT3_RGBA , dxt , 4, 4, x128, , , , xyzw, rgb PIPE_FORMAT_DXT5_RGBA , dxt , 4, 4, x128, , , , xyzw, rgb -PIPE_FORMAT_DXT1_SRGBA , dxt , 4, 4, x64 , , , , xyzw, srgb PIPE_FORMAT_DXT1_SRGB , dxt , 4, 4, x64 , , , , xyz1, srgb +PIPE_FORMAT_DXT1_SRGBA , dxt , 4, 4, x64 , , , , xyzw, srgb PIPE_FORMAT_DXT3_SRGBA , dxt , 4, 4, x128, , , , xyzw, srgb PIPE_FORMAT_DXT5_SRGBA , dxt , 4, 4, x128, , , , xyzw, srgb diff --git a/src/gallium/auxiliary/util/u_format_table.py b/src/gallium/auxiliary/util/u_format_table.py index 8834568e8e..8713594376 100755 --- a/src/gallium/auxiliary/util/u_format_table.py +++ b/src/gallium/auxiliary/util/u_format_table.py @@ -90,6 +90,15 @@ def write_format_table(formats): print 'const struct util_format_description' print 'util_format_description_table[] = ' print "{" + print " {" + print " PIPE_FORMAT_NONE," + print " \"PIPE_FORMAT_NONE\"," + print " {0, 0, 0}," + print " 0," + print " {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}," + print " {0, 0, 0, 0}," + print " 0" + print " }," for format in formats: print " {" print " %s," % (format.name,) @@ -120,15 +129,6 @@ def write_format_table(formats): print " }," print " %s," % (colorspace_map(format.colorspace),) print " }," - print " {" - print " PIPE_FORMAT_NONE," - print " \"PIPE_FORMAT_NONE\"," - print " {0, 0, 0}," - print " 0," - print " {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}," - print " {0, 0, 0, 0}," - print " 0" - print " }," print "};" -- cgit v1.2.3 From eb926ddf9eee1095c7fc12013f0b8375bbaeca6f Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Tue, 8 Dec 2009 20:48:47 +0100 Subject: 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(-) (limited to 'src/gallium/auxiliary/util/u_format_table.py') diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h index 25a06a8f7d..bb7c2add5c 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 8713594376..c772a75e61 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 a6ecaa0b2b..3641e1dccb 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 7cd1f87630..c71305edc2 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 329ae03db2..2056dce7fb 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" */ -- cgit v1.2.3 From dfdf83d714c0d32d9182eb3001cf642aa6cb5c87 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Wed, 9 Dec 2009 14:22:30 +0100 Subject: Revert "Simplify the redundant meaning of format layout." This reverts commit eb926ddf9eee1095c7fc12013f0b8375bbaeca6f. --- 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, 21 insertions(+), 15 deletions(-) (limited to 'src/gallium/auxiliary/util/u_format_table.py') diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h index bb7c2add5c..25a06a8f7d 100644 --- a/src/gallium/auxiliary/util/u_format.h +++ b/src/gallium/auxiliary/util/u_format.h @@ -34,8 +34,11 @@ enum util_format_layout { - UTIL_FORMAT_LAYOUT_PLAIN = 0, /*< RGB, depth-stencil */ - UTIL_FORMAT_LAYOUT_DXT = 1 + 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 }; diff --git a/src/gallium/auxiliary/util/u_format_table.py b/src/gallium/auxiliary/util/u_format_table.py index c772a75e61..8713594376 100755 --- a/src/gallium/auxiliary/util/u_format_table.py +++ b/src/gallium/auxiliary/util/u_format_table.py @@ -35,12 +35,8 @@ import sys from u_format_parse import * -layout_map = { - 'arith': 'UTIL_FORMAT_LAYOUT_PLAIN', - 'array': 'UTIL_FORMAT_LAYOUT_PLAIN', - 'yuv': 'UTIL_FORMAT_LAYOUT_PLAIN', - 'dxt': 'UTIL_FORMAT_LAYOUT_DXT', -} +def layout_map(layout): + return 'UTIL_FORMAT_LAYOUT_' + str(layout).upper() def colorspace_map(colorspace): @@ -108,7 +104,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 3641e1dccb..a6ecaa0b2b 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -158,7 +158,9 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen, format_desc->block.height != 1) return FALSE; - if(format_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN) + if(format_desc->layout != UTIL_FORMAT_LAYOUT_SCALAR && + format_desc->layout != UTIL_FORMAT_LAYOUT_ARITH && + format_desc->layout != UTIL_FORMAT_LAYOUT_ARRAY) return FALSE; if(format_desc->colorspace != UTIL_FORMAT_COLORSPACE_RGB && @@ -186,7 +188,9 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen, format_desc->block.height != 1) return FALSE; - if(format_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN) + if(format_desc->layout != UTIL_FORMAT_LAYOUT_SCALAR && + format_desc->layout != UTIL_FORMAT_LAYOUT_ARITH && + format_desc->layout != UTIL_FORMAT_LAYOUT_ARRAY) 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 c71305edc2..7cd1f87630 100644 --- a/src/gallium/drivers/r300/r300_state_inlines.h +++ b/src/gallium/drivers/r300/r300_state_inlines.h @@ -476,7 +476,8 @@ r300_translate_vertex_data_type(enum pipe_format format) { desc = util_format_description(format); - if (desc->layout != UTIL_FORMAT_LAYOUT_PLAIN) { + if (desc->layout != UTIL_FORMAT_LAYOUT_ARITH && + desc->layout != UTIL_FORMAT_LAYOUT_ARRAY) { debug_printf("r300: Bad format %s in %s:%d\n", pf_name(format), __FUNCTION__, __LINE__); assert(0); @@ -540,7 +541,8 @@ r300_translate_vertex_data_swizzle(enum pipe_format format) { assert(format); - if (desc->layout != UTIL_FORMAT_LAYOUT_PLAIN) { + if (desc->layout != UTIL_FORMAT_LAYOUT_ARITH && + desc->layout != UTIL_FORMAT_LAYOUT_ARRAY) { 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 2056dce7fb..329ae03db2 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -83,7 +83,8 @@ 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_PLAIN) { + if (desc->layout == UTIL_FORMAT_LAYOUT_ARITH || + desc->layout == UTIL_FORMAT_LAYOUT_ARRAY) { #if 0 printf("%s\n", pf_name( format ) ); #endif @@ -146,7 +147,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->colorspace == UTIL_FORMAT_COLORSPACE_YUV) { + else if (desc->layout == UTIL_FORMAT_LAYOUT_YUV) { pinfo->mesa_format = MESA_FORMAT_YCBCR; pinfo->datatype = GL_UNSIGNED_SHORT; pinfo->size = 2; /* two bytes per "texel" */ -- cgit v1.2.3