+ util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src, src_stride,
+ width, height, UTIL_FORMAT_DXT5_RGBA,
+ 16, FALSE);
+}
+
+static INLINE void
+util_format_dxtn_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
+ const float *src, unsigned src_stride,
+ unsigned width, unsigned height,
+ enum util_format_dxtn format,
+ unsigned block_size, boolean srgb)
+{
+ unsigned x, y, i, j, k;
+ for(y = 0; y < height; y += 4) {
+ uint8_t *dst = dst_row;
+ for(x = 0; x < width; x += 4) {
+ uint8_t tmp[4][4][4];
+ for(j = 0; j < 4; ++j) {
+ for(i = 0; i < 4; ++i) {
+ float src_tmp;
+ for(k = 0; k < 3; ++k) {
+ src_tmp = src[(y + j)*src_stride/sizeof(*src) + (x+i)*4 + k];
+ if (srgb) {
+ tmp[j][i][k] = util_format_linear_float_to_srgb_8unorm(src_tmp);
+ }
+ else {
+ tmp[j][i][k] = float_to_ubyte(src_tmp);
+ }
+ }
+ /* for sake of simplicity there's an unneeded 4th component for dxt1_rgb */
+ src_tmp = src[(y + j)*src_stride/sizeof(*src) + (x+i)*4 + 3];
+ tmp[j][i][3] = float_to_ubyte(src_tmp);
+ }
+ }
+ util_format_dxtn_pack(4, 4, 4, &tmp[0][0][0], format, dst, 0);
+ dst += block_size;
+ }
+ dst_row += 4*dst_stride/sizeof(*dst_row);
+ }