diff options
author | marha <marha@users.sourceforge.net> | 2014-05-01 16:56:41 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2014-05-01 16:56:41 +0200 |
commit | ea0cd87ecbe9fc3c5503ccad7f87a895a458d6d4 (patch) | |
tree | a961f21249024edee920dc41bb54b2507cf08696 /mesalib/src/gallium/auxiliary/util | |
parent | 03418d6378fe72bea2ff4b941792054dd208b65d (diff) | |
download | vcxsrv-ea0cd87ecbe9fc3c5503ccad7f87a895a458d6d4.tar.gz vcxsrv-ea0cd87ecbe9fc3c5503ccad7f87a895a458d6d4.tar.bz2 vcxsrv-ea0cd87ecbe9fc3c5503ccad7f87a895a458d6d4.zip |
xkeyboard-config libxcb xserver mesa git update 1 May 2014
xserver commit 2535b76c0d32bc1dd0ddaca06a419a68a4757df1
libxcb commit d978a4f69b30b630f28d07f1003cf290284d24d8
xkeyboard-config commit 5274a69ee85fb6c425c33c631fa8ea1310a8f097
mesa commit a773fdc64da8ba88d8c7f8e383c45248b0c3aa19
Diffstat (limited to 'mesalib/src/gallium/auxiliary/util')
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_blit.c | 3 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_format_pack.py | 122 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_format_parse.py | 211 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_format_table.py | 44 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_math.h | 31 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_pack_color.h | 38 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_surface.c | 2 |
7 files changed, 273 insertions, 178 deletions
diff --git a/mesalib/src/gallium/auxiliary/util/u_blit.c b/mesalib/src/gallium/auxiliary/util/u_blit.c index 4b25b93dd..f69b4b1ab 100644 --- a/mesalib/src/gallium/auxiliary/util/u_blit.c +++ b/mesalib/src/gallium/auxiliary/util/u_blit.c @@ -520,6 +520,7 @@ util_blit_pixels_tex(struct blit_state *ctx, cso_save_depth_stencil_alpha(ctx->cso); cso_save_rasterizer(ctx->cso); cso_save_sample_mask(ctx->cso); + cso_save_min_samples(ctx->cso); cso_save_samplers(ctx->cso, PIPE_SHADER_FRAGMENT); cso_save_sampler_views(ctx->cso, PIPE_SHADER_FRAGMENT); cso_save_stream_outputs(ctx->cso); @@ -535,6 +536,7 @@ util_blit_pixels_tex(struct blit_state *ctx, cso_set_blend(ctx->cso, &ctx->blend_write_color); cso_set_depth_stencil_alpha(ctx->cso, &ctx->dsa_keep_depthstencil); cso_set_sample_mask(ctx->cso, ~0); + cso_set_min_samples(ctx->cso, 1); cso_set_rasterizer(ctx->cso, &ctx->rasterizer); cso_set_vertex_elements(ctx->cso, 2, ctx->velem); cso_set_stream_outputs(ctx->cso, 0, NULL, NULL); @@ -597,6 +599,7 @@ util_blit_pixels_tex(struct blit_state *ctx, cso_restore_depth_stencil_alpha(ctx->cso); cso_restore_rasterizer(ctx->cso); cso_restore_sample_mask(ctx->cso); + cso_restore_min_samples(ctx->cso); cso_restore_samplers(ctx->cso, PIPE_SHADER_FRAGMENT); cso_restore_sampler_views(ctx->cso, PIPE_SHADER_FRAGMENT); cso_restore_viewport(ctx->cso); diff --git a/mesalib/src/gallium/auxiliary/util/u_format_pack.py b/mesalib/src/gallium/auxiliary/util/u_format_pack.py index 8072fdb13..f9496de6c 100644 --- a/mesalib/src/gallium/auxiliary/util/u_format_pack.py +++ b/mesalib/src/gallium/auxiliary/util/u_format_pack.py @@ -40,24 +40,33 @@ from u_format_parse import * +def inv_swizzles(swizzles): + '''Return an array[4] of inverse swizzle terms''' + '''Only pick the first matching value to avoid l8 getting blue and i8 getting alpha''' + inv_swizzle = [None]*4 + for i in range(4): + swizzle = swizzles[i] + if swizzle < 4 and inv_swizzle[swizzle] == None: + inv_swizzle[swizzle] = i + return inv_swizzle + +def print_channels(format, func): + if format.nr_channels() <= 1: + func(format.le_channels, format.le_swizzles) + else: + print '#ifdef PIPE_ARCH_BIG_ENDIAN' + func(format.be_channels, format.be_swizzles) + print '#else' + func(format.le_channels, format.le_swizzles) + print '#endif' + def generate_format_type(format): '''Generate a structure that describes the format.''' assert format.layout == PLAIN - print 'union util_format_%s {' % format.short_name() - - if format.block_size() in (8, 16, 32, 64): - print ' uint%u_t value;' % (format.block_size(),) - - use_bitfields = False - for channel in format.channels: - if channel.size % 8 or not is_pot(channel.size): - use_bitfields = True - - print ' struct {' - for channel in format.channels: - if use_bitfields: + def generate_bitfields(channels, swizzles): + for channel in channels: if channel.type == VOID: if channel.size: print ' unsigned %s:%u;' % (channel.name, channel.size) @@ -74,7 +83,9 @@ def generate_format_type(format): print ' unsigned %s:%u;' % (channel.name, channel.size) else: assert 0 - else: + + def generate_full_fields(channels, swizzles): + for channel in channels: assert channel.size % 8 == 0 and is_pot(channel.size) if channel.type == VOID: if channel.size: @@ -94,6 +105,22 @@ def generate_format_type(format): assert 0 else: assert 0 + + print 'union util_format_%s {' % format.short_name() + + if format.block_size() in (8, 16, 32, 64): + print ' uint%u_t value;' % (format.block_size(),) + + use_bitfields = False + for channel in format.le_channels: + if channel.size % 8 or not is_pot(channel.size): + use_bitfields = True + + print ' struct {' + if use_bitfields: + print_channels(format, generate_bitfields) + else: + print_channels(format, generate_full_fields) print ' } chan;' print '};' print @@ -109,7 +136,7 @@ def is_format_supported(format): return False for i in range(4): - channel = format.channels[i] + channel = format.le_channels[i] if channel.type not in (VOID, UNSIGNED, SIGNED, FLOAT, FIXED): return False if channel.type == FLOAT and channel.size not in (16, 32, 64): @@ -117,27 +144,6 @@ def is_format_supported(format): return True -def is_format_pure_unsigned(format): - for i in range(4): - channel = format.channels[i] - if channel.type not in (VOID, UNSIGNED): - return False - if channel.type == UNSIGNED and channel.pure == False: - return False - - return True - - -def is_format_pure_signed(format): - for i in range(4): - channel = format.channels[i] - if channel.type not in (VOID, SIGNED): - return False - if channel.type == SIGNED and channel.pure == False: - return False - - return True - def native_type(format): '''Get the native appropriate for a format.''' @@ -152,7 +158,7 @@ def native_type(format): return 'uint%u_t' % format.block_size() else: # For array pixel formats return the integer type that matches the color channel - channel = format.channels[0] + channel = format.array_element() if channel.type in (UNSIGNED, VOID): return 'uint%u_t' % channel.size elif channel.type in (SIGNED, FIXED): @@ -410,13 +416,13 @@ def generate_unpack_kernel(format, dst_channel, dst_native_type): src_native_type = native_type(format) - if format.is_bitmask(): + def unpack_from_bitmask(channels, swizzles): depth = format.block_size() print ' uint%u_t value = *(const uint%u_t *)src;' % (depth, depth) # Declare the intermediate variables for i in range(format.nr_channels()): - src_channel = format.channels[i] + src_channel = channels[i] if src_channel.type == UNSIGNED: print ' uint%u_t %s;' % (depth, src_channel.name) elif src_channel.type == SIGNED: @@ -424,7 +430,7 @@ def generate_unpack_kernel(format, dst_channel, dst_native_type): # Compute the intermediate unshifted values for i in range(format.nr_channels()): - src_channel = format.channels[i] + src_channel = channels[i] value = 'value' shift = src_channel.shift if src_channel.type == UNSIGNED: @@ -451,9 +457,9 @@ def generate_unpack_kernel(format, dst_channel, dst_native_type): # Convert, swizzle, and store final values for i in range(4): - swizzle = format.swizzles[i] + swizzle = swizzles[i] if swizzle < 4: - src_channel = format.channels[swizzle] + src_channel = channels[swizzle] src_colorspace = format.colorspace if src_colorspace == SRGB and i == 3: # Alpha channel is linear @@ -473,14 +479,14 @@ def generate_unpack_kernel(format, dst_channel, dst_native_type): assert False print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i]) - else: + def unpack_from_union(channels, swizzles): print ' union util_format_%s pixel;' % format.short_name() print ' memcpy(&pixel, src, sizeof pixel);' for i in range(4): - swizzle = format.swizzles[i] + swizzle = swizzles[i] if swizzle < 4: - src_channel = format.channels[swizzle] + src_channel = channels[swizzle] src_colorspace = format.colorspace if src_colorspace == SRGB and i == 3: # Alpha channel is linear @@ -500,6 +506,11 @@ def generate_unpack_kernel(format, dst_channel, dst_native_type): assert False print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i]) + if format.is_bitmask(): + print_channels(format, unpack_from_bitmask) + else: + print_channels(format, unpack_from_union) + def generate_pack_kernel(format, src_channel, src_native_type): @@ -510,14 +521,14 @@ def generate_pack_kernel(format, src_channel, src_native_type): assert format.layout == PLAIN - inv_swizzle = format.inv_swizzles() + def pack_into_bitmask(channels, swizzles): + inv_swizzle = inv_swizzles(swizzles) - if format.is_bitmask(): depth = format.block_size() print ' uint%u_t value = 0;' % depth for i in range(4): - dst_channel = format.channels[i] + dst_channel = channels[i] shift = dst_channel.shift if inv_swizzle[i] is not None: value ='src[%u]' % inv_swizzle[i] @@ -544,11 +555,13 @@ def generate_pack_kernel(format, src_channel, src_native_type): print ' *(uint%u_t *)dst = value;' % depth - else: + def pack_into_union(channels, swizzles): + inv_swizzle = inv_swizzles(swizzles) + print ' union util_format_%s pixel;' % format.short_name() for i in range(4): - dst_channel = format.channels[i] + dst_channel = channels[i] width = dst_channel.size if inv_swizzle[i] is None: continue @@ -565,6 +578,11 @@ def generate_pack_kernel(format, src_channel, src_native_type): print ' memcpy(dst, &pixel, sizeof pixel);' + if format.is_bitmask(): + print_channels(format, pack_into_bitmask) + else: + print_channels(format, pack_into_union) + def generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix): '''Generate the function to unpack pixels from a particular format''' @@ -662,7 +680,7 @@ def generate(formats): if is_format_supported(format): generate_format_type(format) - if is_format_pure_unsigned(format): + if format.is_pure_unsigned(): native_type = 'unsigned' suffix = 'unsigned' channel = Channel(UNSIGNED, False, True, 32) @@ -676,7 +694,7 @@ def generate(formats): suffix = 'signed' generate_format_unpack(format, channel, native_type, suffix) generate_format_pack(format, channel, native_type, suffix) - elif is_format_pure_signed(format): + elif format.is_pure_signed(): native_type = 'int' suffix = 'signed' channel = Channel(SIGNED, False, True, 32) diff --git a/mesalib/src/gallium/auxiliary/util/u_format_parse.py b/mesalib/src/gallium/auxiliary/util/u_format_parse.py index e202099b9..15cc6d4fe 100644 --- a/mesalib/src/gallium/auxiliary/util/u_format_parse.py +++ b/mesalib/src/gallium/auxiliary/util/u_format_parse.py @@ -30,8 +30,6 @@ ''' -import sys - VOID, UNSIGNED, SIGNED, FIXED, FLOAT = range(5) SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W, SWIZZLE_0, SWIZZLE_1, SWIZZLE_NONE, = range(7) @@ -44,9 +42,6 @@ YUV = 'yuv' ZS = 'zs' -# Not cross-compiler friendly -is_big_endian = sys.byteorder == 'big' - def is_pot(x): return (x & (x - 1)) == 0 @@ -109,13 +104,15 @@ class Channel: class Format: '''Describe a pixel format.''' - def __init__(self, name, layout, block_width, block_height, channels, swizzles, colorspace): + def __init__(self, name, layout, block_width, block_height, le_channels, le_swizzles, be_channels, be_swizzles, colorspace): self.name = name self.layout = layout self.block_width = block_width self.block_height = block_height - self.channels = channels - self.swizzles = swizzles + self.le_channels = le_channels + self.le_swizzles = le_swizzles + self.be_channels = be_channels + self.be_swizzles = be_swizzles self.name = name self.colorspace = colorspace @@ -134,42 +131,45 @@ class Format: def block_size(self): size = 0 - for channel in self.channels: + for channel in self.le_channels: size += channel.size return size def nr_channels(self): nr_channels = 0 - for channel in self.channels: + for channel in self.le_channels: if channel.size: nr_channels += 1 return nr_channels - def is_array(self): + def array_element(self): if self.layout != PLAIN: - return False - ref_channel = self.channels[0] + return None + ref_channel = self.le_channels[0] if ref_channel.type == VOID: - ref_channel = self.channels[1] - for channel in self.channels: + ref_channel = self.le_channels[1] + for channel in self.le_channels: if channel.size and (channel.size != ref_channel.size or channel.size % 8): - return False + return None if channel.type != VOID: if channel.type != ref_channel.type: - return False + return None if channel.norm != ref_channel.norm: - return False + return None if channel.pure != ref_channel.pure: - return False - return True + return None + return ref_channel + + def is_array(self): + return self.array_element() != None def is_mixed(self): if self.layout != PLAIN: return False - ref_channel = self.channels[0] + ref_channel = self.le_channels[0] if ref_channel.type == VOID: - ref_channel = self.channels[1] - for channel in self.channels[1:]: + ref_channel = self.le_channels[1] + for channel in self.le_channels[1:]: if channel.type != VOID: if channel.type != ref_channel.type: return True @@ -185,7 +185,7 @@ class Format: def is_int(self): if self.layout != PLAIN: return False - for channel in self.channels: + for channel in self.le_channels: if channel.type not in (VOID, UNSIGNED, SIGNED): return False return True @@ -193,7 +193,7 @@ class Format: def is_float(self): if self.layout != PLAIN: return False - for channel in self.channels: + for channel in self.le_channels: if channel.type not in (VOID, FLOAT): return False return True @@ -203,20 +203,43 @@ class Format: return False if self.block_size() not in (8, 16, 32): return False - for channel in self.channels: + for channel in self.le_channels: if channel.type not in (VOID, UNSIGNED, SIGNED): return False return True - def inv_swizzles(self): - '''Return an array[4] of inverse swizzle terms''' - '''Only pick the first matching value to avoid l8 getting blue and i8 getting alpha''' - inv_swizzle = [None]*4 - for i in range(4): - swizzle = self.swizzles[i] - if swizzle < 4 and inv_swizzle[swizzle] == None: - inv_swizzle[swizzle] = i - return inv_swizzle + def is_pure_color(self): + if self.layout != PLAIN or self.colorspace == ZS: + return False + pures = [channel.pure + for channel in self.le_channels + if channel.type != VOID] + for x in pures: + assert x == pures[0] + return pures[0] + + def channel_type(self): + types = [channel.type + for channel in self.le_channels + if channel.type != VOID] + for x in types: + assert x == types[0] + return types[0] + + def is_pure_signed(self): + return self.is_pure_color() and self.channel_type() == SIGNED + + def is_pure_unsigned(self): + return self.is_pure_color() and self.channel_type() == UNSIGNED + + def has_channel(self, id): + return self.le_swizzles[id] != SWIZZLE_NONE + + def has_depth(self): + return self.colorspace == ZS and self.has_channel(0) + + def has_stencil(self): + return self.colorspace == ZS and self.has_channel(1) def stride(self): return self.block_size()/8 @@ -241,6 +264,54 @@ _swizzle_parse_map = { '_': SWIZZLE_NONE, } +def _parse_channels(fields, layout, colorspace, swizzles): + if layout == PLAIN: + names = ['']*4 + if colorspace in (RGB, SRGB): + for i in range(4): + swizzle = swizzles[i] + if swizzle < 4: + names[swizzle] += 'rgba'[i] + elif colorspace == ZS: + for i in range(4): + swizzle = swizzles[i] + if swizzle < 4: + names[swizzle] += 'zs'[i] + else: + assert False + for i in range(4): + if names[i] == '': + names[i] = 'x' + else: + names = ['x', 'y', 'z', 'w'] + + channels = [] + for i in range(0, 4): + field = fields[i] + if field: + type = _type_parse_map[field[0]] + if field[1] == 'n': + norm = True + pure = False + size = int(field[2:]) + elif field[1] == 'p': + pure = True + norm = False + size = int(field[2:]) + else: + norm = False + pure = False + size = int(field[1:]) + else: + type = VOID + norm = False + pure = False + size = 0 + channel = Channel(type, norm, pure, size, names[i]) + channels.append(channel) + + return channels + def parse(filename): '''Parse the format descrition in CSV format in terms of the Channel and Format classes above.''' @@ -263,61 +334,27 @@ def parse(filename): name = fields[0] layout = fields[1] block_width, block_height = map(int, fields[2:4]) - - swizzles = [_swizzle_parse_map[swizzle] for swizzle in fields[8]] colorspace = fields[9] - - if layout == PLAIN: - names = ['']*4 - if colorspace in (RGB, SRGB): - for i in range(4): - swizzle = swizzles[i] - if swizzle < 4: - names[swizzle] += 'rgba'[i] - elif colorspace == ZS: - for i in range(4): - swizzle = swizzles[i] - if swizzle < 4: - names[swizzle] += 'zs'[i] - else: - assert False - for i in range(4): - if names[i] == '': - names[i] = 'x' - else: - names = ['x', 'y', 'z', 'w'] - - channels = [] - for i in range(0, 4): - field = fields[4 + i] - if field: - type = _type_parse_map[field[0]] - if field[1] == 'n': - norm = True - pure = False - size = int(field[2:]) - elif field[1] == 'p': - pure = True - norm = False - size = int(field[2:]) - else: - norm = False - pure = False - size = int(field[1:]) - else: - type = VOID - norm = False - pure = False - size = 0 - channel = Channel(type, norm, pure, size, names[i]) - channels.append(channel) - shift = 0 - for channel in channels[3::-1] if is_big_endian else channels: - channel.shift = shift - shift += channel.size + le_swizzles = [_swizzle_parse_map[swizzle] for swizzle in fields[8]] + le_channels = _parse_channels(fields[4:8], layout, colorspace, le_swizzles) + + be_swizzles = [_swizzle_parse_map[swizzle] for swizzle in fields[8]] + be_channels = _parse_channels(fields[4:8], layout, colorspace, be_swizzles) + + le_shift = 0 + for channel in le_channels: + channel.shift = le_shift + le_shift += channel.size + + be_shift = 0 + for channel in be_channels[3::-1]: + channel.shift = be_shift + be_shift += channel.size + + assert le_shift == be_shift - format = Format(name, layout, block_width, block_height, channels, swizzles, colorspace) + format = Format(name, layout, block_width, block_height, le_channels, le_swizzles, be_channels, be_swizzles, colorspace) formats.append(format) return formats diff --git a/mesalib/src/gallium/auxiliary/util/u_format_table.py b/mesalib/src/gallium/auxiliary/util/u_format_table.py index 9d44cf391..81fd3996f 100644 --- a/mesalib/src/gallium/auxiliary/util/u_format_table.py +++ b/mesalib/src/gallium/auxiliary/util/u_format_table.py @@ -94,21 +94,10 @@ def write_format_table(formats): u_format_pack.generate(formats) - for format in formats: - print 'const struct util_format_description' - print 'util_format_%s_description = {' % (format.short_name(),) - print " %s," % (format.name,) - print " \"%s\"," % (format.name,) - print " \"%s\"," % (format.short_name(),) - print " {%u, %u, %u},\t/* block */" % (format.block_width, format.block_height, format.block_size()) - print " %s," % (layout_map(format.layout),) - print " %u,\t/* nr_channels */" % (format.nr_channels(),) - print " %s,\t/* is_array */" % (bool_map(format.is_array()),) - print " %s,\t/* is_bitmask */" % (bool_map(format.is_bitmask()),) - print " %s,\t/* is_mixed */" % (bool_map(format.is_mixed()),) + def do_channel_array(channels, swizzles): print " {" for i in range(4): - channel = format.channels[i] + channel = channels[i] if i < 3: sep = "," else: @@ -118,9 +107,11 @@ def write_format_table(formats): else: print " {0, 0, 0, 0, 0}%s" % (sep,) print " }," + + def do_swizzle_array(channels, swizzles): print " {" for i in range(4): - swizzle = format.swizzles[i] + swizzle = swizzles[i] if i < 3: sep = "," else: @@ -131,8 +122,23 @@ def write_format_table(formats): comment = 'ignored' print " %s%s\t/* %s */" % (swizzle_map[swizzle], sep, comment) print " }," + + for format in formats: + print 'const struct util_format_description' + print 'util_format_%s_description = {' % (format.short_name(),) + print " %s," % (format.name,) + print " \"%s\"," % (format.name,) + print " \"%s\"," % (format.short_name(),) + print " {%u, %u, %u},\t/* block */" % (format.block_width, format.block_height, format.block_size()) + print " %s," % (layout_map(format.layout),) + print " %u,\t/* nr_channels */" % (format.nr_channels(),) + print " %s,\t/* is_array */" % (bool_map(format.is_array()),) + print " %s,\t/* is_bitmask */" % (bool_map(format.is_bitmask()),) + print " %s,\t/* is_mixed */" % (bool_map(format.is_mixed()),) + u_format_pack.print_channels(format, do_channel_array) + u_format_pack.print_channels(format, do_swizzle_array) print " %s," % (colorspace_map(format.colorspace),) - if format.colorspace != ZS and format.channels[0].pure == False: + if format.colorspace != ZS and not format.is_pure_color(): print " &util_format_%s_unpack_rgba_8unorm," % format.short_name() print " &util_format_%s_pack_rgba_8unorm," % format.short_name() if format.layout == 's3tc' or format.layout == 'rgtc': @@ -149,7 +155,7 @@ def write_format_table(formats): print " NULL, /* unpack_rgba_float */" print " NULL, /* pack_rgba_float */" print " NULL, /* fetch_rgba_float */" - if format.colorspace == ZS and format.swizzles[0] != SWIZZLE_NONE: + if format.has_depth(): print " &util_format_%s_unpack_z_32unorm," % format.short_name() print " &util_format_%s_pack_z_32unorm," % format.short_name() print " &util_format_%s_unpack_z_float," % format.short_name() @@ -159,20 +165,20 @@ def write_format_table(formats): print " NULL, /* pack_z_32unorm */" print " NULL, /* unpack_z_float */" print " NULL, /* pack_z_float */" - if format.colorspace == ZS and format.swizzles[1] != SWIZZLE_NONE: + if format.has_stencil(): print " &util_format_%s_unpack_s_8uint," % format.short_name() print " &util_format_%s_pack_s_8uint," % format.short_name() else: print " NULL, /* unpack_s_8uint */" print " NULL, /* pack_s_8uint */" - if format.colorspace != ZS and format.channels[0].pure == True and format.channels[0].type == UNSIGNED: + if format.is_pure_unsigned(): print " &util_format_%s_unpack_unsigned, /* unpack_rgba_uint */" % format.short_name() print " &util_format_%s_pack_unsigned, /* pack_rgba_uint */" % format.short_name() print " &util_format_%s_unpack_signed, /* unpack_rgba_sint */" % format.short_name() print " &util_format_%s_pack_signed, /* pack_rgba_sint */" % format.short_name() print " &util_format_%s_fetch_unsigned, /* fetch_rgba_uint */" % format.short_name() print " NULL /* fetch_rgba_sint */" - elif format.colorspace != ZS and format.channels[0].pure == True and format.channels[0].type == SIGNED: + elif format.is_pure_signed(): print " &util_format_%s_unpack_unsigned, /* unpack_rgba_uint */" % format.short_name() print " &util_format_%s_pack_unsigned, /* pack_rgba_uint */" % format.short_name() print " &util_format_%s_unpack_signed, /* unpack_rgba_sint */" % format.short_name() diff --git a/mesalib/src/gallium/auxiliary/util/u_math.h b/mesalib/src/gallium/auxiliary/util/u_math.h index ec03e4e58..a60e1830a 100644 --- a/mesalib/src/gallium/auxiliary/util/u_math.h +++ b/mesalib/src/gallium/auxiliary/util/u_math.h @@ -567,6 +567,22 @@ static INLINE unsigned util_last_bit(unsigned u) #endif } +/** + * Find last bit in a word that does not match the sign bit. The least + * significant bit is 1. + * Return 0 if no bits are set. + */ +static INLINE unsigned util_last_bit_signed(int i) +{ +#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 407) + return 31 - __builtin_clrsb(i); +#else + if (i >= 0) + return util_last_bit(i); + else + return util_last_bit(~(unsigned)i); +#endif +} /* Destructively loop over all of the bits in a mask as in: * @@ -715,6 +731,21 @@ util_bitcount(unsigned n) #endif } +/** + * Reverse bits in n + * Algorithm taken from: + * http://stackoverflow.com/questions/9144800/c-reverse-bits-in-unsigned-integer + */ +static INLINE unsigned +util_bitreverse(unsigned n) +{ + n = ((n >> 1) & 0x55555555u) | ((n & 0x55555555u) << 1); + n = ((n >> 2) & 0x33333333u) | ((n & 0x33333333u) << 2); + n = ((n >> 4) & 0x0f0f0f0fu) | ((n & 0x0f0f0f0fu) << 4); + n = ((n >> 8) & 0x00ff00ffu) | ((n & 0x00ff00ffu) << 8); + n = ((n >> 16) & 0xffffu) | ((n & 0xffffu) << 16); + return n; +} /** * Convert from little endian to CPU byte order. diff --git a/mesalib/src/gallium/auxiliary/util/u_pack_color.h b/mesalib/src/gallium/auxiliary/util/u_pack_color.h index 166c68b57..e0c9018f8 100644 --- a/mesalib/src/gallium/auxiliary/util/u_pack_color.h +++ b/mesalib/src/gallium/auxiliary/util/u_pack_color.h @@ -51,7 +51,7 @@ union util_color { ubyte ub; ushort us; - uint ui; + uint ui[4]; ushort h[4]; /* half float */ float f[4]; double d[4]; @@ -67,32 +67,32 @@ util_pack_color_ub(ubyte r, ubyte g, ubyte b, ubyte a, switch (format) { case PIPE_FORMAT_ABGR8888_UNORM: { - uc->ui = (r << 24) | (g << 16) | (b << 8) | a; + uc->ui[0] = (r << 24) | (g << 16) | (b << 8) | a; } return; case PIPE_FORMAT_XBGR8888_UNORM: { - uc->ui = (r << 24) | (g << 16) | (b << 8) | 0xff; + uc->ui[0] = (r << 24) | (g << 16) | (b << 8) | 0xff; } return; case PIPE_FORMAT_BGRA8888_UNORM: { - uc->ui = (a << 24) | (r << 16) | (g << 8) | b; + uc->ui[0] = (a << 24) | (r << 16) | (g << 8) | b; } return; case PIPE_FORMAT_BGRX8888_UNORM: { - uc->ui = (0xff << 24) | (r << 16) | (g << 8) | b; + uc->ui[0] = (0xff << 24) | (r << 16) | (g << 8) | b; } return; case PIPE_FORMAT_ARGB8888_UNORM: { - uc->ui = (b << 24) | (g << 16) | (r << 8) | a; + uc->ui[0] = (b << 24) | (g << 16) | (r << 8) | a; } return; case PIPE_FORMAT_XRGB8888_UNORM: { - uc->ui = (b << 24) | (g << 16) | (r << 8) | 0xff; + uc->ui[0] = (b << 24) | (g << 16) | (r << 8) | 0xff; } return; case PIPE_FORMAT_B5G6R5_UNORM: @@ -168,7 +168,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc, switch (format) { case PIPE_FORMAT_ABGR8888_UNORM: { - uint p = uc->ui; + uint p = uc->ui[0]; *r = (ubyte) ((p >> 24) & 0xff); *g = (ubyte) ((p >> 16) & 0xff); *b = (ubyte) ((p >> 8) & 0xff); @@ -177,7 +177,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc, return; case PIPE_FORMAT_XBGR8888_UNORM: { - uint p = uc->ui; + uint p = uc->ui[0]; *r = (ubyte) ((p >> 24) & 0xff); *g = (ubyte) ((p >> 16) & 0xff); *b = (ubyte) ((p >> 8) & 0xff); @@ -186,7 +186,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc, return; case PIPE_FORMAT_BGRA8888_UNORM: { - uint p = uc->ui; + uint p = uc->ui[0]; *r = (ubyte) ((p >> 16) & 0xff); *g = (ubyte) ((p >> 8) & 0xff); *b = (ubyte) ((p >> 0) & 0xff); @@ -195,7 +195,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc, return; case PIPE_FORMAT_BGRX8888_UNORM: { - uint p = uc->ui; + uint p = uc->ui[0]; *r = (ubyte) ((p >> 16) & 0xff); *g = (ubyte) ((p >> 8) & 0xff); *b = (ubyte) ((p >> 0) & 0xff); @@ -204,7 +204,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc, return; case PIPE_FORMAT_ARGB8888_UNORM: { - uint p = uc->ui; + uint p = uc->ui[0]; *r = (ubyte) ((p >> 8) & 0xff); *g = (ubyte) ((p >> 16) & 0xff); *b = (ubyte) ((p >> 24) & 0xff); @@ -213,7 +213,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc, return; case PIPE_FORMAT_XRGB8888_UNORM: { - uint p = uc->ui; + uint p = uc->ui[0]; *r = (ubyte) ((p >> 8) & 0xff); *g = (ubyte) ((p >> 16) & 0xff); *b = (ubyte) ((p >> 24) & 0xff); @@ -352,32 +352,32 @@ util_pack_color(const float rgba[4], enum pipe_format format, union util_color * switch (format) { case PIPE_FORMAT_ABGR8888_UNORM: { - uc->ui = (r << 24) | (g << 16) | (b << 8) | a; + uc->ui[0] = (r << 24) | (g << 16) | (b << 8) | a; } return; case PIPE_FORMAT_XBGR8888_UNORM: { - uc->ui = (r << 24) | (g << 16) | (b << 8) | 0xff; + uc->ui[0] = (r << 24) | (g << 16) | (b << 8) | 0xff; } return; case PIPE_FORMAT_BGRA8888_UNORM: { - uc->ui = (a << 24) | (r << 16) | (g << 8) | b; + uc->ui[0] = (a << 24) | (r << 16) | (g << 8) | b; } return; case PIPE_FORMAT_BGRX8888_UNORM: { - uc->ui = (0xff << 24) | (r << 16) | (g << 8) | b; + uc->ui[0] = (0xff << 24) | (r << 16) | (g << 8) | b; } return; case PIPE_FORMAT_ARGB8888_UNORM: { - uc->ui = (b << 24) | (g << 16) | (r << 8) | a; + uc->ui[0] = (b << 24) | (g << 16) | (r << 8) | a; } return; case PIPE_FORMAT_XRGB8888_UNORM: { - uc->ui = (b << 24) | (g << 16) | (r << 8) | 0xff; + uc->ui[0] = (b << 24) | (g << 16) | (r << 8) | 0xff; } return; case PIPE_FORMAT_B5G6R5_UNORM: diff --git a/mesalib/src/gallium/auxiliary/util/u_surface.c b/mesalib/src/gallium/auxiliary/util/u_surface.c index 07997d2ad..654b5bbc5 100644 --- a/mesalib/src/gallium/auxiliary/util/u_surface.c +++ b/mesalib/src/gallium/auxiliary/util/u_surface.c @@ -196,7 +196,7 @@ util_fill_rect(ubyte * dst, for (i = 0; i < height; i++) { uint32_t *row = (uint32_t *)dst; for (j = 0; j < width; j++) - *row++ = uc->ui; + *row++ = uc->ui[0]; dst += dst_stride; } break; |