unsigned i;
boolean success;
- format_desc->unpack_float(unpacked, test->packed, 1);
+ format_desc->unpack_float(unpacked, 0, test->packed, 0, 1, 1);
success = TRUE;
for (i = 0; i < 4; ++i)
for (i = 0; i < 4; ++i)
unpacked[i] = (float) test->unpacked[i];
- format_desc->pack_float(packed, unpacked, 1);
+ format_desc->pack_float(packed, 0, unpacked, 0, 1, 1);
success = TRUE;
for (i = 0; i < UTIL_FORMAT_MAX_PACKED_BYTES; ++i)
unsigned i;
boolean success;
- format_desc->unpack_8unorm(unpacked, test->packed, 1);
+ format_desc->unpack_8unorm(unpacked, 0, test->packed, 0, 1, 1);
convert_float_to_8unorm(expected, test->unpacked);
memset(packed, 0, sizeof packed);
- format_desc->pack_8unorm(packed, unpacked, 1);
+ format_desc->pack_8unorm(packed, 0, unpacked, 0, 1, 1);
success = TRUE;
for (i = 0; i < UTIL_FORMAT_MAX_PACKED_BYTES; ++i)
const struct util_format_description *format_desc;
const uint8_t *src_row;
float *dst_row;
- unsigned row_blocks;
- unsigned i;
format_desc = util_format_description(format);
src_row = (const uint8_t *)src + y*src_stride + x*(format_desc->block.bits/8);
dst_row = dst;
- row_blocks = (w + format_desc->block.width - 1) / format_desc->block.width;
- for (i = 0; i < h; i += format_desc->block.height) {
- format_desc->unpack_float(dst_row, src_row, row_blocks);
- src_row += src_stride;
- dst_row += dst_stride/sizeof(*dst_row);
- }
+ format_desc->unpack_float(dst_row, dst_stride, src_row, src_stride, w, h);
}
const struct util_format_description *format_desc;
uint8_t *dst_row;
const float *src_row;
- unsigned row_blocks;
- unsigned i;
format_desc = util_format_description(format);
dst_row = (uint8_t *)dst + y*dst_stride + x*(format_desc->block.bits/8);
src_row = src;
- row_blocks = (w + format_desc->block.width - 1) / format_desc->block.width;
- for (i = 0; i < h; i += format_desc->block.height) {
- format_desc->pack_float(dst_row, src_row, row_blocks);
- dst_row += dst_stride;
- src_row += src_stride/sizeof(*src_row);
- }
+ format_desc->pack_float(dst_row, dst_stride, src_row, src_stride, w, h);
}
const struct util_format_description *format_desc;
const uint8_t *src_row;
uint8_t *dst_row;
- unsigned row_blocks;
- unsigned i;
format_desc = util_format_description(format);
src_row = (const uint8_t *)src + y*src_stride + x*(format_desc->block.bits/8);
dst_row = dst;
- row_blocks = (w + format_desc->block.width - 1) / format_desc->block.width;
- for (i = 0; i < h; i += format_desc->block.height) {
- format_desc->unpack_8unorm(dst_row, src_row, row_blocks);
- src_row += src_stride;
- dst_row += dst_stride/sizeof(*dst_row);
- }
+ format_desc->unpack_8unorm(dst_row, dst_stride, src_row, src_stride, w, h);
}
const struct util_format_description *format_desc;
uint8_t *dst_row;
const uint8_t *src_row;
- unsigned row_blocks;
- unsigned i;
format_desc = util_format_description(format);
dst_row = (uint8_t *)dst + y*dst_stride + x*(format_desc->block.bits/8);
src_row = src;
- row_blocks = (w + format_desc->block.width - 1) / format_desc->block.width;
- for (i = 0; i < h; i += format_desc->block.height) {
- format_desc->pack_8unorm(dst_row, src_row, row_blocks);
- dst_row += dst_stride;
- src_row += src_stride/sizeof(*src_row);
- }
+ format_desc->pack_8unorm(dst_row, dst_stride, src_row, src_stride, w, h);
}
enum util_format_colorspace colorspace;
/**
- * Unpack a span of pixel blocks to R8G8B8A8_UNORM.
+ * Unpack pixel blocks to R8G8B8A8_UNORM.
*/
void
- (*unpack_8unorm)(uint8_t *dst, const uint8_t *src, unsigned nr_blocks);
+ (*unpack_8unorm)(uint8_t *dst, unsigned dst_stride,
+ const uint8_t *src, unsigned src_stride,
+ unsigned width, unsigned height);
/**
- * Pack a span of pixel blocks from R8G8B8A8_UNORM.
+ * Pack pixel blocks from R8G8B8A8_UNORM.
*/
void
- (*pack_8unorm)(uint8_t *dst, const uint8_t *src, unsigned nr_blocks);
+ (*pack_8unorm)(uint8_t *dst, unsigned dst_stride,
+ const uint8_t *src, unsigned src_stride,
+ unsigned width, unsigned height);
/**
- * Unpack a span of pixel blocks to R32G32B32A32_FLOAT.
+ * Unpack pixel blocks to R32G32B32A32_FLOAT.
*/
void
- (*unpack_float)(float *dst, const uint8_t *src, unsigned nr_blocks);
+ (*unpack_float)(float *dst, unsigned dst_stride,
+ const uint8_t *src, unsigned src_stride,
+ unsigned width, unsigned height);
/**
- * Pack a span of pixel blocks from R32G32B32A32_FLOAT.
+ * Pack pixel blocks from R32G32B32A32_FLOAT.
*/
void
- (*pack_float)(uint8_t *dst, const float *src, unsigned nr_blocks);
+ (*pack_float)(uint8_t *dst, unsigned dst_stride,
+ const float *src, unsigned src_stride,
+ unsigned width, unsigned height);
/**
* Fetch a single pixel (i, j) from a block.
*/
void
- (*fetch_float)(float *dst, const uint8_t *src, unsigned i, unsigned j);
+ (*fetch_float)(float *dst,
+ const uint8_t *src,
+ unsigned i, unsigned j);
};
if format.is_bitmask():
depth = format.block_size()
- print ' uint%u_t value = *(uint%u_t *)src;' % (depth, depth)
+ print ' uint%u_t value = *(uint%u_t *)src;' % (depth, depth)
# Declare the intermediate variables
for i in range(format.nr_channels()):
src_channel = format.channels[i]
if src_channel.type == UNSIGNED:
- print ' uint%u_t %s;' % (depth, src_channel.name)
+ print ' uint%u_t %s;' % (depth, src_channel.name)
elif src_channel.type == SIGNED:
- print ' int%u_t %s;' % (depth, src_channel.name)
+ print ' int%u_t %s;' % (depth, src_channel.name)
- print ' #ifdef PIPE_ARCH_BIG_ENDIAN'
- print ' value = util_bswap%u(value);' % depth
- print ' #endif'
+ print '#ifdef PIPE_ARCH_BIG_ENDIAN'
+ print ' value = util_bswap%u(value);' % depth
+ print '#endif'
# Compute the intermediate unshifted values
shift = 0
value = None
if value is not None:
- print ' %s = %s;' % (src_channel.name, value)
+ print ' %s = %s;' % (src_channel.name, value)
shift += src_channel.size
value = get_one(dst_channel)
elif i >= 1:
value = 'dst[0]'
- print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i])
+ print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i])
else:
- print ' union util_format_%s pixel;' % format.short_name()
- print ' memcpy(&pixel, src, sizeof pixel);'
+ print ' union util_format_%s pixel;' % format.short_name()
+ print ' memcpy(&pixel, src, sizeof pixel);'
bswap_format(format)
for i in range(4):
value = get_one(dst_channel)
elif i >= 1:
value = 'dst[0]'
- print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i])
+ print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i])
def generate_pack_kernel(format, src_channel, src_native_type):
if format.is_bitmask():
depth = format.block_size()
- print ' uint%u_t value = 0;' % depth
+ print ' uint%u_t value = 0;' % depth
shift = 0
for i in range(4):
else:
value = None
if value is not None:
- print ' value |= %s;' % (value)
+ print ' value |= %s;' % (value)
shift += dst_channel.size
print '#ifdef PIPE_ARCH_BIG_ENDIAN'
- print ' value = util_bswap%u(value);' % depth
+ print ' value = util_bswap%u(value);' % depth
print '#endif'
- print ' *(uint%u_t *)dst = value;' % depth
+ print ' *(uint%u_t *)dst = value;' % depth
else:
- print ' union util_format_%s pixel;' % format.short_name()
+ print ' union util_format_%s pixel;' % format.short_name()
for i in range(4):
dst_channel = format.channels[i]
value = get_one(dst_channel)
elif i >= 1:
value = '0'
- print ' pixel.chan.%s = %s;' % (dst_channel.name, value)
+ print ' pixel.chan.%s = %s;' % (dst_channel.name, value)
bswap_format(format)
- print ' memcpy(dst, &pixel, sizeof pixel);'
+ print ' memcpy(dst, &pixel, sizeof pixel);'
def generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix):
name = format.short_name()
print 'static INLINE void'
- print 'util_format_%s_unpack_%s(%s *dst, const uint8_t *src, unsigned length)' % (name, dst_suffix, dst_native_type)
+ print 'util_format_%s_unpack_%s(%s *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)' % (name, dst_suffix, dst_native_type)
print '{'
if is_format_supported(format):
- print ' while(length--) {'
-
+ print ' unsigned x, y;'
+ print ' for(y = 0; y < height; y += %u) {' % (format.block_height,)
+ print ' %s *dst = dst_row;' % (dst_native_type)
+ print ' const uint8_t *src = src_row;'
+ print ' for(x = 0; x < width; x += %u) {' % (format.block_width,)
+
generate_unpack_kernel(format, dst_channel, dst_native_type)
- print ' src += %u;' % (format.block_size() / 8,)
- print ' dst += 4;'
+ print ' src += %u;' % (format.block_size() / 8,)
+ print ' dst += 4;'
+ print ' }'
+ print ' src_row += src_stride;'
+ print ' dst_row += dst_stride/sizeof(*dst_row);'
print ' }'
print '}'
name = format.short_name()
print 'static INLINE void'
- print 'util_format_%s_pack_%s(uint8_t *dst, const %s *src, unsigned length)' % (name, src_suffix, src_native_type)
+ print 'util_format_%s_pack_%s(uint8_t *dst_row, unsigned dst_stride, const %s *src_row, unsigned src_stride, unsigned width, unsigned height)' % (name, src_suffix, src_native_type)
print '{'
if is_format_supported(format):
- print ' while(length--) {'
+ print ' unsigned x, y;'
+ print ' for(y = 0; y < height; y += %u) {' % (format.block_height,)
+ print ' const %s *src = src_row;' % (src_native_type)
+ print ' uint8_t *dst = dst_row;'
+ print ' for(x = 0; x < width; x += %u) {' % (format.block_width,)
generate_pack_kernel(format, src_channel, src_native_type)
- print ' src += 4;'
- print ' dst += %u;' % (format.block_size() / 8,)
+ print ' src += 4;'
+ print ' dst += %u;' % (format.block_size() / 8,)
+ print ' }'
+ print ' dst_row += dst_stride;'
+ print ' src_row += src_stride/sizeof(*src_row);'
print ' }'
-
+
print '}'
print