static boolean
-test_format_fetch_float(const struct util_format_description *format_desc,
- const struct util_format_test_case *test)
+test_format_fetch_rgba_float(const struct util_format_description *format_desc,
+ const struct util_format_test_case *test)
{
float unpacked[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH][4] = { { { 0 } } };
unsigned i, j, k;
success = TRUE;
for (i = 0; i < format_desc->block.height; ++i) {
for (j = 0; j < format_desc->block.width; ++j) {
- format_desc->fetch_float(unpacked[i][j], test->packed, j, i);
+ format_desc->fetch_rgba_float(unpacked[i][j], test->packed, j, i);
for (k = 0; k < 4; ++k) {
if (!compare_float(test->unpacked[i][j][k], unpacked[i][j][k])) {
success = FALSE;
static boolean
-test_format_unpack_float(const struct util_format_description *format_desc,
- const struct util_format_test_case *test)
+test_format_unpack_rgba_float(const struct util_format_description *format_desc,
+ const struct util_format_test_case *test)
{
float unpacked[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH][4] = { { { 0 } } };
unsigned i, j, k;
boolean success;
- format_desc->unpack_float(&unpacked[0][0][0], sizeof unpacked[0],
+ format_desc->unpack_rgba_float(&unpacked[0][0][0], sizeof unpacked[0],
test->packed, 0,
format_desc->block.width, format_desc->block.height);
static boolean
-test_format_pack_float(const struct util_format_description *format_desc,
- const struct util_format_test_case *test)
+test_format_pack_rgba_float(const struct util_format_description *format_desc,
+ const struct util_format_test_case *test)
{
float unpacked[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH][4];
uint8_t packed[UTIL_FORMAT_MAX_PACKED_BYTES];
}
}
- format_desc->pack_float(packed, 0,
+ format_desc->pack_rgba_float(packed, 0,
&unpacked[0][0][0], sizeof unpacked[0],
format_desc->block.width, format_desc->block.height);
static boolean
-test_format_unpack_8unorm(const struct util_format_description *format_desc,
- const struct util_format_test_case *test)
+test_format_unpack_rgba_8unorm(const struct util_format_description *format_desc,
+ const struct util_format_test_case *test)
{
uint8_t unpacked[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH][4] = { { { 0 } } };
uint8_t expected[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH][4] = { { { 0 } } };
unsigned i, j, k;
boolean success;
- format_desc->unpack_8unorm(&unpacked[0][0][0], sizeof unpacked[0],
+ format_desc->unpack_rgba_8unorm(&unpacked[0][0][0], sizeof unpacked[0],
test->packed, 0,
format_desc->block.width, format_desc->block.height);
static boolean
-test_format_pack_8unorm(const struct util_format_description *format_desc,
- const struct util_format_test_case *test)
+test_format_pack_rgba_8unorm(const struct util_format_description *format_desc,
+ const struct util_format_test_case *test)
{
uint8_t unpacked[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH][4];
uint8_t packed[UTIL_FORMAT_MAX_PACKED_BYTES];
memset(packed, 0, sizeof packed);
- format_desc->pack_8unorm(packed, 0,
+ format_desc->pack_rgba_8unorm(packed, 0,
&unpacked[0][0][0], sizeof unpacked[0],
format_desc->block.width, format_desc->block.height);
{
bool success = TRUE;
- if (!test_one(&test_format_fetch_float, "fetch_float"))
+ if (!test_one(&test_format_fetch_rgba_float, "fetch_rgba_float"))
success = FALSE;
- if (!test_one(&test_format_pack_float, "pack_float"))
+ if (!test_one(&test_format_pack_rgba_float, "pack_rgba_float"))
success = FALSE;
- if (!test_one(&test_format_unpack_float, "unpack_float"))
+ if (!test_one(&test_format_unpack_rgba_float, "unpack_rgba_float"))
success = FALSE;
- if (!test_one(&test_format_pack_8unorm, "pack_8unorm"))
+ if (!test_one(&test_format_pack_rgba_8unorm, "pack_rgba_8unorm"))
success = FALSE;
- if (!test_one(&test_format_unpack_8unorm, "unpack_8unorm"))
+ if (!test_one(&test_format_unpack_rgba_8unorm, "unpack_rgba_8unorm"))
success = FALSE;
return success;
util/u_format_table.c \
util/u_format_tests.c \
util/u_format_yuv.c \
+ util/u_format_zs.c \
util/u_gen_mipmap.c \
util/u_half.c \
util/u_handle_table.c \
'util/u_format_table.c',
'util/u_format_tests.c',
'util/u_format_yuv.c',
+ 'util/u_format_zs.c',
'util/u_gen_mipmap.c',
'util/u_half.c',
'util/u_handle_table.c',
}
else {
/*
- * Fallback to calling util_format_description::fetch_float for each
+ * Fallback to calling util_format_description::fetch_rgba_float for each
* pixel.
*
* This is definitely not the most efficient way of fetching pixels, as
assert(type.floating);
- util_snprintf(name, sizeof name, "util_format_%s_fetch_float", format_desc->short_name);
+ util_snprintf(name, sizeof name, "util_format_%s_fetch_rgba_float", format_desc->short_name);
/*
- * Declare and bind format_desc->fetch_float().
+ * Declare and bind format_desc->fetch_rgba_float().
*/
function = LLVMGetNamedFunction(module, name);
assert(LLVMIsDeclaration(function));
- LLVMAddGlobalMapping(lp_build_engine, function, format_desc->fetch_float);
+ LLVMAddGlobalMapping(lp_build_engine, function, format_desc->fetch_rgba_float);
}
for (chan = 0; chan < 4; ++chan) {
"");
/*
- * Invoke format_desc->fetch_float() for each pixel and insert the result
+ * Invoke format_desc->fetch_rgba_float() for each pixel and insert the result
* in the SoA vectors.
*/
src_row = (const uint8_t *)src + y*src_stride + x*(format_desc->block.bits/8);
dst_row = dst;
- format_desc->unpack_float(dst_row, dst_stride, src_row, src_stride, w, h);
+ format_desc->unpack_rgba_float(dst_row, dst_stride, src_row, src_stride, w, h);
}
dst_row = (uint8_t *)dst + y*dst_stride + x*(format_desc->block.bits/8);
src_row = src;
- format_desc->pack_float(dst_row, dst_stride, src_row, src_stride, w, h);
+ format_desc->pack_rgba_float(dst_row, dst_stride, src_row, src_stride, w, h);
}
src_row = (const uint8_t *)src + y*src_stride + x*(format_desc->block.bits/8);
dst_row = dst;
- format_desc->unpack_8unorm(dst_row, dst_stride, src_row, src_stride, w, h);
+ format_desc->unpack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, w, h);
}
dst_row = (uint8_t *)dst + y*dst_stride + x*(format_desc->block.bits/8);
src_row = src;
- format_desc->pack_8unorm(dst_row, dst_stride, src_row, src_stride, w, h);
+ format_desc->pack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, w, h);
}
return;
while (height >= y_step) {
- src_format_desc->unpack_8unorm(tmp_row, tmp_stride, src_row, src_stride, width, y_step);
- dst_format_desc->pack_8unorm(dst_row, dst_stride, tmp_row, tmp_stride, width, y_step);
+ src_format_desc->unpack_rgba_8unorm(tmp_row, tmp_stride, src_row, src_stride, width, y_step);
+ dst_format_desc->pack_rgba_8unorm(dst_row, dst_stride, tmp_row, tmp_stride, width, y_step);
dst_row += dst_step;
src_row += src_step;
}
if (height) {
- src_format_desc->unpack_8unorm(tmp_row, tmp_stride, src_row, src_stride, width, height);
- dst_format_desc->pack_8unorm(dst_row, dst_stride, tmp_row, tmp_stride, width, height);
+ src_format_desc->unpack_rgba_8unorm(tmp_row, tmp_stride, src_row, src_stride, width, height);
+ dst_format_desc->pack_rgba_8unorm(dst_row, dst_stride, tmp_row, tmp_stride, width, height);
}
FREE(tmp_row);
return;
while (height >= y_step) {
- src_format_desc->unpack_float(tmp_row, tmp_stride, src_row, src_stride, width, y_step);
- dst_format_desc->pack_float(dst_row, dst_stride, tmp_row, tmp_stride, width, y_step);
+ src_format_desc->unpack_rgba_float(tmp_row, tmp_stride, src_row, src_stride, width, y_step);
+ dst_format_desc->pack_rgba_float(dst_row, dst_stride, tmp_row, tmp_stride, width, y_step);
dst_row += dst_step;
src_row += src_step;
}
if (height) {
- src_format_desc->unpack_float(tmp_row, tmp_stride, src_row, src_stride, width, height);
- dst_format_desc->pack_float(dst_row, dst_stride, tmp_row, tmp_stride, width, height);
+ src_format_desc->unpack_rgba_float(tmp_row, tmp_stride, src_row, src_stride, width, height);
+ dst_format_desc->pack_rgba_float(dst_row, dst_stride, tmp_row, tmp_stride, width, height);
}
FREE(tmp_row);
/**
* Unpack pixel blocks to R8G8B8A8_UNORM.
+ *
+ * Only defined for non-depth-stencil formats.
*/
void
- (*unpack_8unorm)(uint8_t *dst, unsigned dst_stride,
- const uint8_t *src, unsigned src_stride,
- unsigned width, unsigned height);
+ (*unpack_rgba_8unorm)(uint8_t *dst, unsigned dst_stride,
+ const uint8_t *src, unsigned src_stride,
+ unsigned width, unsigned height);
/**
* Pack pixel blocks from R8G8B8A8_UNORM.
+ *
+ * Only defined for non-depth-stencil formats.
*/
void
- (*pack_8unorm)(uint8_t *dst, unsigned dst_stride,
- const uint8_t *src, unsigned src_stride,
- unsigned width, unsigned height);
+ (*pack_rgba_8unorm)(uint8_t *dst, unsigned dst_stride,
+ const uint8_t *src, unsigned src_stride,
+ unsigned width, unsigned height);
/**
* Unpack pixel blocks to R32G32B32A32_FLOAT.
+ *
+ * Only defined for non-depth-stencil formats.
*/
void
- (*unpack_float)(float *dst, unsigned dst_stride,
- const uint8_t *src, unsigned src_stride,
- unsigned width, unsigned height);
+ (*unpack_rgba_float)(float *dst, unsigned dst_stride,
+ const uint8_t *src, unsigned src_stride,
+ unsigned width, unsigned height);
/**
* Pack pixel blocks from R32G32B32A32_FLOAT.
+ *
+ * Only defined for non-depth-stencil formats.
*/
void
- (*pack_float)(uint8_t *dst, unsigned dst_stride,
- const float *src, unsigned src_stride,
- unsigned width, unsigned height);
+ (*pack_rgba_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.
+ *
+ * Only defined for non-depth-stencil formats.
+ */
+ void
+ (*fetch_rgba_float)(float *dst,
+ const uint8_t *src,
+ unsigned i, unsigned j);
+
+ /**
+ * Unpack pixels to Z32_UNORM.
+ *
+ * Only defined for depth formats.
+ */
+ void
+ (*unpack_z_32unorm)(uint32_t *dst, unsigned dst_stride,
+ const uint8_t *src, unsigned src_stride,
+ unsigned width, unsigned height);
+
+ /**
+ * Pack pixels from Z32_FLOAT.
+ *
+ * Only defined for depth formats.
+ */
+ void
+ (*pack_z_32unorm)(uint8_t *dst, unsigned dst_stride,
+ const uint32_t *src, unsigned src_stride,
+ unsigned width, unsigned height);
+
+ /**
+ * Unpack pixels to Z32_FLOAT.
+ *
+ * Only defined for depth formats.
+ */
+ void
+ (*unpack_z_float)(float *dst, unsigned dst_stride,
+ const uint8_t *src, unsigned src_stride,
+ unsigned width, unsigned height);
+
+ /**
+ * Pack pixels from Z32_FLOAT.
+ *
+ * Only defined for depth formats.
+ */
+ void
+ (*pack_z_float)(uint8_t *dst, unsigned dst_stride,
+ const float *src, unsigned src_stride,
+ unsigned width, unsigned height);
+
+ /**
+ * Unpack pixels to S8_USCALED.
+ *
+ * Only defined for stencil formats.
+ */
+ void
+ (*unpack_s_32unorm)(uint8_t *dst, unsigned dst_stride,
+ const uint8_t *src, unsigned src_stride,
+ unsigned width, unsigned height);
+
+ /**
+ * Pack pixels from S8_USCALED.
+ *
+ * Only defined for stencil formats.
*/
void
- (*fetch_float)(float *dst,
- const uint8_t *src,
- unsigned i, unsigned j);
+ (*pack_s_8uscaled)(uint8_t *dst, unsigned dst_stride,
+ const uint8_t *src, unsigned src_stride,
+ unsigned width, unsigned height);
+
};
void
-util_format_r9g9b9e5_float_unpack_float(float *dst_row, unsigned dst_stride,
+util_format_r9g9b9e5_float_unpack_rgba_float(float *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height)
{
}
void
-util_format_r9g9b9e5_float_pack_float(uint8_t *dst_row, unsigned dst_stride,
+util_format_r9g9b9e5_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
const float *src_row, unsigned src_stride,
unsigned width, unsigned height)
{
}
void
-util_format_r9g9b9e5_float_fetch_float(float *dst, const uint8_t *src,
+util_format_r9g9b9e5_float_fetch_rgba_float(float *dst, const uint8_t *src,
unsigned i, unsigned j)
{
void
-util_format_r9g9b9e5_float_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride,
+util_format_r9g9b9e5_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height)
{
void
-util_format_r9g9b9e5_float_pack_8unorm(uint8_t *dst_row, unsigned dst_stride,
+util_format_r9g9b9e5_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height)
{
void
-util_format_r1_unorm_unpack_float(float *dst_row, unsigned dst_stride,
+util_format_r1_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height)
{
void
-util_format_r1_unorm_pack_float(uint8_t *dst_row, unsigned dst_stride,
+util_format_r1_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
const float *src_row, unsigned src_stride,
unsigned width, unsigned height)
{
void
-util_format_r1_unorm_fetch_float(float *dst, const uint8_t *src,
+util_format_r1_unorm_fetch_rgba_float(float *dst, const uint8_t *src,
unsigned i, unsigned j)
{
void
-util_format_r1_unorm_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride,
+util_format_r1_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height)
{
void
-util_format_r1_unorm_pack_8unorm(uint8_t *dst_row, unsigned dst_stride,
+util_format_r1_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height)
{
void
-util_format_r8g8bx_snorm_unpack_float(float *dst_row, unsigned dst_stride,
+util_format_r8g8bx_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height)
{
void
-util_format_r8g8bx_snorm_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride,
+util_format_r8g8bx_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height)
{
void
-util_format_r8g8bx_snorm_pack_float(uint8_t *dst_row, unsigned dst_stride,
+util_format_r8g8bx_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
const float *src_row, unsigned src_stride,
unsigned width, unsigned height)
{
void
-util_format_r8g8bx_snorm_pack_8unorm(uint8_t *dst_row, unsigned dst_stride,
+util_format_r8g8bx_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height)
{
void
-util_format_r8g8bx_snorm_fetch_float(float *dst, const uint8_t *src,
+util_format_r8g8bx_snorm_fetch_rgba_float(float *dst, const uint8_t *src,
unsigned i, unsigned j)
{
uint16_t value = *(const uint16_t *)src;
void
-util_format_r9g9b9e5_float_unpack_float(float *dst_row, unsigned dst_stride,
+util_format_r9g9b9e5_float_unpack_rgba_float(float *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height);
void
-util_format_r9g9b9e5_float_pack_float(uint8_t *dst_row, unsigned dst_stride,
+util_format_r9g9b9e5_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
const float *src_row, unsigned src_stride,
unsigned width, unsigned height);
void
-util_format_r9g9b9e5_float_fetch_float(float *dst, const uint8_t *src,
+util_format_r9g9b9e5_float_fetch_rgba_float(float *dst, const uint8_t *src,
unsigned i, unsigned j);
void
-util_format_r9g9b9e5_float_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride,
+util_format_r9g9b9e5_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height);
void
-util_format_r9g9b9e5_float_pack_8unorm(uint8_t *dst_row, unsigned dst_stride,
+util_format_r9g9b9e5_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height);
void
-util_format_r1_unorm_unpack_float(float *dst_row, unsigned dst_stride,
+util_format_r1_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height);
void
-util_format_r1_unorm_pack_float(uint8_t *dst_row, unsigned dst_stride,
+util_format_r1_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
const float *src_row, unsigned src_stride,
unsigned width, unsigned height);
void
-util_format_r1_unorm_fetch_float(float *dst, const uint8_t *src,
+util_format_r1_unorm_fetch_rgba_float(float *dst, const uint8_t *src,
unsigned i, unsigned j);
void
-util_format_r1_unorm_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride,
+util_format_r1_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height);
void
-util_format_r1_unorm_pack_8unorm(uint8_t *dst_row, unsigned dst_stride,
+util_format_r1_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height);
void
-util_format_r8g8bx_snorm_unpack_float(float *dst_row, unsigned dst_stride,
+util_format_r8g8bx_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height);
void
-util_format_r8g8bx_snorm_pack_float(uint8_t *dst_row, unsigned dst_stride,
+util_format_r8g8bx_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
const float *src_row, unsigned src_stride,
unsigned width, unsigned height);
void
-util_format_r8g8bx_snorm_fetch_float(float *dst, const uint8_t *src,
+util_format_r8g8bx_snorm_fetch_rgba_float(float *dst, const uint8_t *src,
unsigned i, unsigned j);
void
-util_format_r8g8bx_snorm_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride,
+util_format_r8g8bx_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height);
void
-util_format_r8g8bx_snorm_pack_8unorm(uint8_t *dst_row, unsigned dst_stride,
+util_format_r8g8bx_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height);
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.is_bitmask() or format.short_name() == "r11g11b10_float":
+
+ 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 (format.is_bitmask() or format.is_mixed()) and not format.is_array() or format.short_name() == "r11g11b10_float":
+ if use_bitfields:
if channel.type == VOID:
if channel.size:
print ' unsigned %s:%u;' % (channel.name, channel.size)
elif channel.type in (SIGNED, FIXED):
print ' int %s:%u;' % (channel.name, channel.size)
elif channel.type == FLOAT:
- if channel.size == 32:
+ if channel.size == 64:
+ print ' double %s;' % (channel.name)
+ elif channel.size == 32:
print ' float %s;' % (channel.name)
else:
print ' unsigned %s:%u;' % (channel.name, channel.size)
if channel.type == FLOAT and channel.size not in (16, 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:
- return False
-
return True
value = '0'
else:
assert False
- if format.colorspace == ZS:
- if i == 3:
- value = get_one(dst_channel)
- elif i >= 1:
- value = 'dst[0]'
print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i])
else:
value = '0'
else:
assert False
- if format.colorspace == ZS:
- if i == 3:
- value = get_one(dst_channel)
- elif i >= 1:
- value = 'dst[0]'
print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i])
dst_channel, dst_native_type,
value,
dst_colorspace = dst_colorspace)
- if format.colorspace == ZS:
- if i == 3:
- value = get_one(dst_channel)
- elif i >= 1:
- value = '0'
if dst_channel.type in (UNSIGNED, SIGNED):
if shift + dst_channel.size < depth:
value = '(%s) & 0x%x' % (value, (1 << dst_channel.size) - 1)
dst_channel, dst_native_type,
value,
dst_colorspace = dst_colorspace)
- if format.colorspace == ZS:
- if i == 3:
- value = get_one(dst_channel)
- elif i >= 1:
- value = '0'
print ' pixel.chan.%s = %s;' % (dst_channel.name, value)
bswap_format(format)
def is_format_hand_written(format):
- return format.layout in ('s3tc', 'subsampled', 'other')
+ return format.layout in ('s3tc', 'subsampled', 'other') or format.colorspace == ZS
+
def generate(formats):
print
print '#include "pipe/p_compiler.h"'
print '#include "u_math.h"'
+ print '#include "u_half.h"'
print '#include "u_format.h"'
print '#include "u_format_other.h"'
print '#include "u_format_srgb.h"'
print '#include "u_format_yuv.h"'
- print '#include "u_half.h"'
+ print '#include "u_format_zs.h"'
print
for format in formats:
- if is_format_supported(format):
- generate_format_type(format)
-
if not is_format_hand_written(format):
+
+ if is_format_supported(format):
+ generate_format_type(format)
+
channel = Channel(FLOAT, False, 32)
native_type = 'float'
- suffix = 'float'
+ suffix = 'rgba_float'
generate_format_unpack(format, channel, native_type, suffix)
generate_format_pack(format, channel, native_type, suffix)
channel = Channel(UNSIGNED, True, 8)
native_type = 'uint8_t'
- suffix = '8unorm'
+ suffix = 'rgba_8unorm'
generate_format_unpack(format, channel, native_type, suffix)
generate_format_pack(format, channel, native_type, suffix)
+
*/
void
-util_format_dxt1_rgb_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
+util_format_dxt1_rgb_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
{
util_format_dxt1_rgb_fetch(0, src, i, j, dst);
}
void
-util_format_dxt1_rgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
+util_format_dxt1_rgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
{
util_format_dxt1_rgba_fetch(0, src, i, j, dst);
}
void
-util_format_dxt3_rgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
+util_format_dxt3_rgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
{
util_format_dxt3_rgba_fetch(0, src, i, j, dst);
}
void
-util_format_dxt5_rgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
+util_format_dxt5_rgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
{
util_format_dxt5_rgba_fetch(0, src, i, j, dst);
}
void
-util_format_dxt1_rgb_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
+util_format_dxt1_rgb_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint8_t tmp[4];
util_format_dxt1_rgb_fetch(0, src, i, j, tmp);
}
void
-util_format_dxt1_rgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
+util_format_dxt1_rgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint8_t tmp[4];
util_format_dxt1_rgba_fetch(0, src, i, j, tmp);
}
void
-util_format_dxt3_rgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
+util_format_dxt3_rgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint8_t tmp[4];
util_format_dxt3_rgba_fetch(0, src, i, j, tmp);
}
void
-util_format_dxt5_rgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
+util_format_dxt5_rgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint8_t tmp[4];
util_format_dxt5_rgba_fetch(0, src, i, j, tmp);
*/
void
-util_format_dxt1_rgb_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
+util_format_dxt1_rgb_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y, i, j;
for(y = 0; y < height; y += 4) {
}
void
-util_format_dxt1_rgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
+util_format_dxt1_rgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y, i, j;
for(y = 0; y < height; y += 4) {
}
void
-util_format_dxt3_rgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
+util_format_dxt3_rgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y, i, j;
for(y = 0; y < height; y += 4) {
}
void
-util_format_dxt5_rgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
+util_format_dxt5_rgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y, i, j;
for(y = 0; y < height; y += 4) {
}
void
-util_format_dxt1_rgb_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
+util_format_dxt1_rgb_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y, i, j;
for(y = 0; y < height; y += 4) {
}
void
-util_format_dxt1_rgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
+util_format_dxt1_rgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y, i, j;
for(y = 0; y < height; y += 4) {
}
void
-util_format_dxt3_rgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
+util_format_dxt3_rgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y, i, j;
for(y = 0; y < height; y += 4) {
}
void
-util_format_dxt5_rgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
+util_format_dxt5_rgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y, i, j;
for(y = 0; y < height; y += 4) {
*/
void
-util_format_dxt1_rgb_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
+util_format_dxt1_rgb_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y, i, j, k;
for(y = 0; y < height; y += 4) {
}
void
-util_format_dxt1_rgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
+util_format_dxt1_rgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y, i, j, k;
for(y = 0; y < height; y += 4) {
}
void
-util_format_dxt3_rgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
+util_format_dxt3_rgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y, i, j, k;
for(y = 0; y < height; y += 4) {
}
void
-util_format_dxt5_rgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
+util_format_dxt5_rgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y, i, j, k;
for(y = 0; y < height; y += 4) {
}
void
-util_format_dxt1_rgb_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
+util_format_dxt1_rgb_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y, i, j, k;
for(y = 0; y < height; y += 4) {
}
void
-util_format_dxt1_rgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
+util_format_dxt1_rgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y, i, j, k;
for(y = 0; y < height; y += 4) {
}
void
-util_format_dxt3_rgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
+util_format_dxt3_rgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y, i, j, k;
for(y = 0; y < height; y += 4) {
}
void
-util_format_dxt5_rgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
+util_format_dxt5_rgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y, i, j, k;
for(y = 0; y < height; y += 4) {
*/
void
-util_format_dxt1_srgb_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
+util_format_dxt1_srgb_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
{
- util_format_dxt1_rgb_unpack_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
+ util_format_dxt1_rgb_unpack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
}
void
-util_format_dxt1_srgb_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
+util_format_dxt1_srgb_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
{
- util_format_dxt1_rgb_pack_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
+ util_format_dxt1_rgb_pack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
}
void
-util_format_dxt1_srgb_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
+util_format_dxt1_srgb_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
{
- util_format_dxt1_rgb_fetch_8unorm(dst, src, i, j);
+ util_format_dxt1_rgb_fetch_rgba_8unorm(dst, src, i, j);
}
void
-util_format_dxt1_srgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
+util_format_dxt1_srgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
{
- util_format_dxt1_rgba_unpack_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
+ util_format_dxt1_rgba_unpack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
}
void
-util_format_dxt1_srgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
+util_format_dxt1_srgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
{
- util_format_dxt1_rgba_pack_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
+ util_format_dxt1_rgba_pack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
}
void
-util_format_dxt1_srgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
+util_format_dxt1_srgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
{
- util_format_dxt1_rgba_fetch_8unorm(dst, src, i, j);
+ util_format_dxt1_rgba_fetch_rgba_8unorm(dst, src, i, j);
}
void
-util_format_dxt3_srgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
+util_format_dxt3_srgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
{
- util_format_dxt3_rgba_unpack_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
+ util_format_dxt3_rgba_unpack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
}
void
-util_format_dxt3_srgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
+util_format_dxt3_srgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
{
- util_format_dxt3_rgba_pack_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
+ util_format_dxt3_rgba_pack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
}
void
-util_format_dxt3_srgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
+util_format_dxt3_srgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
{
- util_format_dxt3_rgba_fetch_8unorm(dst, src, i, j);
+ util_format_dxt3_rgba_fetch_rgba_8unorm(dst, src, i, j);
}
void
-util_format_dxt5_srgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
+util_format_dxt5_srgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
{
- util_format_dxt5_rgba_unpack_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
+ util_format_dxt5_rgba_unpack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
}
void
-util_format_dxt5_srgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
+util_format_dxt5_srgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
{
- util_format_dxt5_rgba_pack_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
+ util_format_dxt5_rgba_pack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
}
void
-util_format_dxt5_srgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
+util_format_dxt5_srgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
{
- util_format_dxt5_rgba_fetch_8unorm(dst, src, i, j);
+ util_format_dxt5_rgba_fetch_rgba_8unorm(dst, src, i, j);
}
void
-util_format_dxt1_srgb_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
+util_format_dxt1_srgb_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
{
- util_format_dxt1_rgb_unpack_float(dst_row, dst_stride, src_row, src_stride, width, height);
+ util_format_dxt1_rgb_unpack_rgba_float(dst_row, dst_stride, src_row, src_stride, width, height);
}
void
-util_format_dxt1_srgb_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
+util_format_dxt1_srgb_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
{
- util_format_dxt1_rgb_pack_float(dst_row, dst_stride, src_row, src_stride, width, height);
+ util_format_dxt1_rgb_pack_rgba_float(dst_row, dst_stride, src_row, src_stride, width, height);
}
void
-util_format_dxt1_srgb_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
+util_format_dxt1_srgb_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
- util_format_dxt1_rgb_fetch_float(dst, src, i, j);
+ util_format_dxt1_rgb_fetch_rgba_float(dst, src, i, j);
}
void
-util_format_dxt1_srgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
+util_format_dxt1_srgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
{
- util_format_dxt1_rgba_unpack_float(dst_row, dst_stride, src_row, src_stride, width, height);
+ util_format_dxt1_rgba_unpack_rgba_float(dst_row, dst_stride, src_row, src_stride, width, height);
}
void
-util_format_dxt1_srgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
+util_format_dxt1_srgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
{
- util_format_dxt1_rgba_pack_float(dst_row, dst_stride, src_row, src_stride, width, height);
+ util_format_dxt1_rgba_pack_rgba_float(dst_row, dst_stride, src_row, src_stride, width, height);
}
void
-util_format_dxt1_srgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
+util_format_dxt1_srgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
- util_format_dxt1_rgba_fetch_float(dst, src, i, j);
+ util_format_dxt1_rgba_fetch_rgba_float(dst, src, i, j);
}
void
-util_format_dxt3_srgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
+util_format_dxt3_srgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
{
- util_format_dxt3_rgba_unpack_float(dst_row, dst_stride, src_row, src_stride, width, height);
+ util_format_dxt3_rgba_unpack_rgba_float(dst_row, dst_stride, src_row, src_stride, width, height);
}
void
-util_format_dxt3_srgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
+util_format_dxt3_srgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
{
- util_format_dxt3_rgba_pack_float(dst_row, dst_stride, src_row, src_stride, width, height);
+ util_format_dxt3_rgba_pack_rgba_float(dst_row, dst_stride, src_row, src_stride, width, height);
}
void
-util_format_dxt3_srgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
+util_format_dxt3_srgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
- util_format_dxt3_rgba_fetch_float(dst, src, i, j);
+ util_format_dxt3_rgba_fetch_rgba_float(dst, src, i, j);
}
void
-util_format_dxt5_srgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
+util_format_dxt5_srgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
{
- util_format_dxt5_rgba_unpack_float(dst_row, dst_stride, src_row, src_stride, width, height);
+ util_format_dxt5_rgba_unpack_rgba_float(dst_row, dst_stride, src_row, src_stride, width, height);
}
void
-util_format_dxt5_srgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
+util_format_dxt5_srgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
{
- util_format_dxt5_rgba_pack_float(dst_row, dst_stride, src_row, src_stride, width, height);
+ util_format_dxt5_rgba_pack_rgba_float(dst_row, dst_stride, src_row, src_stride, width, height);
}
void
-util_format_dxt5_srgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
+util_format_dxt5_srgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
- util_format_dxt5_rgba_fetch_float(dst, src, i, j);
+ util_format_dxt5_rgba_fetch_rgba_float(dst, src, i, j);
}
void
-util_format_dxt1_rgb_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+util_format_dxt1_rgb_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
void
-util_format_dxt1_rgb_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+util_format_dxt1_rgb_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
void
-util_format_dxt1_rgb_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j);
+util_format_dxt1_rgb_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j);
void
-util_format_dxt1_rgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+util_format_dxt1_rgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
void
-util_format_dxt1_rgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+util_format_dxt1_rgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
void
-util_format_dxt1_rgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j);
+util_format_dxt1_rgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j);
void
-util_format_dxt3_rgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+util_format_dxt3_rgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
void
-util_format_dxt3_rgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+util_format_dxt3_rgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
void
-util_format_dxt3_rgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j);
+util_format_dxt3_rgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j);
void
-util_format_dxt5_rgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+util_format_dxt5_rgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
void
-util_format_dxt5_rgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+util_format_dxt5_rgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
void
-util_format_dxt5_rgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j);
+util_format_dxt5_rgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j);
void
-util_format_dxt1_srgb_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+util_format_dxt1_srgb_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
void
-util_format_dxt1_srgb_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+util_format_dxt1_srgb_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
void
-util_format_dxt1_srgb_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j);
+util_format_dxt1_srgb_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j);
void
-util_format_dxt1_srgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+util_format_dxt1_srgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
void
-util_format_dxt1_srgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+util_format_dxt1_srgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
void
-util_format_dxt1_srgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j);
+util_format_dxt1_srgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j);
void
-util_format_dxt3_srgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+util_format_dxt3_srgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
void
-util_format_dxt3_srgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+util_format_dxt3_srgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
void
-util_format_dxt3_srgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j);
+util_format_dxt3_srgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j);
void
-util_format_dxt5_srgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+util_format_dxt5_srgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
void
-util_format_dxt5_srgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+util_format_dxt5_srgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
void
-util_format_dxt5_srgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j);
+util_format_dxt5_srgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j);
void
-util_format_dxt1_rgb_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+util_format_dxt1_rgb_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
void
-util_format_dxt1_rgb_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
+util_format_dxt1_rgb_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
void
-util_format_dxt1_rgb_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j);
+util_format_dxt1_rgb_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j);
void
-util_format_dxt1_rgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+util_format_dxt1_rgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
void
-util_format_dxt1_rgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
+util_format_dxt1_rgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
void
-util_format_dxt1_rgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j);
+util_format_dxt1_rgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j);
void
-util_format_dxt3_rgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+util_format_dxt3_rgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
void
-util_format_dxt3_rgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
+util_format_dxt3_rgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
void
-util_format_dxt3_rgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j);
+util_format_dxt3_rgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j);
void
-util_format_dxt5_rgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+util_format_dxt5_rgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
void
-util_format_dxt5_rgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
+util_format_dxt5_rgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
void
-util_format_dxt5_rgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j);
+util_format_dxt5_rgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j);
void
-util_format_dxt1_srgb_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+util_format_dxt1_srgb_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
void
-util_format_dxt1_srgb_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
+util_format_dxt1_srgb_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
void
-util_format_dxt1_srgb_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j);
+util_format_dxt1_srgb_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j);
void
-util_format_dxt1_srgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+util_format_dxt1_srgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
void
-util_format_dxt1_srgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
+util_format_dxt1_srgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
void
-util_format_dxt1_srgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j);
+util_format_dxt1_srgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j);
void
-util_format_dxt3_srgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+util_format_dxt3_srgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
void
-util_format_dxt3_srgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
+util_format_dxt3_srgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
void
-util_format_dxt3_srgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j);
+util_format_dxt3_srgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j);
void
-util_format_dxt5_srgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+util_format_dxt5_srgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
void
-util_format_dxt5_srgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
+util_format_dxt5_srgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
void
-util_format_dxt5_srgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j);
+util_format_dxt5_srgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j);
#endif /* U_FORMAT_S3TC_H_ */
print " %s%s\t/* %s */" % (swizzle_map[swizzle], sep, comment)
print " },"
print " %s," % (colorspace_map(format.colorspace),)
- print " &util_format_%s_unpack_8unorm," % format.short_name()
- print " &util_format_%s_pack_8unorm," % format.short_name()
- print " &util_format_%s_unpack_float," % format.short_name()
- print " &util_format_%s_pack_float," % format.short_name()
- print " &util_format_%s_fetch_float" % format.short_name()
+ if format.colorspace != ZS:
+ print " &util_format_%s_unpack_rgba_8unorm," % format.short_name()
+ print " &util_format_%s_pack_rgba_8unorm," % format.short_name()
+ print " &util_format_%s_unpack_rgba_float," % format.short_name()
+ print " &util_format_%s_pack_rgba_float," % format.short_name()
+ print " &util_format_%s_fetch_rgba_float," % format.short_name()
+ else:
+ print " NULL, /* unpack_rgba_8unorm */"
+ print " NULL, /* pack_rgba_8unorm */"
+ 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:
+ 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()
+ print " &util_format_%s_pack_z_float," % format.short_name()
+ else:
+ print " NULL, /* unpack_z_32unorm */"
+ 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:
+ print " &util_format_%s_unpack_s_8uscaled," % format.short_name()
+ print " &util_format_%s_pack_s_8uscaled" % format.short_name()
+ else:
+ print " NULL, /* unpack_s_8uscaled */"
+ print " NULL /* pack_s_8uscaled */"
print "};"
print
void
-util_format_r8g8_b8g8_unorm_unpack_float(float *dst_row, unsigned dst_stride,
+util_format_r8g8_b8g8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height)
{
void
-util_format_r8g8_b8g8_unorm_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride,
+util_format_r8g8_b8g8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height)
{
void
-util_format_r8g8_b8g8_unorm_pack_float(uint8_t *dst_row, unsigned dst_stride,
+util_format_r8g8_b8g8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
const float *src_row, unsigned src_stride,
unsigned width, unsigned height)
{
void
-util_format_r8g8_b8g8_unorm_pack_8unorm(uint8_t *dst_row, unsigned dst_stride,
+util_format_r8g8_b8g8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height)
{
void
-util_format_r8g8_b8g8_unorm_fetch_float(float *dst, const uint8_t *src,
+util_format_r8g8_b8g8_unorm_fetch_rgba_float(float *dst, const uint8_t *src,
unsigned i, unsigned j)
{
assert(i < 2);
void
-util_format_g8r8_g8b8_unorm_unpack_float(float *dst_row, unsigned dst_stride,
+util_format_g8r8_g8b8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height)
{
void
-util_format_g8r8_g8b8_unorm_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride,
+util_format_g8r8_g8b8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height)
{
void
-util_format_g8r8_g8b8_unorm_pack_float(uint8_t *dst_row, unsigned dst_stride,
+util_format_g8r8_g8b8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
const float *src_row, unsigned src_stride,
unsigned width, unsigned height)
{
void
-util_format_g8r8_g8b8_unorm_pack_8unorm(uint8_t *dst_row, unsigned dst_stride,
+util_format_g8r8_g8b8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height)
{
void
-util_format_g8r8_g8b8_unorm_fetch_float(float *dst, const uint8_t *src,
+util_format_g8r8_g8b8_unorm_fetch_rgba_float(float *dst, const uint8_t *src,
unsigned i, unsigned j)
{
assert(i < 2);
void
-util_format_uyvy_unpack_float(float *dst_row, unsigned dst_stride,
+util_format_uyvy_unpack_rgba_float(float *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height)
{
void
-util_format_uyvy_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride,
+util_format_uyvy_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height)
{
void
-util_format_uyvy_pack_float(uint8_t *dst_row, unsigned dst_stride,
+util_format_uyvy_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
const float *src_row, unsigned src_stride,
unsigned width, unsigned height)
{
void
-util_format_uyvy_pack_8unorm(uint8_t *dst_row, unsigned dst_stride,
+util_format_uyvy_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height)
{
void
-util_format_uyvy_fetch_float(float *dst, const uint8_t *src,
+util_format_uyvy_fetch_rgba_float(float *dst, const uint8_t *src,
unsigned i, unsigned j)
{
uint8_t y, u, v;
void
-util_format_yuyv_unpack_float(float *dst_row, unsigned dst_stride,
+util_format_yuyv_unpack_rgba_float(float *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height)
{
void
-util_format_yuyv_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride,
+util_format_yuyv_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height)
{
void
-util_format_yuyv_pack_float(uint8_t *dst_row, unsigned dst_stride,
+util_format_yuyv_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
const float *src_row, unsigned src_stride,
unsigned width, unsigned height)
{
void
-util_format_yuyv_pack_8unorm(uint8_t *dst_row, unsigned dst_stride,
+util_format_yuyv_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height)
{
void
-util_format_yuyv_fetch_float(float *dst, const uint8_t *src,
+util_format_yuyv_fetch_rgba_float(float *dst, const uint8_t *src,
unsigned i, unsigned j)
{
uint8_t y, u, v;
void
-util_format_uyvy_unpack_float(float *dst_row, unsigned dst_stride,
+util_format_uyvy_unpack_rgba_float(float *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height);
void
-util_format_uyvy_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride,
+util_format_uyvy_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height);
void
-util_format_uyvy_pack_float(uint8_t *dst_row, unsigned dst_stride,
+util_format_uyvy_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
const float *src_row, unsigned src_stride,
unsigned width, unsigned height);
void
-util_format_uyvy_pack_8unorm(uint8_t *dst_row, unsigned dst_stride,
+util_format_uyvy_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height);
void
-util_format_uyvy_fetch_float(float *dst, const uint8_t *src,
+util_format_uyvy_fetch_rgba_float(float *dst, const uint8_t *src,
unsigned i, unsigned j);
void
-util_format_yuyv_unpack_float(float *dst_row, unsigned dst_stride,
+util_format_yuyv_unpack_rgba_float(float *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height);
void
-util_format_yuyv_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride,
+util_format_yuyv_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height);
void
-util_format_yuyv_pack_float(uint8_t *dst_row, unsigned dst_stride,
+util_format_yuyv_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
const float *src_row, unsigned src_stride,
unsigned width, unsigned height);
void
-util_format_yuyv_pack_8unorm(uint8_t *dst_row, unsigned dst_stride,
+util_format_yuyv_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height);
void
-util_format_yuyv_fetch_float(float *dst, const uint8_t *src,
+util_format_yuyv_fetch_rgba_float(float *dst, const uint8_t *src,
unsigned i, unsigned j);
void
-util_format_r8g8_b8g8_unorm_unpack_float(float *dst_row, unsigned dst_stride,
+util_format_r8g8_b8g8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height);
void
-util_format_r8g8_b8g8_unorm_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride,
+util_format_r8g8_b8g8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height);
void
-util_format_r8g8_b8g8_unorm_pack_float(uint8_t *dst_row, unsigned dst_stride,
+util_format_r8g8_b8g8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
const float *src_row, unsigned src_stride,
unsigned width, unsigned height);
void
-util_format_r8g8_b8g8_unorm_pack_8unorm(uint8_t *dst_row, unsigned dst_stride,
+util_format_r8g8_b8g8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height);
void
-util_format_r8g8_b8g8_unorm_fetch_float(float *dst, const uint8_t *src,
+util_format_r8g8_b8g8_unorm_fetch_rgba_float(float *dst, const uint8_t *src,
unsigned i, unsigned j);
void
-util_format_g8r8_g8b8_unorm_unpack_float(float *dst_row, unsigned dst_stride,
+util_format_g8r8_g8b8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height);
void
-util_format_g8r8_g8b8_unorm_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride,
+util_format_g8r8_g8b8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height);
void
-util_format_g8r8_g8b8_unorm_pack_float(uint8_t *dst_row, unsigned dst_stride,
+util_format_g8r8_g8b8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
const float *src_row, unsigned src_stride,
unsigned width, unsigned height);
void
-util_format_g8r8_g8b8_unorm_pack_8unorm(uint8_t *dst_row, unsigned dst_stride,
+util_format_g8r8_g8b8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height);
void
-util_format_g8r8_g8b8_unorm_fetch_float(float *dst, const uint8_t *src,
+util_format_g8r8_g8b8_unorm_fetch_rgba_float(float *dst, const uint8_t *src,
unsigned i, unsigned j);
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2010 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ **************************************************************************/
+
+
+#include "u_debug.h"
+#include "u_math.h"
+#include "u_format_zs.h"
+
+
+void
+util_format_s8_uscaled_unpack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned y;
+ for(y = 0; y < height; ++y) {
+ memcpy(dst_row, src_row, width);
+ src_row += src_stride/sizeof(*src_row);
+ dst_row += dst_stride/sizeof(*dst_row);
+ }
+}
+
+void
+util_format_s8_uscaled_pack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned y;
+ for(y = 0; y < height; ++y) {
+ memcpy(dst_row, src_row, width);
+ src_row += src_stride/sizeof(*src_row);
+ dst_row += dst_stride/sizeof(*dst_row);
+ }
+}
+
+void
+util_format_z16_unorm_unpack_z_float(float *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+ for(y = 0; y < height; ++y) {
+ float *dst = dst_row;
+ const uint16_t *src = (const uint16_t *)src_row;
+ for(x = 0; x < width; ++x) {
+ uint16_t value = *src++;
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap16(value);
+#endif
+ dst[0] = (float)(value * (1.0f/0xffff));
+ dst += 1;
+ }
+ src_row += src_stride/sizeof(*src_row);
+ dst_row += dst_stride/sizeof(*dst_row);
+ }
+}
+
+void
+util_format_z16_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride,
+ const float *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+ for(y = 0; y < height; ++y) {
+ const float *src = src_row;
+ uint16_t *dst = (uint16_t *)dst_row;
+ for(x = 0; x < width; ++x) {
+ uint16_t value;
+ value = (uint16_t)(*src * 0xffff);
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap16(value);
+#endif
+ *dst++ = value;
+ src += 1;
+ }
+ dst_row += dst_stride/sizeof(*dst_row);
+ src_row += src_stride/sizeof(*src_row);
+ }
+}
+
+void
+util_format_z16_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+ for(y = 0; y < height; ++y) {
+ uint32_t *dst = dst_row;
+ const uint16_t *src = (const uint16_t *)src_row;
+ for(x = 0; x < width; ++x) {
+ uint16_t value = *src++;
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap16(value);
+#endif
+ /* value * 0xffffffff / 0xffff */
+ *dst++ = (value << 16) | value;
+ }
+ src_row += src_stride/sizeof(*src_row);
+ dst_row += dst_stride/sizeof(*dst_row);
+ }
+}
+
+void
+util_format_z16_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint32_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+ for(y = 0; y < height; ++y) {
+ const uint32_t *src = src_row;
+ uint16_t *dst = (uint16_t *)dst_row;
+ for(x = 0; x < width; ++x) {
+ uint16_t value;
+ value = (uint16_t)(*src++ >> 16);
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap16(value);
+#endif
+ *dst++ = value;
+ }
+ dst_row += dst_stride/sizeof(*dst_row);
+ src_row += src_stride/sizeof(*src_row);
+ }
+}
+
+void
+util_format_z32_unorm_unpack_z_float(float *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+ for(y = 0; y < height; ++y) {
+ float *dst = dst_row;
+ const uint32_t *src = (const uint32_t *)src_row;
+ for(x = 0; x < width; ++x) {
+ uint32_t value = *src++;
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+ *dst++ = (float)(value * (1.0/0xffffffff));
+ }
+ src_row += src_stride/sizeof(*src_row);
+ dst_row += dst_stride/sizeof(*dst_row);
+ }
+}
+
+void
+util_format_z32_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride,
+ const float *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+ for(y = 0; y < height; ++y) {
+ const float *src = src_row;
+ uint32_t *dst = (uint32_t *)dst_row;
+ for(x = 0; x < width; ++x) {
+ uint32_t value;
+ value = (uint32_t)(*src * (double)0xffffffff);
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+ *dst++ = value;
+ ++src;
+ }
+ dst_row += dst_stride/sizeof(*dst_row);
+ src_row += src_stride/sizeof(*src_row);
+ }
+}
+
+void
+util_format_z32_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned y;
+ for(y = 0; y < height; ++y) {
+ memcpy(dst_row, src_row, width * 4);
+ src_row += src_stride/sizeof(*src_row);
+ dst_row += dst_stride/sizeof(*dst_row);
+ }
+}
+
+void
+util_format_z32_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint32_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned y;
+ for(y = 0; y < height; ++y) {
+ memcpy(dst_row, src_row, width * 4);
+ src_row += src_stride/sizeof(*src_row);
+ dst_row += dst_stride/sizeof(*dst_row);
+ }
+}
+
+void
+util_format_z32_float_unpack_z_float(float *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned y;
+ for(y = 0; y < height; ++y) {
+ memcpy(dst_row, src_row, width * 4);
+ src_row += src_stride/sizeof(*src_row);
+ dst_row += dst_stride/sizeof(*dst_row);
+ }
+}
+
+void
+util_format_z32_float_pack_z_float(uint8_t *dst_row, unsigned dst_stride,
+ const float *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned y;
+ for(y = 0; y < height; ++y) {
+ memcpy(dst_row, src_row, width * 4);
+ src_row += src_stride/sizeof(*src_row);
+ dst_row += dst_stride/sizeof(*dst_row);
+ }
+}
+
+void
+util_format_z32_float_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+ for(y = 0; y < height; ++y) {
+ uint32_t *dst = dst_row;
+ const float *src = (const float *)src_row;
+ for(x = 0; x < width; ++x) {
+ *dst++ = (uint32_t)(*src++ * (double)0xffffffff);
+ }
+ src_row += src_stride/sizeof(*src_row);
+ dst_row += dst_stride/sizeof(*dst_row);
+ }
+}
+
+void
+util_format_z32_float_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint32_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+ for(y = 0; y < height; ++y) {
+ const uint32_t *src = src_row;
+ float *dst = (float *)dst_row;
+ for(x = 0; x < width; ++x) {
+ *dst++ = (float)(*src++ * (1.0/0xffffffff));
+ }
+ dst_row += dst_stride/sizeof(*dst_row);
+ src_row += src_stride/sizeof(*src_row);
+ }
+}
+
+void
+util_format_z24_unorm_s8_uscaled_unpack_z_float(float *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+ for(y = 0; y < height; ++y) {
+ float *dst = dst_row;
+ const uint32_t *src = (const uint32_t *)src_row;
+ for(x = 0; x < width; ++x) {
+ uint32_t value = *src++;
+ uint32_t z;
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+ z = (value) & 0xffffff;
+ *dst++ = (float)(z * (1.0/0xffffff));
+ }
+ src_row += src_stride/sizeof(*src_row);
+ dst_row += dst_stride/sizeof(*dst_row);
+ }
+}
+
+void
+util_format_z24_unorm_s8_uscaled_pack_z_float(uint8_t *dst_row, unsigned dst_stride,
+ const float *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+ for(y = 0; y < height; ++y) {
+ const float *src = src_row;
+ uint32_t *dst = (uint32_t *)dst_row;
+ for(x = 0; x < width; ++x) {
+ uint32_t value = *dst;
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+ value &= 0xff000000;
+ value |= ((uint32_t)(*src++ * (double)0xffffff)) & 0xffffff;
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+ *dst++ = value;
+ }
+ dst_row += dst_stride/sizeof(*dst_row);
+ src_row += src_stride/sizeof(*src_row);
+ }
+}
+
+void
+util_format_z24_unorm_s8_uscaled_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+ for(y = 0; y < height; ++y) {
+ uint32_t *dst = dst_row;
+ const uint32_t *src = (const uint32_t *)src_row;
+ for(x = 0; x < width; ++x) {
+ uint32_t value = *src++;
+ uint32_t z;
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+ z = value & 0xffffff;
+ *dst++ = (z << 8) | (z >> 16); /* z * 0xffffffff / 0xffffff */;
+ }
+ src_row += src_stride/sizeof(*src_row);
+ dst_row += dst_stride/sizeof(*dst_row);
+ }
+}
+
+void
+util_format_z24_unorm_s8_uscaled_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint32_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+ for(y = 0; y < height; ++y) {
+ const uint32_t *src = src_row;
+ uint32_t *dst = (uint32_t *)dst_row;
+ for(x = 0; x < width; ++x) {
+ uint32_t value;
+ value = ((uint32_t)(*src >> 8)) & 0xffffff;
+ value = ((uint32_t)(((uint64_t)src[1]) * 0x1 / 0xffffffff)) << 24;
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+ *dst++ = value;
+ src += 1;
+ dst += 4;
+ }
+ dst_row += dst_stride/sizeof(*dst_row);
+ src_row += src_stride/sizeof(*src_row);
+ }
+}
+
+void
+util_format_z24_unorm_s8_uscaled_unpack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+ for(y = 0; y < height; ++y) {
+ uint8_t *dst = dst_row;
+ const uint8_t *src = src_row;
+ for(x = 0; x < width; ++x) {
+ uint32_t value = *(const uint32_t *)src;
+ uint32_t z;
+ uint32_t s;
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+ z = (value) & 0xffffff;
+ s = value >> 24;
+ dst[1] = s;
+ src += 4;
+ dst += 1;
+ }
+ src_row += src_stride/sizeof(*src_row);
+ dst_row += dst_stride/sizeof(*dst_row);
+ }
+}
+
+void
+util_format_z24_unorm_s8_uscaled_pack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+ for(y = 0; y < height; ++y) {
+ const uint8_t *src = src_row;
+ uint8_t *dst = dst_row;
+ for(x = 0; x < width; ++x) {
+ uint32_t value;
+ value = ((uint32_t)(((uint32_t)MIN2(*src, 1)) * 0xffffff / 0x1)) & 0xffffff;
+ value = (src[1]) << 24;
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+ *(uint32_t *)dst = value;
+ src += 1;
+ dst += 4;
+ }
+ dst_row += dst_stride/sizeof(*dst_row);
+ src_row += src_stride/sizeof(*src_row);
+ }
+}
+
+void
+util_format_s8_uscaled_z24_unorm_unpack_z_float(float *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+ for(y = 0; y < height; ++y) {
+ float *dst = dst_row;
+ const uint8_t *src = src_row;
+ for(x = 0; x < width; ++x) {
+ uint32_t value = *(const uint32_t *)src;
+ uint32_t s;
+ uint32_t z;
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+ s = (value) & 0xff;
+ z = value >> 8;
+ dst[0] = (float)(z * (1.0/0xffffff));
+ src += 4;
+ dst += 1;
+ }
+ src_row += src_stride/sizeof(*src_row);
+ dst_row += dst_stride/sizeof(*dst_row);
+ }
+}
+
+void
+util_format_s8_uscaled_z24_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride,
+ const float *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+ for(y = 0; y < height; ++y) {
+ const float *src = src_row;
+ uint8_t *dst = dst_row;
+ for(x = 0; x < width; ++x) {
+ uint32_t value;
+ value = ((uint32_t)CLAMP(src[1], 0, 255)) & 0xff;
+ value = ((uint32_t)(*src * (double)0xffffff)) << 8;
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+ *(uint32_t *)dst = value;
+ src += 1;
+ dst += 4;
+ }
+ dst_row += dst_stride/sizeof(*dst_row);
+ src_row += src_stride/sizeof(*src_row);
+ }
+}
+
+void
+util_format_s8_uscaled_z24_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+ for(y = 0; y < height; ++y) {
+ uint32_t *dst = dst_row;
+ const uint8_t *src = src_row;
+ for(x = 0; x < width; ++x) {
+ uint32_t value = *(const uint32_t *)src;
+ uint32_t s;
+ uint32_t z;
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+ s = (value) & 0xff;
+ z = value >> 8;
+ dst[0] = (uint32_t)(((uint64_t)z) * 0xffffffff / 0xffffff);
+ src += 4;
+ dst += 1;
+ }
+ src_row += src_stride/sizeof(*src_row);
+ dst_row += dst_stride/sizeof(*dst_row);
+ }
+}
+
+void
+util_format_s8_uscaled_z24_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint32_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+ for(y = 0; y < height; ++y) {
+ const uint32_t *src = src_row;
+ uint8_t *dst = dst_row;
+ for(x = 0; x < width; ++x) {
+ uint32_t value;
+ value = ((uint32_t)(((uint64_t)src[1]) * 0x1 / 0xffffffff)) & 0xff;
+ value = ((uint32_t)(*src >> 8)) << 8;
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+ *(uint32_t *)dst = value;
+ src += 1;
+ dst += 4;
+ }
+ dst_row += dst_stride/sizeof(*dst_row);
+ src_row += src_stride/sizeof(*src_row);
+ }
+}
+
+void
+util_format_s8_uscaled_z24_unorm_unpack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+ for(y = 0; y < height; ++y) {
+ uint8_t *dst = dst_row;
+ const uint8_t *src = src_row;
+ for(x = 0; x < width; ++x) {
+ uint32_t value = *(const uint32_t *)src;
+ uint32_t s;
+ uint32_t z;
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+ s = (value) & 0xff;
+ z = value >> 8;
+ dst[1] = s;
+ src += 4;
+ dst += 1;
+ }
+ src_row += src_stride/sizeof(*src_row);
+ dst_row += dst_stride/sizeof(*dst_row);
+ }
+}
+
+void
+util_format_s8_uscaled_z24_unorm_pack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+ for(y = 0; y < height; ++y) {
+ const uint8_t *src = src_row;
+ uint8_t *dst = dst_row;
+ for(x = 0; x < width; ++x) {
+ uint32_t value;
+ value = (src[1]) & 0xff;
+ value = ((uint32_t)(((uint32_t)MIN2(*src, 1)) * 0xffffff / 0x1)) << 8;
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+ *(uint32_t *)dst = value;
+ src += 1;
+ dst += 4;
+ }
+ dst_row += dst_stride/sizeof(*dst_row);
+ src_row += src_stride/sizeof(*src_row);
+ }
+}
+
+void
+util_format_z24x8_unorm_unpack_z_float(float *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+ for(y = 0; y < height; ++y) {
+ float *dst = dst_row;
+ const uint8_t *src = src_row;
+ for(x = 0; x < width; ++x) {
+ uint32_t value = *(const uint32_t *)src;
+ uint32_t z;
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+ z = (value) & 0xffffff;
+ dst[0] = (float)(z * (1.0/0xffffff));
+ src += 4;
+ dst += 1;
+ }
+ src_row += src_stride/sizeof(*src_row);
+ dst_row += dst_stride/sizeof(*dst_row);
+ }
+}
+
+void
+util_format_z24x8_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride,
+ const float *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+ for(y = 0; y < height; ++y) {
+ const float *src = src_row;
+ uint8_t *dst = dst_row;
+ for(x = 0; x < width; ++x) {
+ uint32_t value;
+ value = ((uint32_t)(*src * (double)0xffffff)) & 0xffffff;
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+ *(uint32_t *)dst = value;
+ src += 1;
+ dst += 4;
+ }
+ dst_row += dst_stride/sizeof(*dst_row);
+ src_row += src_stride/sizeof(*src_row);
+ }
+}
+
+void
+util_format_z24x8_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+ for(y = 0; y < height; ++y) {
+ uint32_t *dst = dst_row;
+ const uint8_t *src = src_row;
+ for(x = 0; x < width; ++x) {
+ uint32_t value = *(const uint32_t *)src;
+ uint32_t z;
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+ z = (value) & 0xffffff;
+ dst[0] = (uint32_t)(((uint64_t)z) * 0xffffffff / 0xffffff);
+ src += 4;
+ dst += 1;
+ }
+ src_row += src_stride/sizeof(*src_row);
+ dst_row += dst_stride/sizeof(*dst_row);
+ }
+}
+
+void
+util_format_z24x8_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint32_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+ for(y = 0; y < height; ++y) {
+ const uint32_t *src = src_row;
+ uint8_t *dst = dst_row;
+ for(x = 0; x < width; ++x) {
+ uint32_t value;
+ value = ((uint32_t)(*src >> 8)) & 0xffffff;
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+ *(uint32_t *)dst = value;
+ src += 1;
+ dst += 4;
+ }
+ dst_row += dst_stride/sizeof(*dst_row);
+ src_row += src_stride/sizeof(*src_row);
+ }
+}
+
+void
+util_format_x8z24_unorm_unpack_z_float(float *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+ for(y = 0; y < height; ++y) {
+ float *dst = dst_row;
+ const uint8_t *src = src_row;
+ for(x = 0; x < width; ++x) {
+ uint32_t value = *(const uint32_t *)src;
+ uint32_t z;
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+ z = value >> 8;
+ dst[0] = (float)(z * (1.0/0xffffff));
+ src += 4;
+ dst += 1;
+ }
+ src_row += src_stride/sizeof(*src_row);
+ dst_row += dst_stride/sizeof(*dst_row);
+ }
+}
+
+void
+util_format_x8z24_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride,
+ const float *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+ for(y = 0; y < height; ++y) {
+ const float *src = src_row;
+ uint8_t *dst = dst_row;
+ for(x = 0; x < width; ++x) {
+ uint32_t value;
+ value = ((uint32_t)(*src * (double)0xffffff)) << 8;
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+ *(uint32_t *)dst = value;
+ src += 1;
+ dst += 4;
+ }
+ dst_row += dst_stride/sizeof(*dst_row);
+ src_row += src_stride/sizeof(*src_row);
+ }
+}
+
+void
+util_format_x8z24_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+ for(y = 0; y < height; ++y) {
+ uint32_t *dst = dst_row;
+ const uint8_t *src = src_row;
+ for(x = 0; x < width; ++x) {
+ uint32_t value = *(const uint32_t *)src;
+ uint32_t z;
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+ z = value >> 8;
+ dst[0] = (uint32_t)(((uint64_t)z) * 0xffffffff / 0xffffff);
+ src += 4;
+ dst += 1;
+ }
+ src_row += src_stride/sizeof(*src_row);
+ dst_row += dst_stride/sizeof(*dst_row);
+ }
+}
+
+void
+util_format_x8z24_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint32_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+ for(y = 0; y < height; ++y) {
+ const uint32_t *src = src_row;
+ uint8_t *dst = dst_row;
+ for(x = 0; x < width; ++x) {
+ uint32_t value;
+ value = ((uint32_t)(*src >> 8)) << 8;
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+ *(uint32_t *)dst = value;
+ src += 1;
+ dst += 4;
+ }
+ dst_row += dst_stride/sizeof(*dst_row);
+ src_row += src_stride/sizeof(*src_row);
+ }
+}
+
+void
+util_format_z32_float_s8x24_uscaled_unpack_z_float(float *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+ for(y = 0; y < height; ++y) {
+ float *dst = dst_row;
+ const float *src = (const float *)src_row;
+ for(x = 0; x < width; ++x) {
+ *dst = *src;
+ src += 2;
+ dst += 1;
+ }
+ src_row += src_stride/sizeof(*src_row);
+ dst_row += dst_stride/sizeof(*dst_row);
+ }
+}
+
+void
+util_format_z32_float_s8x24_uscaled_pack_z_float(uint8_t *dst_row, unsigned dst_stride,
+ const float *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+ for(y = 0; y < height; ++y) {
+ const float *src = src_row;
+ float *dst = (float *)dst_row;
+ for(x = 0; x < width; ++x) {
+ *dst = *src;
+ src += 1;
+ dst += 2;
+ }
+ dst_row += dst_stride/sizeof(*dst_row);
+ src_row += src_stride/sizeof(*src_row);
+ }
+}
+
+void
+util_format_z32_float_s8x24_uscaled_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+ for(y = 0; y < height; ++y) {
+ uint32_t *dst = dst_row;
+ const float *src = (const float *)src_row;
+ for(x = 0; x < width; ++x) {
+ *dst = (uint32_t)(*src * (double)0xffffffff);
+ src += 2;
+ dst += 1;
+ }
+ src_row += src_stride/sizeof(*src_row);
+ dst_row += dst_stride/sizeof(*dst_row);
+ }
+}
+
+void
+util_format_z32_float_s8x24_uscaled_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint32_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+ for(y = 0; y < height; ++y) {
+ const uint32_t *src = src_row;
+ float *dst = (float *)dst_row;
+ for(x = 0; x < width; ++x) {
+ *dst = (float)(*src * (1.0/0xffffffff));
+ src += 2;
+ dst += 1;
+ }
+ dst_row += dst_stride/sizeof(*dst_row);
+ src_row += src_stride/sizeof(*src_row);
+ }
+}
+
+void
+util_format_z32_float_s8x24_uscaled_unpack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+ for(y = 0; y < height; ++y) {
+ uint8_t *dst = dst_row;
+ const uint8_t *src = src_row + 4;
+ for(x = 0; x < width; ++x) {
+ *dst = *src;
+ src += 8;
+ dst += 1;
+ }
+ src_row += src_stride/sizeof(*src_row);
+ dst_row += dst_stride/sizeof(*dst_row);
+ }
+}
+
+void
+util_format_z32_float_s8x24_uscaled_pack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+ for(y = 0; y < height; ++y) {
+ const uint8_t *src = src_row;
+ uint8_t *dst = dst_row + 4;
+ for(x = 0; x < width; ++x) {
+ *dst = *src;
+ src += 1;
+ dst += 8;
+ }
+ dst_row += dst_stride/sizeof(*dst_row);
+ src_row += src_stride/sizeof(*src_row);
+ }
+}
+
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2010 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ **************************************************************************/
+
+
+#ifndef U_FORMAT_ZS_H_
+#define U_FORMAT_ZS_H_
+
+
+#include "pipe/p_compiler.h"
+
+
+void
+util_format_s8_uscaled_unpack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+void
+util_format_s8_uscaled_pack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+void
+util_format_z16_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+void
+util_format_z16_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+void
+util_format_z16_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+void
+util_format_z16_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+void
+util_format_z32_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+void
+util_format_z32_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+void
+util_format_z32_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+void
+util_format_z32_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+void
+util_format_z32_float_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+void
+util_format_z32_float_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+void
+util_format_z32_float_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+void
+util_format_z32_float_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+void
+util_format_z24_unorm_s8_uscaled_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+void
+util_format_z24_unorm_s8_uscaled_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+void
+util_format_z24_unorm_s8_uscaled_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+void
+util_format_z24_unorm_s8_uscaled_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+void
+util_format_z24_unorm_s8_uscaled_unpack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+void
+util_format_z24_unorm_s8_uscaled_pack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+void
+util_format_s8_uscaled_z24_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+void
+util_format_s8_uscaled_z24_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+void
+util_format_s8_uscaled_z24_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+void
+util_format_s8_uscaled_z24_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+void
+util_format_s8_uscaled_z24_unorm_unpack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+void
+util_format_s8_uscaled_z24_unorm_pack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+void
+util_format_z24x8_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+void
+util_format_z24x8_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+void
+util_format_z24x8_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+void
+util_format_z24x8_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+void
+util_format_x8z24_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+void
+util_format_x8z24_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+void
+util_format_x8z24_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+void
+util_format_x8z24_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+void
+util_format_z32_float_s8x24_uscaled_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+void
+util_format_z32_float_s8x24_uscaled_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+void
+util_format_z32_float_s8x24_uscaled_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+void
+util_format_z32_float_s8x24_uscaled_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+void
+util_format_z32_float_s8x24_uscaled_unpack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+void
+util_format_z32_float_s8x24_uscaled_pack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
+
+
+#endif /* U_FORMAT_ZS_H_ */