static inline void util_format_dxtn_rgb_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height, util_format_dxtn_fetch_t fetch, unsigned block_size, boolean srgb) { 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) { float *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4; uint8_t tmp[4]; fetch(0, src, i, j, tmp); if (srgb) { dst[0] = util_format_srgb_8unorm_to_linear_float(tmp[0]); dst[1] = util_format_srgb_8unorm_to_linear_float(tmp[1]); dst[2] = util_format_srgb_8unorm_to_linear_float(tmp[2]); } else { dst[0] = ubyte_to_float(tmp[0]); dst[1] = ubyte_to_float(tmp[1]); dst[2] = ubyte_to_float(tmp[2]); } dst[3] = ubyte_to_float(tmp[3]); } } src += block_size; } src_row += src_stride; } }
void util_format_dxt5_srgba_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); dst[0] = util_format_srgb_8unorm_to_linear_float(tmp[0]); dst[1] = util_format_srgb_8unorm_to_linear_float(tmp[1]); dst[2] = util_format_srgb_8unorm_to_linear_float(tmp[2]); dst[3] = ubyte_to_float(tmp[3]); }
static void fetch_srgba_dxt5(const GLubyte *map, GLint rowStride, GLint i, GLint j, GLfloat *texel) { if (fetch_ext_rgba_dxt5) { GLubyte tex[4]; fetch_ext_rgba_dxt5(rowStride, map, i, j, tex); texel[RCOMP] = util_format_srgb_8unorm_to_linear_float(tex[RCOMP]); texel[GCOMP] = util_format_srgb_8unorm_to_linear_float(tex[GCOMP]); texel[BCOMP] = util_format_srgb_8unorm_to_linear_float(tex[BCOMP]); texel[ACOMP] = UBYTE_TO_FLOAT(tex[ACOMP]); } else { problem("srgba_dxt5"); } }