mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-09 01:50:12 +01:00
util/format: implement rgtc -> r8 / r8g8 unpack
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Acked-by: Eric Engestrom <eric@igalia.com> Tested-by: Eric Engestrom <eric@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18248>
This commit is contained in:
parent
dfbcd94041
commit
a6ed406d9f
2 changed files with 114 additions and 0 deletions
|
|
@ -37,6 +37,30 @@ util_format_rgtc1_unorm_fetch_rgba_8unorm(uint8_t *restrict dst, const uint8_t *
|
|||
dst[3] = 255;
|
||||
}
|
||||
|
||||
void
|
||||
util_format_rgtc1_unorm_unpack_r_8unorm(uint8_t *restrict dst_row, unsigned dst_stride, const uint8_t *restrict src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||
{
|
||||
const unsigned bw = 4, bh = 4, comps = 1;
|
||||
unsigned x, y, i, j;
|
||||
unsigned block_size = 8;
|
||||
|
||||
for(y = 0; y < height; y += bh) {
|
||||
const uint8_t *src = src_row;
|
||||
const unsigned h = MIN2(height - y, bh);
|
||||
for(x = 0; x < width; x += bw) {
|
||||
const unsigned w = MIN2(width - x, bw);
|
||||
for(j = 0; j < h; ++j) {
|
||||
for(i = 0; i < w; ++i) {
|
||||
uint8_t *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*comps;
|
||||
util_format_unsigned_fetch_texel_rgtc(0, src, i, j, dst, 1);
|
||||
}
|
||||
}
|
||||
src += block_size;
|
||||
}
|
||||
src_row += src_stride;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
util_format_rgtc1_unorm_unpack_rgba_8unorm(uint8_t *restrict dst_row, unsigned dst_stride, const uint8_t *restrict src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||
{
|
||||
|
|
@ -163,6 +187,32 @@ util_format_rgtc1_snorm_unpack_rgba_8unorm(UNUSED uint8_t *restrict dst_row, UNU
|
|||
fprintf(stderr,"%s\n", __func__);
|
||||
}
|
||||
|
||||
void
|
||||
util_format_rgtc1_snorm_unpack_r_8snorm(int8_t *restrict dst_row, unsigned dst_stride,
|
||||
const uint8_t *restrict src_row, unsigned src_stride,
|
||||
unsigned width, unsigned height)
|
||||
{
|
||||
const unsigned bw = 4, bh = 4, comps = 1;
|
||||
unsigned x, y, i, j;
|
||||
unsigned block_size = 8;
|
||||
|
||||
for(y = 0; y < height; y += bh) {
|
||||
const uint8_t *src = src_row;
|
||||
const unsigned h = MIN2(height - y, bh);
|
||||
for(x = 0; x < width; x += bw) {
|
||||
const unsigned w = MIN2(width - x, bw);
|
||||
for(j = 0; j < h; ++j) {
|
||||
for(i = 0; i < w; ++i) {
|
||||
int8_t *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*comps;
|
||||
util_format_signed_fetch_texel_rgtc(0, (const int8_t *)src, i, j, dst, 1);
|
||||
}
|
||||
}
|
||||
src += block_size;
|
||||
}
|
||||
src_row += src_stride;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
util_format_rgtc1_snorm_pack_rgba_8unorm(UNUSED uint8_t *restrict dst_row, UNUSED unsigned dst_stride,
|
||||
UNUSED const uint8_t *restrict src_row, UNUSED unsigned src_stride,
|
||||
|
|
@ -242,6 +292,31 @@ util_format_rgtc2_unorm_fetch_rgba_8unorm(uint8_t *restrict dst, const uint8_t *
|
|||
dst[3] = 255;
|
||||
}
|
||||
|
||||
void
|
||||
util_format_rgtc2_unorm_unpack_rg_8unorm(uint8_t *restrict dst_row, unsigned dst_stride, const uint8_t *restrict src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||
{
|
||||
const unsigned bw = 4, bh = 4, comps = 2;
|
||||
unsigned x, y, i, j;
|
||||
unsigned block_size = 16;
|
||||
|
||||
for(y = 0; y < height; y += bh) {
|
||||
const uint8_t *src = src_row;
|
||||
const unsigned h = MIN2(height - y, bh);
|
||||
for(x = 0; x < width; x += bw) {
|
||||
const unsigned w = MIN2(width - x, bw);
|
||||
for(j = 0; j < h; ++j) {
|
||||
for(i = 0; i < w; ++i) {
|
||||
uint8_t *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*comps;
|
||||
util_format_unsigned_fetch_texel_rgtc(0, src, i, j, dst, 2);
|
||||
util_format_unsigned_fetch_texel_rgtc(0, src + 8, i, j, dst + 1, 2);
|
||||
}
|
||||
}
|
||||
src += block_size;
|
||||
}
|
||||
src_row += src_stride;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
util_format_rgtc2_unorm_unpack_rgba_8unorm(uint8_t *restrict dst_row, unsigned dst_stride, const uint8_t *restrict src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||
{
|
||||
|
|
@ -382,6 +457,33 @@ util_format_rgtc2_snorm_unpack_rgba_8unorm(UNUSED uint8_t *restrict dst_row, UNU
|
|||
fprintf(stderr,"%s\n", __func__);
|
||||
}
|
||||
|
||||
void
|
||||
util_format_rgtc2_snorm_unpack_rg_8snorm(int8_t *restrict dst_row, unsigned dst_stride,
|
||||
const uint8_t *restrict src_row, unsigned src_stride,
|
||||
unsigned width, unsigned height)
|
||||
{
|
||||
const unsigned bw = 4, bh = 4, comps = 2;
|
||||
unsigned x, y, i, j;
|
||||
unsigned block_size = 16;
|
||||
|
||||
for(y = 0; y < height; y += bh) {
|
||||
const uint8_t *src = src_row;
|
||||
const unsigned h = MIN2(height - y, bh);
|
||||
for(x = 0; x < width; x += bw) {
|
||||
const unsigned w = MIN2(width - x, bw);
|
||||
for(j = 0; j < h; ++j) {
|
||||
for(i = 0; i < w; ++i) {
|
||||
int8_t *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*comps;
|
||||
util_format_signed_fetch_texel_rgtc(0, (const int8_t *)src, i, j, (int8_t *)dst, 2);
|
||||
util_format_signed_fetch_texel_rgtc(0, (const int8_t *)src + 8, i, j, (int8_t *)dst + 1, 2);
|
||||
}
|
||||
}
|
||||
src += block_size;
|
||||
}
|
||||
src_row += src_stride;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
util_format_rgtc2_snorm_pack_rgba_8unorm(UNUSED uint8_t *restrict dst_row, UNUSED unsigned dst_stride,
|
||||
UNUSED const uint8_t *restrict src_row, UNUSED unsigned src_stride,
|
||||
|
|
|
|||
|
|
@ -33,6 +33,9 @@
|
|||
void
|
||||
util_format_rgtc1_unorm_fetch_rgba_8unorm(uint8_t *restrict dst, const uint8_t *restrict src, unsigned i, unsigned j);
|
||||
|
||||
void
|
||||
util_format_rgtc1_unorm_unpack_r_8unorm(uint8_t *restrict dst_row, unsigned dst_stride, const uint8_t *restrict src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
void
|
||||
util_format_rgtc1_unorm_unpack_rgba_8unorm(uint8_t *restrict dst_row, unsigned dst_stride, const uint8_t *restrict src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
|
|
@ -56,6 +59,9 @@ util_format_rgtc1_snorm_fetch_rgba_8unorm(uint8_t *restrict dst, const uint8_t *
|
|||
void
|
||||
util_format_rgtc1_snorm_unpack_rgba_8unorm(uint8_t *restrict dst_row, unsigned dst_stride, const uint8_t *restrict src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
void
|
||||
util_format_rgtc1_snorm_unpack_r_8snorm(int8_t *restrict dst_row, unsigned dst_stride, const uint8_t *restrict src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
void
|
||||
util_format_rgtc1_snorm_pack_rgba_8unorm(uint8_t *restrict dst_row, unsigned dst_stride, const uint8_t *restrict src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
|
|
@ -72,6 +78,9 @@ util_format_rgtc1_snorm_fetch_rgba(void *restrict dst, const uint8_t *restrict s
|
|||
void
|
||||
util_format_rgtc2_unorm_fetch_rgba_8unorm(uint8_t *restrict dst, const uint8_t *restrict src, unsigned i, unsigned j);
|
||||
|
||||
void
|
||||
util_format_rgtc2_unorm_unpack_rg_8unorm(uint8_t *restrict dst_row, unsigned dst_stride, const uint8_t *restrict src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
void
|
||||
util_format_rgtc2_unorm_unpack_rgba_8unorm(uint8_t *restrict dst_row, unsigned dst_stride, const uint8_t *restrict src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
|
|
@ -97,6 +106,9 @@ util_format_rgtc2_snorm_fetch_rgba_8unorm(uint8_t *restrict dst, const uint8_t *
|
|||
void
|
||||
util_format_rgtc2_snorm_unpack_rgba_8unorm(uint8_t *restrict dst_row, unsigned dst_stride, const uint8_t *restrict src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
void
|
||||
util_format_rgtc2_snorm_unpack_rg_8snorm(int8_t *restrict dst_row, unsigned dst_stride, const uint8_t *restrict src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
void
|
||||
util_format_rgtc2_snorm_pack_rgba_8unorm(uint8_t *restrict dst_row, unsigned dst_stride, const uint8_t *restrict src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue