1 /**************************************************************************
3 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
4 * Copyright (c) 2008 VMware, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 **************************************************************************/
28 #include "u_format_s3tc.h"
31 #if defined(_WIN32) || defined(WIN32)
32 #define DXTN_LIBNAME "dxtn.dll"
34 #define DXTN_LIBNAME "libtxc_dxtn.so"
38 util_format_dxt1_rgb_fetch_stub( int src_stride
,
43 util_format_s3tc_init();
44 util_format_dxt1_rgb_fetch(src_stride
, src
, col
, row
, dst
);
48 util_format_dxt1_rgba_fetch_stub( int src_stride
,
53 util_format_s3tc_init();
54 util_format_dxt1_rgba_fetch(src_stride
, src
, col
, row
, dst
);
58 util_format_dxt3_rgba_fetch_stub( int src_stride
,
63 util_format_s3tc_init();
64 util_format_dxt3_rgba_fetch(src_stride
, src
, col
, row
, dst
);
68 util_format_dxt5_rgba_fetch_stub( int src_stride
,
73 util_format_s3tc_init();
74 util_format_dxt5_rgba_fetch(src_stride
, src
, col
, row
, dst
);
78 void util_format_dxtn_pack_stub( int src_comps
,
79 int width
, int height
,
81 enum util_format_dxtn dst_format
,
85 util_format_s3tc_init();
86 util_format_dxtn_pack_stub(src_comps
, width
, height
, src
, dst_format
, dst
, dst_stride
);
89 boolean util_format_s3tc_enabled
= FALSE
;
90 boolean util_format_s3tc_inited
= FALSE
;
92 util_format_dxtn_fetch_t util_format_dxt1_rgb_fetch
= util_format_dxt1_rgb_fetch_stub
;
93 util_format_dxtn_fetch_t util_format_dxt1_rgba_fetch
= util_format_dxt1_rgba_fetch_stub
;
94 util_format_dxtn_fetch_t util_format_dxt3_rgba_fetch
= util_format_dxt3_rgba_fetch_stub
;
95 util_format_dxtn_fetch_t util_format_dxt5_rgba_fetch
= util_format_dxt5_rgba_fetch_stub
;
97 util_format_dxtn_pack_t util_format_dxtn_pack
= util_format_dxtn_pack_stub
;
103 #define is_nop(f) ((void*)(f) == (void*)nop)
106 get_proc_address_or_nop(struct util_dl_library
*library
,
107 const char *procname
)
110 util_dl_proc proc
= util_dl_get_proc_address(library
, procname
);
114 return (util_dl_proc
)nop
;
118 util_format_s3tc_do_init(void)
120 struct util_dl_library
*library
;
122 library
= util_dl_open(DXTN_LIBNAME
);
123 util_format_dxt1_rgb_fetch
= (util_format_dxtn_fetch_t
)
124 get_proc_address_or_nop(library
, "fetch_2d_texel_rgb_dxt1");
125 util_format_dxt1_rgba_fetch
= (util_format_dxtn_fetch_t
)
126 get_proc_address_or_nop(library
, "fetch_2d_texel_rgba_dxt1");
127 util_format_dxt3_rgba_fetch
= (util_format_dxtn_fetch_t
)
128 get_proc_address_or_nop(library
, "fetch_2d_texel_rgba_dxt3");
129 util_format_dxt5_rgba_fetch
= (util_format_dxtn_fetch_t
)
130 get_proc_address_or_nop(library
, "fetch_2d_texel_rgba_dxt5");
131 util_format_dxtn_pack
= (util_format_dxtn_pack_t
)
132 get_proc_address_or_nop(library
, "tx_compress_dxtn");
135 debug_printf("couldn't open " DXTN_LIBNAME
", software DXTn "
136 "compression/decompression unavailable");
138 if (!is_nop(util_format_dxt1_rgb_fetch
) &&
139 !is_nop(util_format_dxt1_rgba_fetch
) &&
140 !is_nop(util_format_dxt3_rgba_fetch
) &&
141 !is_nop(util_format_dxt5_rgba_fetch
) &&
142 !is_nop(util_format_dxtn_pack
)) {
143 debug_printf("software DXTn compression/decompression available");
144 util_format_s3tc_enabled
= TRUE
;
146 debug_printf("couldn't reference all symbols in "
147 DXTN_LIBNAME
", software DXTn compression/decompression "
158 util_format_dxt1_rgb_fetch_8unorm(uint8_t *dst
, const uint8_t *src
, unsigned i
, unsigned j
)
160 util_format_dxt1_rgb_fetch(0, src
, i
, j
, dst
);
164 util_format_dxt1_rgba_fetch_8unorm(uint8_t *dst
, const uint8_t *src
, unsigned i
, unsigned j
)
166 util_format_dxt1_rgba_fetch(0, src
, i
, j
, dst
);
170 util_format_dxt3_rgba_fetch_8unorm(uint8_t *dst
, const uint8_t *src
, unsigned i
, unsigned j
)
172 util_format_dxt3_rgba_fetch(0, src
, i
, j
, dst
);
176 util_format_dxt5_rgba_fetch_8unorm(uint8_t *dst
, const uint8_t *src
, unsigned i
, unsigned j
)
178 util_format_dxt5_rgba_fetch(0, src
, i
, j
, dst
);
182 util_format_dxt1_rgb_fetch_float(float *dst
, const uint8_t *src
, unsigned i
, unsigned j
)
185 util_format_dxt1_rgb_fetch(0, src
, i
, j
, tmp
);
186 dst
[0] = ubyte_to_float(tmp
[0]);
187 dst
[1] = ubyte_to_float(tmp
[1]);
188 dst
[2] = ubyte_to_float(tmp
[2]);
193 util_format_dxt1_rgba_fetch_float(float *dst
, const uint8_t *src
, unsigned i
, unsigned j
)
196 util_format_dxt1_rgba_fetch(0, src
, i
, j
, tmp
);
197 dst
[0] = ubyte_to_float(tmp
[0]);
198 dst
[1] = ubyte_to_float(tmp
[1]);
199 dst
[2] = ubyte_to_float(tmp
[2]);
200 dst
[3] = ubyte_to_float(tmp
[3]);
204 util_format_dxt3_rgba_fetch_float(float *dst
, const uint8_t *src
, unsigned i
, unsigned j
)
207 util_format_dxt3_rgba_fetch(0, src
, i
, j
, tmp
);
208 dst
[0] = ubyte_to_float(tmp
[0]);
209 dst
[1] = ubyte_to_float(tmp
[1]);
210 dst
[2] = ubyte_to_float(tmp
[2]);
211 dst
[3] = ubyte_to_float(tmp
[3]);
215 util_format_dxt5_rgba_fetch_float(float *dst
, const uint8_t *src
, unsigned i
, unsigned j
)
218 util_format_dxt5_rgba_fetch(0, src
, i
, j
, tmp
);
219 dst
[0] = ubyte_to_float(tmp
[0]);
220 dst
[1] = ubyte_to_float(tmp
[1]);
221 dst
[2] = ubyte_to_float(tmp
[2]);
222 dst
[3] = ubyte_to_float(tmp
[3]);
227 * Block decompression.
231 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
)
233 if (!is_nop(util_format_dxt1_rgb_fetch
)) {
235 for(y
= 0; y
< height
; y
+= 4) {
236 const uint8_t *src
= src_row
;
237 for(x
= 0; x
< width
; x
+= 4) {
238 for(j
= 0; j
< 4; ++j
) {
239 for(i
= 0; i
< 4; ++i
) {
240 uint8_t *dst
= dst_row
+ (y
+ j
)*dst_stride
/sizeof(*dst_row
) + (x
+ i
)*4;
241 util_format_dxt1_rgb_fetch(0, src
, i
, j
, dst
);
246 src_row
+= src_stride
;
252 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
)
254 if (!is_nop(util_format_dxt1_rgba_fetch
)) {
256 for(y
= 0; y
< height
; y
+= 4) {
257 const uint8_t *src
= src_row
;
258 for(x
= 0; x
< width
; x
+= 4) {
259 for(j
= 0; j
< 4; ++j
) {
260 for(i
= 0; i
< 4; ++i
) {
261 uint8_t *dst
= dst_row
+ (y
+ j
)*dst_stride
/sizeof(*dst_row
) + (x
+ i
)*4;
262 util_format_dxt1_rgba_fetch(0, src
, i
, j
, dst
);
267 src_row
+= src_stride
;
273 util_format_dxt3_rgba_unpack_8unorm(uint8_t *dst_row
, unsigned dst_stride
, const uint8_t *src_row
, unsigned src_stride
, unsigned width
, unsigned height
)
275 if (!is_nop(util_format_dxt3_rgba_fetch
)) {
277 for(y
= 0; y
< height
; y
+= 4) {
278 const uint8_t *src
= src_row
;
279 for(x
= 0; x
< width
; x
+= 4) {
280 for(j
= 0; j
< 4; ++j
) {
281 for(i
= 0; i
< 4; ++i
) {
282 uint8_t *dst
= dst_row
+ (y
+ j
)*dst_stride
/sizeof(*dst_row
) + (x
+ i
)*4;
283 util_format_dxt3_rgba_fetch(0, src
, i
, j
, dst
);
288 src_row
+= src_stride
;
294 util_format_dxt5_rgba_unpack_8unorm(uint8_t *dst_row
, unsigned dst_stride
, const uint8_t *src_row
, unsigned src_stride
, unsigned width
, unsigned height
)
296 if (is_nop(util_format_dxt5_rgba_fetch
)) {
298 for(y
= 0; y
< height
; y
+= 4) {
299 const uint8_t *src
= src_row
;
300 for(x
= 0; x
< width
; x
+= 4) {
301 for(j
= 0; j
< 4; ++j
) {
302 for(i
= 0; i
< 4; ++i
) {
303 uint8_t *dst
= dst_row
+ (y
+ j
)*dst_stride
/sizeof(*dst_row
) + (x
+ i
)*4;
304 util_format_dxt5_rgba_fetch(0, src
, i
, j
, dst
);
309 src_row
+= src_stride
;
315 util_format_dxt1_rgb_unpack_float(float *dst_row
, unsigned dst_stride
, const uint8_t *src_row
, unsigned src_stride
, unsigned width
, unsigned height
)
317 if (is_nop(util_format_dxt1_rgb_fetch
)) {
319 for(y
= 0; y
< height
; y
+= 4) {
320 const uint8_t *src
= src_row
;
321 for(x
= 0; x
< width
; x
+= 4) {
322 for(j
= 0; j
< 4; ++j
) {
323 for(i
= 0; i
< 4; ++i
) {
324 float *dst
= dst_row
+ (y
+ j
)*dst_stride
/sizeof(*dst_row
) + (x
+ i
)*4;
326 util_format_dxt1_rgb_fetch(0, src
, i
, j
, tmp
);
327 dst
[0] = ubyte_to_float(tmp
[0]);
328 dst
[1] = ubyte_to_float(tmp
[1]);
329 dst
[2] = ubyte_to_float(tmp
[2]);
335 src_row
+= src_stride
;
341 util_format_dxt1_rgba_unpack_float(float *dst_row
, unsigned dst_stride
, const uint8_t *src_row
, unsigned src_stride
, unsigned width
, unsigned height
)
343 if (!is_nop(util_format_dxt1_rgba_fetch
)) {
345 for(y
= 0; y
< height
; y
+= 4) {
346 const uint8_t *src
= src_row
;
347 for(x
= 0; x
< width
; x
+= 4) {
348 for(j
= 0; j
< 4; ++j
) {
349 for(i
= 0; i
< 4; ++i
) {
350 float *dst
= dst_row
+ (y
+ j
)*dst_stride
/sizeof(*dst_row
) + (x
+ i
)*4;
352 util_format_dxt1_rgba_fetch(0, src
, i
, j
, tmp
);
353 dst
[0] = ubyte_to_float(tmp
[0]);
354 dst
[1] = ubyte_to_float(tmp
[1]);
355 dst
[2] = ubyte_to_float(tmp
[2]);
356 dst
[3] = ubyte_to_float(tmp
[3]);
361 src_row
+= src_stride
;
367 util_format_dxt3_rgba_unpack_float(float *dst_row
, unsigned dst_stride
, const uint8_t *src_row
, unsigned src_stride
, unsigned width
, unsigned height
)
369 if (!is_nop(util_format_dxt3_rgba_fetch
)) {
371 for(y
= 0; y
< height
; y
+= 4) {
372 const uint8_t *src
= src_row
;
373 for(x
= 0; x
< width
; x
+= 4) {
374 for(j
= 0; j
< 4; ++j
) {
375 for(i
= 0; i
< 4; ++i
) {
376 float *dst
= dst_row
+ (y
+ j
)*dst_stride
/sizeof(*dst_row
) + (x
+ i
)*4;
378 util_format_dxt3_rgba_fetch(0, src
, i
, j
, tmp
);
379 dst
[0] = ubyte_to_float(tmp
[0]);
380 dst
[1] = ubyte_to_float(tmp
[1]);
381 dst
[2] = ubyte_to_float(tmp
[2]);
382 dst
[3] = ubyte_to_float(tmp
[3]);
387 src_row
+= src_stride
;
393 util_format_dxt5_rgba_unpack_float(float *dst_row
, unsigned dst_stride
, const uint8_t *src_row
, unsigned src_stride
, unsigned width
, unsigned height
)
395 if (!is_nop(util_format_dxt5_rgba_fetch
)) {
397 for(y
= 0; y
< height
; y
+= 4) {
398 const uint8_t *src
= src_row
;
399 for(x
= 0; x
< width
; x
+= 4) {
400 for(j
= 0; j
< 4; ++j
) {
401 for(i
= 0; i
< 4; ++i
) {
402 float *dst
= dst_row
+ (y
+ j
)*dst_stride
/sizeof(*dst_row
) + (x
+ i
)*4;
404 util_format_dxt5_rgba_fetch(0, src
, i
, j
, tmp
);
405 dst
[0] = ubyte_to_float(tmp
[0]);
406 dst
[1] = ubyte_to_float(tmp
[1]);
407 dst
[2] = ubyte_to_float(tmp
[2]);
408 dst
[3] = ubyte_to_float(tmp
[3]);
413 src_row
+= src_stride
;
424 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
)
426 if (!is_nop(util_format_dxtn_pack
)) {
427 unsigned x
, y
, i
, j
, k
;
428 for(y
= 0; y
< height
; y
+= 4) {
429 const uint8_t *src
= src_row
;
430 uint8_t *dst
= dst_row
;
431 for(x
= 0; x
< width
; x
+= 4) {
432 uint8_t tmp
[4][4][3];
433 for(j
= 0; j
< 4; ++j
) {
434 for(i
= 0; i
< 4; ++i
) {
435 for(k
= 0; k
< 3; ++k
) {
436 tmp
[j
][i
][k
] = src
[(y
+ j
)*src_stride
/sizeof(*src
) + i
*4 + k
];
440 util_format_dxtn_pack(3, 4, 4, &tmp
[0][0][0], UTIL_FORMAT_DXT1_RGB
, dst
, dst_stride
);
444 src_row
+= src_stride
;
445 dst_row
+= 4*dst_stride
/sizeof(*dst_row
);
451 util_format_dxt1_rgba_pack_8unorm(uint8_t *dst_row
, unsigned dst_stride
, const uint8_t *src_row
, unsigned src_stride
, unsigned width
, unsigned height
)
453 if (!is_nop(util_format_dxtn_pack
)) {
454 unsigned x
, y
, i
, j
, k
;
455 for(y
= 0; y
< height
; y
+= 4) {
456 const uint8_t *src
= src_row
;
457 uint8_t *dst
= dst_row
;
458 for(x
= 0; x
< width
; x
+= 4) {
459 uint8_t tmp
[4][4][4];
460 for(j
= 0; j
< 4; ++j
) {
461 for(i
= 0; i
< 4; ++i
) {
462 for(k
= 0; k
< 4; ++k
) {
463 tmp
[j
][i
][k
] = src
[(y
+ j
)*src_stride
/sizeof(*src
) + i
*4 + k
];
467 util_format_dxtn_pack(4, 4, 4, &tmp
[0][0][0], UTIL_FORMAT_DXT1_RGBA
, dst
, dst_stride
);
471 src_row
+= src_stride
;
472 dst_row
+= 4*dst_stride
/sizeof(*dst_row
);
478 util_format_dxt3_rgba_pack_8unorm(uint8_t *dst_row
, unsigned dst_stride
, const uint8_t *src_row
, unsigned src_stride
, unsigned width
, unsigned height
)
480 if (!is_nop(util_format_dxtn_pack
)) {
481 unsigned x
, y
, i
, j
, k
;
482 for(y
= 0; y
< height
; y
+= 4) {
483 const uint8_t *src
= src_row
;
484 uint8_t *dst
= dst_row
;
485 for(x
= 0; x
< width
; x
+= 4) {
486 uint8_t tmp
[4][4][4];
487 for(j
= 0; j
< 4; ++j
) {
488 for(i
= 0; i
< 4; ++i
) {
489 for(k
= 0; k
< 4; ++k
) {
490 tmp
[j
][i
][k
] = src
[(y
+ j
)*src_stride
/sizeof(*src
) + i
*4 + k
];
494 util_format_dxtn_pack(4, 4, 4, &tmp
[0][0][0], UTIL_FORMAT_DXT3_RGBA
, dst
, dst_stride
);
498 src_row
+= src_stride
;
499 dst_row
+= 4*dst_stride
/sizeof(*dst_row
);
505 util_format_dxt5_rgba_pack_8unorm(uint8_t *dst_row
, unsigned dst_stride
, const uint8_t *src_row
, unsigned src_stride
, unsigned width
, unsigned height
)
507 if (!is_nop(util_format_dxtn_pack
)) {
508 unsigned x
, y
, i
, j
, k
;
509 for(y
= 0; y
< height
; y
+= 4) {
510 const uint8_t *src
= src_row
;
511 uint8_t *dst
= dst_row
;
512 for(x
= 0; x
< width
; x
+= 4) {
513 uint8_t tmp
[4][4][4];
514 for(j
= 0; j
< 4; ++j
) {
515 for(i
= 0; i
< 4; ++i
) {
516 for(k
= 0; k
< 4; ++k
) {
517 tmp
[j
][i
][k
] = src
[(y
+ j
)*src_stride
/sizeof(*src
) + i
*4 + k
];
521 util_format_dxtn_pack(4, 4, 4, &tmp
[0][0][0], UTIL_FORMAT_DXT5_RGBA
, dst
, dst_stride
);
525 src_row
+= src_stride
;
526 dst_row
+= 4*dst_stride
/sizeof(*dst_row
);
532 util_format_dxt1_rgb_pack_float(uint8_t *dst_row
, unsigned dst_stride
, const float *src_row
, unsigned src_stride
, unsigned width
, unsigned height
)
534 if (!is_nop(util_format_dxtn_pack
)) {
535 unsigned x
, y
, i
, j
, k
;
536 for(y
= 0; y
< height
; y
+= 4) {
537 const float *src
= src_row
;
538 uint8_t *dst
= dst_row
;
539 for(x
= 0; x
< width
; x
+= 4) {
540 uint8_t tmp
[4][4][3];
541 for(j
= 0; j
< 4; ++j
) {
542 for(i
= 0; i
< 4; ++i
) {
543 for(k
= 0; k
< 3; ++k
) {
544 tmp
[j
][i
][k
] = float_to_ubyte(src
[(y
+ j
)*src_stride
/sizeof(*src
) + i
*4 + k
]);
548 util_format_dxtn_pack(3, 4, 4, &tmp
[0][0][0], UTIL_FORMAT_DXT1_RGB
, dst
, dst_stride
);
552 src_row
+= src_stride
;
553 dst_row
+= 4*dst_stride
/sizeof(*dst_row
);
559 util_format_dxt1_rgba_pack_float(uint8_t *dst_row
, unsigned dst_stride
, const float *src_row
, unsigned src_stride
, unsigned width
, unsigned height
)
561 if (!is_nop(util_format_dxtn_pack
)) {
562 unsigned x
, y
, i
, j
, k
;
563 for(y
= 0; y
< height
; y
+= 4) {
564 const float *src
= src_row
;
565 uint8_t *dst
= dst_row
;
566 for(x
= 0; x
< width
; x
+= 4) {
567 uint8_t tmp
[4][4][4];
568 for(j
= 0; j
< 4; ++j
) {
569 for(i
= 0; i
< 4; ++i
) {
570 for(k
= 0; k
< 4; ++k
) {
571 tmp
[j
][i
][k
] = float_to_ubyte(src
[(y
+ j
)*src_stride
/sizeof(*src
) + i
*4 + k
]);
575 util_format_dxtn_pack(4, 4, 4, &tmp
[0][0][0], UTIL_FORMAT_DXT1_RGBA
, dst
, dst_stride
);
579 src_row
+= src_stride
;
580 dst_row
+= 4*dst_stride
/sizeof(*dst_row
);
586 util_format_dxt3_rgba_pack_float(uint8_t *dst_row
, unsigned dst_stride
, const float *src_row
, unsigned src_stride
, unsigned width
, unsigned height
)
588 if (!is_nop(util_format_dxtn_pack
)) {
589 unsigned x
, y
, i
, j
, k
;
590 for(y
= 0; y
< height
; y
+= 4) {
591 const float *src
= src_row
;
592 uint8_t *dst
= dst_row
;
593 for(x
= 0; x
< width
; x
+= 4) {
594 uint8_t tmp
[4][4][4];
595 for(j
= 0; j
< 4; ++j
) {
596 for(i
= 0; i
< 4; ++i
) {
597 for(k
= 0; k
< 4; ++k
) {
598 tmp
[j
][i
][k
] = float_to_ubyte(src
[(y
+ j
)*src_stride
/sizeof(*src
) + i
*4 + k
]);
602 util_format_dxtn_pack(4, 4, 4, &tmp
[0][0][0], UTIL_FORMAT_DXT3_RGBA
, dst
, dst_stride
);
606 src_row
+= src_stride
;
607 dst_row
+= 4*dst_stride
/sizeof(*dst_row
);
613 util_format_dxt5_rgba_pack_float(uint8_t *dst_row
, unsigned dst_stride
, const float *src_row
, unsigned src_stride
, unsigned width
, unsigned height
)
615 if (!is_nop(util_format_dxtn_pack
)) {
616 unsigned x
, y
, i
, j
, k
;
617 for(y
= 0; y
< height
; y
+= 4) {
618 const float *src
= src_row
;
619 uint8_t *dst
= dst_row
;
620 for(x
= 0; x
< width
; x
+= 4) {
621 uint8_t tmp
[4][4][4];
622 for(j
= 0; j
< 4; ++j
) {
623 for(i
= 0; i
< 4; ++i
) {
624 for(k
= 0; k
< 4; ++k
) {
625 tmp
[j
][i
][k
] = float_to_ubyte(src
[(y
+ j
)*src_stride
/sizeof(*src
) + i
*4 + k
]);
629 util_format_dxtn_pack(4, 4, 4, &tmp
[0][0][0], UTIL_FORMAT_DXT5_RGBA
, dst
, dst_stride
);
633 src_row
+= src_stride
;
634 dst_row
+= 4*dst_stride
/sizeof(*dst_row
);
643 * FIXME: shunts to RGB for now
647 util_format_dxt1_srgb_unpack_8unorm(uint8_t *dst_row
, unsigned dst_stride
, const uint8_t *src_row
, unsigned src_stride
, unsigned width
, unsigned height
)
649 util_format_dxt1_rgb_unpack_8unorm(dst_row
, dst_stride
, src_row
, src_stride
, width
, height
);
653 util_format_dxt1_srgb_pack_8unorm(uint8_t *dst_row
, unsigned dst_stride
, const uint8_t *src_row
, unsigned src_stride
, unsigned width
, unsigned height
)
655 util_format_dxt1_rgb_pack_8unorm(dst_row
, dst_stride
, src_row
, src_stride
, width
, height
);
659 util_format_dxt1_srgb_fetch_8unorm(uint8_t *dst
, const uint8_t *src
, unsigned i
, unsigned j
)
661 util_format_dxt1_rgb_fetch_8unorm(dst
, src
, i
, j
);
665 util_format_dxt1_srgba_unpack_8unorm(uint8_t *dst_row
, unsigned dst_stride
, const uint8_t *src_row
, unsigned src_stride
, unsigned width
, unsigned height
)
667 util_format_dxt1_rgba_unpack_8unorm(dst_row
, dst_stride
, src_row
, src_stride
, width
, height
);
671 util_format_dxt1_srgba_pack_8unorm(uint8_t *dst_row
, unsigned dst_stride
, const uint8_t *src_row
, unsigned src_stride
, unsigned width
, unsigned height
)
673 util_format_dxt1_rgba_pack_8unorm(dst_row
, dst_stride
, src_row
, src_stride
, width
, height
);
677 util_format_dxt1_srgba_fetch_8unorm(uint8_t *dst
, const uint8_t *src
, unsigned i
, unsigned j
)
679 util_format_dxt1_rgba_fetch_8unorm(dst
, src
, i
, j
);
683 util_format_dxt3_srgba_unpack_8unorm(uint8_t *dst_row
, unsigned dst_stride
, const uint8_t *src_row
, unsigned src_stride
, unsigned width
, unsigned height
)
685 util_format_dxt3_rgba_unpack_8unorm(dst_row
, dst_stride
, src_row
, src_stride
, width
, height
);
689 util_format_dxt3_srgba_pack_8unorm(uint8_t *dst_row
, unsigned dst_stride
, const uint8_t *src_row
, unsigned src_stride
, unsigned width
, unsigned height
)
691 util_format_dxt3_rgba_pack_8unorm(dst_row
, dst_stride
, src_row
, src_stride
, width
, height
);
695 util_format_dxt3_srgba_fetch_8unorm(uint8_t *dst
, const uint8_t *src
, unsigned i
, unsigned j
)
697 util_format_dxt3_rgba_fetch_8unorm(dst
, src
, i
, j
);
701 util_format_dxt5_srgba_unpack_8unorm(uint8_t *dst_row
, unsigned dst_stride
, const uint8_t *src_row
, unsigned src_stride
, unsigned width
, unsigned height
)
703 util_format_dxt5_rgba_unpack_8unorm(dst_row
, dst_stride
, src_row
, src_stride
, width
, height
);
707 util_format_dxt5_srgba_pack_8unorm(uint8_t *dst_row
, unsigned dst_stride
, const uint8_t *src_row
, unsigned src_stride
, unsigned width
, unsigned height
)
709 util_format_dxt5_rgba_pack_8unorm(dst_row
, dst_stride
, src_row
, src_stride
, width
, height
);
713 util_format_dxt5_srgba_fetch_8unorm(uint8_t *dst
, const uint8_t *src
, unsigned i
, unsigned j
)
715 util_format_dxt5_rgba_fetch_8unorm(dst
, src
, i
, j
);
719 util_format_dxt1_srgb_unpack_float(float *dst_row
, unsigned dst_stride
, const uint8_t *src_row
, unsigned src_stride
, unsigned width
, unsigned height
)
721 util_format_dxt1_rgb_unpack_float(dst_row
, dst_stride
, src_row
, src_stride
, width
, height
);
725 util_format_dxt1_srgb_pack_float(uint8_t *dst_row
, unsigned dst_stride
, const float *src_row
, unsigned src_stride
, unsigned width
, unsigned height
)
727 util_format_dxt1_rgb_pack_float(dst_row
, dst_stride
, src_row
, src_stride
, width
, height
);
731 util_format_dxt1_srgb_fetch_float(float *dst
, const uint8_t *src
, unsigned i
, unsigned j
)
733 util_format_dxt1_rgb_fetch_float(dst
, src
, i
, j
);
737 util_format_dxt1_srgba_unpack_float(float *dst_row
, unsigned dst_stride
, const uint8_t *src_row
, unsigned src_stride
, unsigned width
, unsigned height
)
739 util_format_dxt1_rgba_unpack_float(dst_row
, dst_stride
, src_row
, src_stride
, width
, height
);
743 util_format_dxt1_srgba_pack_float(uint8_t *dst_row
, unsigned dst_stride
, const float *src_row
, unsigned src_stride
, unsigned width
, unsigned height
)
745 util_format_dxt1_rgba_pack_float(dst_row
, dst_stride
, src_row
, src_stride
, width
, height
);
749 util_format_dxt1_srgba_fetch_float(float *dst
, const uint8_t *src
, unsigned i
, unsigned j
)
751 util_format_dxt1_rgba_fetch_float(dst
, src
, i
, j
);
755 util_format_dxt3_srgba_unpack_float(float *dst_row
, unsigned dst_stride
, const uint8_t *src_row
, unsigned src_stride
, unsigned width
, unsigned height
)
757 util_format_dxt3_rgba_unpack_float(dst_row
, dst_stride
, src_row
, src_stride
, width
, height
);
761 util_format_dxt3_srgba_pack_float(uint8_t *dst_row
, unsigned dst_stride
, const float *src_row
, unsigned src_stride
, unsigned width
, unsigned height
)
763 util_format_dxt3_rgba_pack_float(dst_row
, dst_stride
, src_row
, src_stride
, width
, height
);
767 util_format_dxt3_srgba_fetch_float(float *dst
, const uint8_t *src
, unsigned i
, unsigned j
)
769 util_format_dxt3_rgba_fetch_float(dst
, src
, i
, j
);
773 util_format_dxt5_srgba_unpack_float(float *dst_row
, unsigned dst_stride
, const uint8_t *src_row
, unsigned src_stride
, unsigned width
, unsigned height
)
775 util_format_dxt5_rgba_unpack_float(dst_row
, dst_stride
, src_row
, src_stride
, width
, height
);
779 util_format_dxt5_srgba_pack_float(uint8_t *dst_row
, unsigned dst_stride
, const float *src_row
, unsigned src_stride
, unsigned width
, unsigned height
)
781 util_format_dxt5_rgba_pack_float(dst_row
, dst_stride
, src_row
, src_stride
, width
, height
);
785 util_format_dxt5_srgba_fetch_float(float *dst
, const uint8_t *src
, unsigned i
, unsigned j
)
787 util_format_dxt5_rgba_fetch_float(dst
, src
, i
, j
);