void util_format_rgtc2_unorm_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; int block_size = 16; 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) { float *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4; uint8_t tmp_r, tmp_g; util_format_unsigned_fetch_texel_rgtc(0, src, i, j, &tmp_r, 2); util_format_unsigned_fetch_texel_rgtc(0, src + 8, i, j, &tmp_g, 2); dst[0] = ubyte_to_float(tmp_r); dst[1] = ubyte_to_float(tmp_g); dst[2] = 0.0; dst[3] = 1.0; } } src += block_size; } src_row += src_stride; } }
void util_format_rgtc2_unorm_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j) { 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); dst[2] = 0; dst[3] = 255; }
void util_format_rgtc2_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) { uint8_t tmp_r, tmp_g; util_format_unsigned_fetch_texel_rgtc(0, src, i, j, &tmp_r, 2); util_format_unsigned_fetch_texel_rgtc(0, src + 8, i, j, &tmp_g, 2); dst[0] = ubyte_to_float(tmp_r); dst[1] = ubyte_to_float(tmp_g); dst[2] = 0.0; dst[3] = 1.0; }
static void fetch_la_latc2(const GLubyte *map, GLint rowStride, GLint i, GLint j, GLfloat *texel) { GLubyte red, green; util_format_unsigned_fetch_texel_rgtc(rowStride, map, i, j, &red, 2); util_format_unsigned_fetch_texel_rgtc(rowStride, map + 8, i, j, &green, 2); texel[RCOMP] = texel[GCOMP] = texel[BCOMP] = UBYTE_TO_FLOAT(red); texel[ACOMP] = UBYTE_TO_FLOAT(green); }
static void fetch_l_latc1(const GLubyte *map, GLint rowStride, GLint i, GLint j, GLfloat *texel) { GLubyte red; util_format_unsigned_fetch_texel_rgtc(rowStride, map, i, j, &red, 1); texel[RCOMP] = texel[GCOMP] = texel[BCOMP] = UBYTE_TO_FLOAT(red); texel[ACOMP] = 1.0; }
void util_format_rgtc2_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { const unsigned bw = 4, bh = 4, comps = 4; unsigned x, y, i, j; unsigned block_size = 16; for(y = 0; y < height; y += bh) { const uint8_t *src = src_row; for(x = 0; x < width; x += bw) { for(j = 0; j < bh; ++j) { for(i = 0; i < bw; ++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); dst[2] = 0; dst[3] = 255; } } src += block_size; } src_row += src_stride; } }