From 4e9690f00ca67e42e31367c50f9c216ad10ef553 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Tue, 30 Mar 2010 01:33:28 +0200 Subject: gallium: make the python scripts for format parsing not fail on new formats they won't generate any useful conversion code for some of the new formats but at least don't assert. Also needed some more hacks so they don't generate code for some of the new formats, as gcc was not impressed. Also declare unused channels as void, and change the scripts to not fail if the first channel happened to be unused. Needs serious fixing. --- src/gallium/auxiliary/util/u_format.csv | 20 ++++++++++---------- src/gallium/auxiliary/util/u_format_access.py | 5 +++++ src/gallium/auxiliary/util/u_format_pack.py | 14 ++++++++++++-- src/gallium/auxiliary/util/u_format_parse.py | 2 ++ 4 files changed, 29 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/util/u_format.csv b/src/gallium/auxiliary/util/u_format.csv index 2b2230f3089..f55bc3d805b 100644 --- a/src/gallium/auxiliary/util/u_format.csv +++ b/src/gallium/auxiliary/util/u_format.csv @@ -58,12 +58,12 @@ # Typical rendertarget formats PIPE_FORMAT_B8G8R8A8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , zyxw, rgb -PIPE_FORMAT_B8G8R8X8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , zyx1, rgb +PIPE_FORMAT_B8G8R8X8_UNORM , plain, 1, 1, un8 , un8 , un8 , x8 , zyx1, rgb PIPE_FORMAT_A8R8G8B8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , yzwx, rgb -PIPE_FORMAT_X8R8G8B8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , yzw1, rgb +PIPE_FORMAT_X8R8G8B8_UNORM , plain, 1, 1, x8 , un8 , un8 , un8 , yzw1, rgb PIPE_FORMAT_A8B8G8R8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , wzyx, rgb -PIPE_FORMAT_X8B8G8R8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , wzy1, rgb -PIPE_FORMAT_B5G5R5X1_UNORM , plain, 1, 1, un5 , un5 , un5 , un1 , zyx1, rgb +PIPE_FORMAT_X8B8G8R8_UNORM , plain, 1, 1, x8 , un8 , un8 , un8 , wzy1, rgb +PIPE_FORMAT_B5G5R5X1_UNORM , plain, 1, 1, un5 , un5 , un5 , x1 , zyx1, rgb PIPE_FORMAT_B5G5R5A1_UNORM , plain, 1, 1, un5 , un5 , un5 , un1 , zyxw, rgb PIPE_FORMAT_B4G4R4A4_UNORM , plain, 1, 1, un4 , un4 , un4 , un4 , zyxw, rgb PIPE_FORMAT_B5G6R5_UNORM , plain, 1, 1, un5 , un6 , un5 , , zyx1, rgb @@ -82,11 +82,11 @@ PIPE_FORMAT_L8A8_SRGB , plain, 1, 1, un8 , un8 , , , xxxy, s PIPE_FORMAT_R8G8B8_SRGB , plain, 1, 1, un8 , un8 , un8 , , xyz1, srgb PIPE_FORMAT_R8G8B8A8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , xyzw, srgb PIPE_FORMAT_A8B8G8R8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , wzyx, srgb -PIPE_FORMAT_X8B8G8R8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , wzy1, srgb +PIPE_FORMAT_X8B8G8R8_SRGB , plain, 1, 1, x8 , un8 , un8 , un8 , wzy1, srgb PIPE_FORMAT_B8G8R8A8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , zyxw, srgb -PIPE_FORMAT_B8G8R8X8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , zyx1, srgb +PIPE_FORMAT_B8G8R8X8_SRGB , plain, 1, 1, un8 , un8 , un8 , x8 , zyx1, srgb PIPE_FORMAT_A8R8G8B8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , yzwx, srgb -PIPE_FORMAT_X8R8G8B8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , yzw1, srgb +PIPE_FORMAT_X8R8G8B8_SRGB , plain, 1, 1, x8 , un8 , un8 , un8 , yzw1, srgb # Mixed-sign formats (typically used for bump map textures) PIPE_FORMAT_R8SG8SB8UX8U_NORM , plain, 1, 1, sn8 , sn8 , un8 , x8 , xyz1, rgb @@ -99,9 +99,9 @@ PIPE_FORMAT_Z32_UNORM , plain, 1, 1, un32, , , , x___, PIPE_FORMAT_Z32_FLOAT , plain, 1, 1, f32 , , , , x___, zs PIPE_FORMAT_Z24_UNORM_S8_USCALED , plain, 1, 1, un24, u8 , , , xy__, zs PIPE_FORMAT_S8_USCALED_Z24_UNORM , plain, 1, 1, u8 , un24, , , yx__, zs -PIPE_FORMAT_Z24X8_UNORM , plain, 1, 1, un24, u8 , , , x___, zs -PIPE_FORMAT_X8Z24_UNORM , plain, 1, 1, u8 , un24, , , y___, zs -PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED , plain, 1, 1, f32, u8 , u24 , , xy__, zs +PIPE_FORMAT_Z24X8_UNORM , plain, 1, 1, un24, x8 , , , x___, zs +PIPE_FORMAT_X8Z24_UNORM , plain, 1, 1, x8 , un24, , , y___, zs +PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED , plain, 1, 1, f32, u8 , x24 , , xy__, zs # YUV formats # http://www.fourcc.org/yuv.php#UYVY diff --git a/src/gallium/auxiliary/util/u_format_access.py b/src/gallium/auxiliary/util/u_format_access.py index 00424779d28..42a37badca7 100644 --- a/src/gallium/auxiliary/util/u_format_access.py +++ b/src/gallium/auxiliary/util/u_format_access.py @@ -60,6 +60,9 @@ def is_format_supported(format): channel = format.channels[i] if channel.type not in (VOID, UNSIGNED, FLOAT): return False + if channel.type == FLOAT: + if channel.size not in (32, 64) or format.is_mixed(): + return False # We can only read a color from a depth/stencil format if the depth channel is present if format.colorspace == 'zs' and format.swizzles[0] == SWIZZLE_NONE: @@ -78,6 +81,8 @@ def native_type(format): else: # For array pixel formats return the integer type that matches the color channel channel = format.channels[0] + if channel.type == VOID: + channel = format.channels[1] if channel.type == UNSIGNED: return 'uint%u_t' % channel.size elif channel.type == SIGNED: diff --git a/src/gallium/auxiliary/util/u_format_pack.py b/src/gallium/auxiliary/util/u_format_pack.py index 409d024c637..47def90317e 100644 --- a/src/gallium/auxiliary/util/u_format_pack.py +++ b/src/gallium/auxiliary/util/u_format_pack.py @@ -46,11 +46,11 @@ def generate_format_type(format): '''Generate a structure that describes the format.''' print 'union util_format_%s {' % format.short_name() - if format.is_bitmask(): + if format.is_bitmask() or format.short_name() == "r11g11b10_float": print ' uint%u_t value;' % (format.block_size(),) print ' struct {' for channel in format.channels: - if format.is_bitmask() and not format.is_array(): + if (format.is_bitmask() or format.is_mixed()) and not format.is_array() or format.short_name() == "r11g11b10_float": if channel.type == VOID: if channel.size: print ' unsigned %s:%u;' % (channel.name, channel.size) @@ -58,6 +58,11 @@ def generate_format_type(format): print ' unsigned %s:%u;' % (channel.name, channel.size) elif channel.type == SIGNED: print ' int %s:%u;' % (channel.name, channel.size) + elif channel.type == FLOAT: + if channel.size == 32: + print ' float %s;' % (channel.name) + else: + print ' unsigned %s:%u;' % (channel.name, channel.size) else: assert 0 else: @@ -107,6 +112,9 @@ def is_format_supported(format): channel = format.channels[i] if channel.type not in (VOID, UNSIGNED, SIGNED, FLOAT): return False + if channel.type == FLOAT: + if channel.size not in (32, 64): + return False # We can only read a color from a depth/stencil format if the depth channel is present if format.colorspace == 'zs' and format.swizzles[0] == SWIZZLE_NONE: @@ -125,6 +133,8 @@ def native_type(format): else: # For array pixel formats return the integer type that matches the color channel type = format.channels[0] + if type.type == VOID: + type = format.channels[1] if type.type == UNSIGNED: return 'uint%u_t' % type.size elif type.type == SIGNED: diff --git a/src/gallium/auxiliary/util/u_format_parse.py b/src/gallium/auxiliary/util/u_format_parse.py index f74dc5e88a4..03dc62d3294 100755 --- a/src/gallium/auxiliary/util/u_format_parse.py +++ b/src/gallium/auxiliary/util/u_format_parse.py @@ -142,6 +142,8 @@ class Format: def is_mixed(self): ref_channel = self.channels[0] + if ref_channel.type == VOID: + ref_channel = self.channels[1] for channel in self.channels[1:]: if channel.type != VOID: if channel.type != ref_channel.type: -- cgit v1.2.3