util: Get DXT1_RGB format working correctly.
This commit is contained in:
parent
ca6aacf842
commit
8548efbe1d
|
@ -44,7 +44,6 @@ compare_float(float x, float y)
|
|||
error = -error;
|
||||
|
||||
if (error > FLT_EPSILON) {
|
||||
printf("error = %g\n", error);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -201,6 +200,15 @@ test_format_pack_float(const struct util_format_description *format_desc,
|
|||
unsigned i, j, k;
|
||||
boolean success;
|
||||
|
||||
if (format_desc->layout == UTIL_FORMAT_LAYOUT_S3TC) {
|
||||
/*
|
||||
* Skip S3TC as packed representation is not canonical.
|
||||
*
|
||||
* TODO: Do a round trip conversion.
|
||||
*/
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
memset(packed, 0, sizeof packed);
|
||||
for (i = 0; i < format_desc->block.height; ++i) {
|
||||
for (j = 0; j < format_desc->block.width; ++j) {
|
||||
|
@ -259,7 +267,7 @@ test_format_unpack_8unorm(const struct util_format_description *format_desc,
|
|||
unsigned i, j, k;
|
||||
boolean success;
|
||||
|
||||
format_desc->unpack_8unorm(&unpacked[0][0][0], 0, test->packed, 0, 1, 1);
|
||||
format_desc->unpack_8unorm(&unpacked[0][0][0], sizeof unpacked[0], test->packed, 0, 1, 1);
|
||||
|
||||
convert_float_to_8unorm(&expected[0][0][0], &test->unpacked[0][0][0]);
|
||||
|
||||
|
@ -292,6 +300,15 @@ test_format_pack_8unorm(const struct util_format_description *format_desc,
|
|||
unsigned i;
|
||||
boolean success;
|
||||
|
||||
if (format_desc->layout == UTIL_FORMAT_LAYOUT_S3TC) {
|
||||
/*
|
||||
* Skip S3TC as packed representation is not canonical.
|
||||
*
|
||||
* TODO: Do a round trip conversion.
|
||||
*/
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (!convert_float_to_8unorm(&unpacked[0][0][0], &test->unpacked[0][0][0])) {
|
||||
/*
|
||||
* Skip test cases which cannot be represented by four unorm bytes.
|
||||
|
|
|
@ -188,12 +188,43 @@ util_format_dxt5_rgba_fetch_float(float *dst, const uint8_t *src, unsigned i, un
|
|||
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)
|
||||
{
|
||||
if (util_format_dxt1_rgb_fetch) {
|
||||
unsigned x, y, i, j;
|
||||
for(y = 0; y < height; y += 4) {
|
||||
const uint8_t *src = src_row;
|
||||
for(x = 0; x < width; x += 4) {
|
||||
for(j = 0; j < 4; ++j) {
|
||||
for(i = 0; i < 4; ++i) {
|
||||
uint8_t *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4;
|
||||
util_format_dxt1_rgb_fetch(0, src, i, j, dst);
|
||||
}
|
||||
}
|
||||
src += 8;
|
||||
}
|
||||
src_row += src_stride;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
if (util_format_dxt1_rgba_fetch) {
|
||||
unsigned x, y, i, j;
|
||||
for(y = 0; y < height; y += 4) {
|
||||
const uint8_t *src = src_row;
|
||||
for(x = 0; x < width; x += 4) {
|
||||
for(j = 0; j < 4; ++j) {
|
||||
for(i = 0; i < 4; ++i) {
|
||||
uint8_t *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4;
|
||||
util_format_dxt1_rgba_fetch(0, src, i, j, dst);
|
||||
}
|
||||
}
|
||||
src += 8;
|
||||
}
|
||||
src_row += src_stride;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -320,6 +351,28 @@ util_format_dxt5_rgba_unpack_float(float *dst_row, unsigned dst_stride, const ui
|
|||
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)
|
||||
{
|
||||
if (util_format_dxtn_pack) {
|
||||
unsigned x, y, i, j, k;
|
||||
for(y = 0; y < height; y += 4) {
|
||||
const uint8_t *src = src_row;
|
||||
uint8_t *dst = dst_row;
|
||||
for(x = 0; x < width; x += 4) {
|
||||
uint8_t tmp[4][4][3];
|
||||
for(j = 0; j < 4; ++j) {
|
||||
for(i = 0; i < 4; ++i) {
|
||||
for(k = 0; k < 3; ++k) {
|
||||
tmp[j][i][k] = src[(y + j)*src_stride/sizeof(*src) + i*4 + k];
|
||||
}
|
||||
}
|
||||
}
|
||||
util_format_dxtn_pack(3, 4, 4, src, UTIL_FORMAT_DXT1_RGB, dst, dst_stride);
|
||||
src += 4*4;
|
||||
dst += 8;
|
||||
}
|
||||
src_row += src_stride;
|
||||
dst_row += 4*dst_stride/sizeof(*dst_row);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in New Issue