util: Add support for other DXTn RGBA formats.
[mesa.git] / src / gallium / auxiliary / util / u_format_s3tc.c
1 /**************************************************************************
2 *
3 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
4 * Copyright (c) 2008 VMware, Inc.
5 *
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:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
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.
22 *
23 **************************************************************************/
24
25 #include "u_dl.h"
26 #include "u_math.h"
27 #include "u_format.h"
28 #include "u_format_s3tc.h"
29
30
31 #if defined(_WIN32) || defined(WIN32)
32 #define DXTN_LIBNAME "dxtn.dll"
33 #else
34 #define DXTN_LIBNAME "libtxc_dxtn.so"
35 #endif
36
37
38 boolean util_format_s3tc_enabled = FALSE;
39
40 util_format_dxtn_fetch_t util_format_dxt1_rgb_fetch = NULL;
41 util_format_dxtn_fetch_t util_format_dxt1_rgba_fetch = NULL;
42 util_format_dxtn_fetch_t util_format_dxt3_rgba_fetch = NULL;
43 util_format_dxtn_fetch_t util_format_dxt5_rgba_fetch = NULL;
44
45 util_format_dxtn_pack_t util_format_dxtn_pack = NULL;
46
47
48 void
49 util_format_s3tc_init(void)
50 {
51 static struct util_dl_library *
52 library = NULL;
53
54 if (util_format_s3tc_enabled)
55 return;
56
57 if (!library) {
58 library = util_dl_open(DXTN_LIBNAME);
59 if (!library) {
60 debug_printf("couldn't open " DXTN_LIBNAME ", software DXTn "
61 "compression/decompression unavailable");
62 }
63 else {
64 util_format_dxt1_rgb_fetch = (util_format_dxtn_fetch_t)
65 util_dl_get_proc_address(library, "fetch_2d_texel_rgb_dxt1");
66 util_format_dxt1_rgba_fetch = (util_format_dxtn_fetch_t)
67 util_dl_get_proc_address(library, "fetch_2d_texel_rgba_dxt1");
68 util_format_dxt3_rgba_fetch = (util_format_dxtn_fetch_t)
69 util_dl_get_proc_address(library, "fetch_2d_texel_rgba_dxt3");
70 util_format_dxt5_rgba_fetch = (util_format_dxtn_fetch_t)
71 util_dl_get_proc_address(library, "fetch_2d_texel_rgba_dxt5");
72 util_format_dxtn_pack = (util_format_dxtn_pack_t)
73 util_dl_get_proc_address(library, "tx_compress_dxtn");
74
75 if (util_format_dxt1_rgb_fetch ||
76 util_format_dxt1_rgba_fetch ||
77 util_format_dxt3_rgba_fetch ||
78 util_format_dxt5_rgba_fetch ||
79 util_format_dxtn_pack) {
80 util_format_s3tc_enabled = TRUE;
81 debug_printf("software DXTn compression/decompression available");
82
83 } else {
84 debug_printf("couldn't reference all symbols in "
85 DXTN_LIBNAME ", software DXTn compression/decompression "
86 "unavailable");
87 }
88 }
89 }
90 }
91
92
93 /*
94 * Pixel fetch.
95 */
96
97 void
98 util_format_dxt1_rgb_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
99 {
100 if (util_format_dxt1_rgb_fetch) {
101 util_format_dxt1_rgb_fetch(0, src, i, j, dst);
102 }
103 }
104
105 void
106 util_format_dxt1_rgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
107 {
108 if (util_format_dxt1_rgba_fetch) {
109 util_format_dxt1_rgba_fetch(0, src, i, j, dst);
110 }
111 }
112
113 void
114 util_format_dxt3_rgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
115 {
116 if (util_format_dxt3_rgba_fetch) {
117 util_format_dxt3_rgba_fetch(0, src, i, j, dst);
118 }
119 }
120
121 void
122 util_format_dxt5_rgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
123 {
124 if (util_format_dxt5_rgba_fetch) {
125 util_format_dxt5_rgba_fetch(0, src, i, j, dst);
126 }
127 }
128
129 void
130 util_format_dxt1_rgb_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
131 {
132 if (util_format_dxt1_rgb_fetch) {
133 uint8_t tmp[4];
134 util_format_dxt1_rgb_fetch(0, src, i, j, tmp);
135 dst[0] = ubyte_to_float(tmp[0]);
136 dst[1] = ubyte_to_float(tmp[1]);
137 dst[2] = ubyte_to_float(tmp[2]);
138 dst[3] = 1.0;
139 }
140 }
141
142 void
143 util_format_dxt1_rgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
144 {
145 if (util_format_dxt1_rgba_fetch) {
146 uint8_t tmp[4];
147 util_format_dxt1_rgba_fetch(0, src, i, j, tmp);
148 dst[0] = ubyte_to_float(tmp[0]);
149 dst[1] = ubyte_to_float(tmp[1]);
150 dst[2] = ubyte_to_float(tmp[2]);
151 dst[3] = ubyte_to_float(tmp[3]);
152 }
153 }
154
155 void
156 util_format_dxt3_rgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
157 {
158 if (util_format_dxt3_rgba_fetch) {
159 uint8_t tmp[4];
160 util_format_dxt3_rgba_fetch(0, src, i, j, tmp);
161 dst[0] = ubyte_to_float(tmp[0]);
162 dst[1] = ubyte_to_float(tmp[1]);
163 dst[2] = ubyte_to_float(tmp[2]);
164 dst[3] = ubyte_to_float(tmp[3]);
165 }
166 }
167
168 void
169 util_format_dxt5_rgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
170 {
171 if (util_format_dxt5_rgba_fetch) {
172 uint8_t tmp[4];
173 util_format_dxt5_rgba_fetch(0, src, i, j, tmp);
174 dst[0] = ubyte_to_float(tmp[0]);
175 dst[1] = ubyte_to_float(tmp[1]);
176 dst[2] = ubyte_to_float(tmp[2]);
177 dst[3] = ubyte_to_float(tmp[3]);
178 }
179 }
180
181
182 /*
183 * Block decompression.
184 */
185
186 void
187 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)
188 {
189 if (util_format_dxt1_rgb_fetch) {
190 unsigned x, y, i, j;
191 for(y = 0; y < height; y += 4) {
192 const uint8_t *src = src_row;
193 for(x = 0; x < width; x += 4) {
194 for(j = 0; j < 4; ++j) {
195 for(i = 0; i < 4; ++i) {
196 uint8_t *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4;
197 util_format_dxt1_rgb_fetch(0, src, i, j, dst);
198 }
199 }
200 src += 8;
201 }
202 src_row += src_stride;
203 }
204 }
205 }
206
207 void
208 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)
209 {
210 if (util_format_dxt1_rgba_fetch) {
211 unsigned x, y, i, j;
212 for(y = 0; y < height; y += 4) {
213 const uint8_t *src = src_row;
214 for(x = 0; x < width; x += 4) {
215 for(j = 0; j < 4; ++j) {
216 for(i = 0; i < 4; ++i) {
217 uint8_t *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4;
218 util_format_dxt1_rgba_fetch(0, src, i, j, dst);
219 }
220 }
221 src += 8;
222 }
223 src_row += src_stride;
224 }
225 }
226 }
227
228 void
229 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)
230 {
231 if (util_format_dxt3_rgba_fetch) {
232 unsigned x, y, i, j;
233 for(y = 0; y < height; y += 4) {
234 const uint8_t *src = src_row;
235 for(x = 0; x < width; x += 4) {
236 for(j = 0; j < 4; ++j) {
237 for(i = 0; i < 4; ++i) {
238 uint8_t *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4;
239 util_format_dxt3_rgba_fetch(0, src, i, j, dst);
240 }
241 }
242 src += 16;
243 }
244 src_row += src_stride;
245 }
246 }
247 }
248
249 void
250 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)
251 {
252 if (util_format_dxt5_rgba_fetch) {
253 unsigned x, y, i, j;
254 for(y = 0; y < height; y += 4) {
255 const uint8_t *src = src_row;
256 for(x = 0; x < width; x += 4) {
257 for(j = 0; j < 4; ++j) {
258 for(i = 0; i < 4; ++i) {
259 uint8_t *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4;
260 util_format_dxt5_rgba_fetch(0, src, i, j, dst);
261 }
262 }
263 src += 16;
264 }
265 src_row += src_stride;
266 }
267 }
268 }
269
270 void
271 util_format_dxt1_rgb_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
272 {
273 if (util_format_dxt1_rgb_fetch) {
274 unsigned x, y, i, j;
275 for(y = 0; y < height; y += 4) {
276 const uint8_t *src = src_row;
277 for(x = 0; x < width; x += 4) {
278 for(j = 0; j < 4; ++j) {
279 for(i = 0; i < 4; ++i) {
280 float *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4;
281 uint8_t tmp[4];
282 util_format_dxt1_rgb_fetch(0, src, i, j, tmp);
283 dst[0] = ubyte_to_float(tmp[0]);
284 dst[1] = ubyte_to_float(tmp[1]);
285 dst[2] = ubyte_to_float(tmp[2]);
286 dst[3] = 1.0;
287 }
288 }
289 src += 8;
290 }
291 src_row += src_stride;
292 }
293 }
294 }
295
296 void
297 util_format_dxt1_rgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
298 {
299 if (util_format_dxt1_rgba_fetch) {
300 unsigned x, y, i, j;
301 for(y = 0; y < height; y += 4) {
302 const uint8_t *src = src_row;
303 for(x = 0; x < width; x += 4) {
304 for(j = 0; j < 4; ++j) {
305 for(i = 0; i < 4; ++i) {
306 float *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4;
307 uint8_t tmp[4];
308 util_format_dxt1_rgba_fetch(0, src, i, j, tmp);
309 dst[0] = ubyte_to_float(tmp[0]);
310 dst[1] = ubyte_to_float(tmp[1]);
311 dst[2] = ubyte_to_float(tmp[2]);
312 dst[3] = ubyte_to_float(tmp[3]);
313 }
314 }
315 src += 8;
316 }
317 src_row += src_stride;
318 }
319 }
320 }
321
322 void
323 util_format_dxt3_rgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
324 {
325 if (util_format_dxt3_rgba_fetch) {
326 unsigned x, y, i, j;
327 for(y = 0; y < height; y += 4) {
328 const uint8_t *src = src_row;
329 for(x = 0; x < width; x += 4) {
330 for(j = 0; j < 4; ++j) {
331 for(i = 0; i < 4; ++i) {
332 float *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4;
333 uint8_t tmp[4];
334 util_format_dxt3_rgba_fetch(0, src, i, j, tmp);
335 dst[0] = ubyte_to_float(tmp[0]);
336 dst[1] = ubyte_to_float(tmp[1]);
337 dst[2] = ubyte_to_float(tmp[2]);
338 dst[3] = ubyte_to_float(tmp[3]);
339 }
340 }
341 src += 16;
342 }
343 src_row += src_stride;
344 }
345 }
346 }
347
348 void
349 util_format_dxt5_rgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
350 {
351 if (util_format_dxt5_rgba_fetch) {
352 unsigned x, y, i, j;
353 for(y = 0; y < height; y += 4) {
354 const uint8_t *src = src_row;
355 for(x = 0; x < width; x += 4) {
356 for(j = 0; j < 4; ++j) {
357 for(i = 0; i < 4; ++i) {
358 float *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4;
359 uint8_t tmp[4];
360 util_format_dxt5_rgba_fetch(0, src, i, j, tmp);
361 dst[0] = ubyte_to_float(tmp[0]);
362 dst[1] = ubyte_to_float(tmp[1]);
363 dst[2] = ubyte_to_float(tmp[2]);
364 dst[3] = ubyte_to_float(tmp[3]);
365 }
366 }
367 src += 16;
368 }
369 src_row += src_stride;
370 }
371 }
372 }
373
374
375 /*
376 * Block compression.
377 */
378
379 void
380 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)
381 {
382 if (util_format_dxtn_pack) {
383 unsigned x, y, i, j, k;
384 for(y = 0; y < height; y += 4) {
385 const uint8_t *src = src_row;
386 uint8_t *dst = dst_row;
387 for(x = 0; x < width; x += 4) {
388 uint8_t tmp[4][4][3];
389 for(j = 0; j < 4; ++j) {
390 for(i = 0; i < 4; ++i) {
391 for(k = 0; k < 3; ++k) {
392 tmp[j][i][k] = src[(y + j)*src_stride/sizeof(*src) + i*4 + k];
393 }
394 }
395 }
396 util_format_dxtn_pack(3, 4, 4, &tmp[0][0][0], UTIL_FORMAT_DXT1_RGB, dst, dst_stride);
397 src += 4*4;
398 dst += 8;
399 }
400 src_row += src_stride;
401 dst_row += 4*dst_stride/sizeof(*dst_row);
402 }
403 }
404 }
405
406 void
407 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)
408 {
409 if (util_format_dxtn_pack) {
410 unsigned x, y, i, j, k;
411 for(y = 0; y < height; y += 4) {
412 const uint8_t *src = src_row;
413 uint8_t *dst = dst_row;
414 for(x = 0; x < width; x += 4) {
415 uint8_t tmp[4][4][4];
416 for(j = 0; j < 4; ++j) {
417 for(i = 0; i < 4; ++i) {
418 for(k = 0; k < 4; ++k) {
419 tmp[j][i][k] = src[(y + j)*src_stride/sizeof(*src) + i*4 + k];
420 }
421 }
422 }
423 util_format_dxtn_pack(4, 4, 4, &tmp[0][0][0], UTIL_FORMAT_DXT1_RGBA, dst, dst_stride);
424 src += 4*4;
425 dst += 8;
426 }
427 src_row += src_stride;
428 dst_row += 4*dst_stride/sizeof(*dst_row);
429 }
430 }
431 }
432
433 void
434 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)
435 {
436 if (util_format_dxtn_pack) {
437 unsigned x, y, i, j, k;
438 for(y = 0; y < height; y += 4) {
439 const uint8_t *src = src_row;
440 uint8_t *dst = dst_row;
441 for(x = 0; x < width; x += 4) {
442 uint8_t tmp[4][4][4];
443 for(j = 0; j < 4; ++j) {
444 for(i = 0; i < 4; ++i) {
445 for(k = 0; k < 4; ++k) {
446 tmp[j][i][k] = src[(y + j)*src_stride/sizeof(*src) + i*4 + k];
447 }
448 }
449 }
450 util_format_dxtn_pack(4, 4, 4, &tmp[0][0][0], UTIL_FORMAT_DXT3_RGBA, dst, dst_stride);
451 src += 4*4;
452 dst += 16;
453 }
454 src_row += src_stride;
455 dst_row += 4*dst_stride/sizeof(*dst_row);
456 }
457 }
458 }
459
460 void
461 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)
462 {
463 if (util_format_dxtn_pack) {
464 unsigned x, y, i, j, k;
465 for(y = 0; y < height; y += 4) {
466 const uint8_t *src = src_row;
467 uint8_t *dst = dst_row;
468 for(x = 0; x < width; x += 4) {
469 uint8_t tmp[4][4][4];
470 for(j = 0; j < 4; ++j) {
471 for(i = 0; i < 4; ++i) {
472 for(k = 0; k < 4; ++k) {
473 tmp[j][i][k] = src[(y + j)*src_stride/sizeof(*src) + i*4 + k];
474 }
475 }
476 }
477 util_format_dxtn_pack(4, 4, 4, &tmp[0][0][0], UTIL_FORMAT_DXT5_RGBA, dst, dst_stride);
478 src += 4*4;
479 dst += 16;
480 }
481 src_row += src_stride;
482 dst_row += 4*dst_stride/sizeof(*dst_row);
483 }
484 }
485 }
486
487 void
488 util_format_dxt1_rgb_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
489 {
490 if (util_format_dxtn_pack) {
491 unsigned x, y, i, j, k;
492 for(y = 0; y < height; y += 4) {
493 const float *src = src_row;
494 uint8_t *dst = dst_row;
495 for(x = 0; x < width; x += 4) {
496 uint8_t tmp[4][4][3];
497 for(j = 0; j < 4; ++j) {
498 for(i = 0; i < 4; ++i) {
499 for(k = 0; k < 3; ++k) {
500 tmp[j][i][k] = float_to_ubyte(src[(y + j)*src_stride/sizeof(*src) + i*4 + k]);
501 }
502 }
503 }
504 util_format_dxtn_pack(3, 4, 4, &tmp[0][0][0], UTIL_FORMAT_DXT1_RGB, dst, dst_stride);
505 src += 4*4;
506 dst += 8;
507 }
508 src_row += src_stride;
509 dst_row += 4*dst_stride/sizeof(*dst_row);
510 }
511 }
512 }
513
514 void
515 util_format_dxt1_rgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
516 {
517 if (util_format_dxtn_pack) {
518 unsigned x, y, i, j, k;
519 for(y = 0; y < height; y += 4) {
520 const float *src = src_row;
521 uint8_t *dst = dst_row;
522 for(x = 0; x < width; x += 4) {
523 uint8_t tmp[4][4][4];
524 for(j = 0; j < 4; ++j) {
525 for(i = 0; i < 4; ++i) {
526 for(k = 0; k < 4; ++k) {
527 tmp[j][i][k] = float_to_ubyte(src[(y + j)*src_stride/sizeof(*src) + i*4 + k]);
528 }
529 }
530 }
531 util_format_dxtn_pack(4, 4, 4, &tmp[0][0][0], UTIL_FORMAT_DXT1_RGBA, dst, dst_stride);
532 src += 4*4;
533 dst += 8;
534 }
535 src_row += src_stride;
536 dst_row += 4*dst_stride/sizeof(*dst_row);
537 }
538 }
539 }
540
541 void
542 util_format_dxt3_rgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
543 {
544 if (util_format_dxtn_pack) {
545 unsigned x, y, i, j, k;
546 for(y = 0; y < height; y += 4) {
547 const float *src = src_row;
548 uint8_t *dst = dst_row;
549 for(x = 0; x < width; x += 4) {
550 uint8_t tmp[4][4][4];
551 for(j = 0; j < 4; ++j) {
552 for(i = 0; i < 4; ++i) {
553 for(k = 0; k < 4; ++k) {
554 tmp[j][i][k] = float_to_ubyte(src[(y + j)*src_stride/sizeof(*src) + i*4 + k]);
555 }
556 }
557 }
558 util_format_dxtn_pack(4, 4, 4, &tmp[0][0][0], UTIL_FORMAT_DXT3_RGBA, dst, dst_stride);
559 src += 4*4;
560 dst += 16;
561 }
562 src_row += src_stride;
563 dst_row += 4*dst_stride/sizeof(*dst_row);
564 }
565 }
566 }
567
568 void
569 util_format_dxt5_rgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
570 {
571 if (util_format_dxtn_pack) {
572 unsigned x, y, i, j, k;
573 for(y = 0; y < height; y += 4) {
574 const float *src = src_row;
575 uint8_t *dst = dst_row;
576 for(x = 0; x < width; x += 4) {
577 uint8_t tmp[4][4][4];
578 for(j = 0; j < 4; ++j) {
579 for(i = 0; i < 4; ++i) {
580 for(k = 0; k < 4; ++k) {
581 tmp[j][i][k] = float_to_ubyte(src[(y + j)*src_stride/sizeof(*src) + i*4 + k]);
582 }
583 }
584 }
585 util_format_dxtn_pack(4, 4, 4, &tmp[0][0][0], UTIL_FORMAT_DXT5_RGBA, dst, dst_stride);
586 src += 4*4;
587 dst += 16;
588 }
589 src_row += src_stride;
590 dst_row += 4*dst_stride/sizeof(*dst_row);
591 }
592 }
593 }
594
595
596 /*
597 * SRGB variants.
598 *
599 * FIXME: shunts to RGB for now
600 */
601
602 void
603 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)
604 {
605 util_format_dxt1_rgb_unpack_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
606 }
607
608 void
609 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)
610 {
611 util_format_dxt1_rgb_pack_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
612 }
613
614 void
615 util_format_dxt1_srgb_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
616 {
617 util_format_dxt1_rgb_fetch_8unorm(dst, src, i, j);
618 }
619
620 void
621 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)
622 {
623 util_format_dxt1_rgba_unpack_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
624 }
625
626 void
627 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)
628 {
629 util_format_dxt1_rgba_pack_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
630 }
631
632 void
633 util_format_dxt1_srgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
634 {
635 util_format_dxt1_rgba_fetch_8unorm(dst, src, i, j);
636 }
637
638 void
639 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)
640 {
641 util_format_dxt3_rgba_unpack_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
642 }
643
644 void
645 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)
646 {
647 util_format_dxt3_rgba_pack_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
648 }
649
650 void
651 util_format_dxt3_srgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
652 {
653 util_format_dxt3_rgba_fetch_8unorm(dst, src, i, j);
654 }
655
656 void
657 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)
658 {
659 util_format_dxt5_rgba_unpack_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
660 }
661
662 void
663 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)
664 {
665 util_format_dxt5_rgba_pack_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
666 }
667
668 void
669 util_format_dxt5_srgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
670 {
671 util_format_dxt5_rgba_fetch_8unorm(dst, src, i, j);
672 }
673
674 void
675 util_format_dxt1_srgb_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
676 {
677 util_format_dxt1_rgb_unpack_float(dst_row, dst_stride, src_row, src_stride, width, height);
678 }
679
680 void
681 util_format_dxt1_srgb_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
682 {
683 util_format_dxt1_rgb_pack_float(dst_row, dst_stride, src_row, src_stride, width, height);
684 }
685
686 void
687 util_format_dxt1_srgb_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
688 {
689 util_format_dxt1_rgb_fetch_float(dst, src, i, j);
690 }
691
692 void
693 util_format_dxt1_srgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
694 {
695 util_format_dxt1_rgba_unpack_float(dst_row, dst_stride, src_row, src_stride, width, height);
696 }
697
698 void
699 util_format_dxt1_srgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
700 {
701 util_format_dxt1_rgba_pack_float(dst_row, dst_stride, src_row, src_stride, width, height);
702 }
703
704 void
705 util_format_dxt1_srgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
706 {
707 util_format_dxt1_rgba_fetch_float(dst, src, i, j);
708 }
709
710 void
711 util_format_dxt3_srgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
712 {
713 util_format_dxt3_rgba_unpack_float(dst_row, dst_stride, src_row, src_stride, width, height);
714 }
715
716 void
717 util_format_dxt3_srgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
718 {
719 util_format_dxt3_rgba_pack_float(dst_row, dst_stride, src_row, src_stride, width, height);
720 }
721
722 void
723 util_format_dxt3_srgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
724 {
725 util_format_dxt3_rgba_fetch_float(dst, src, i, j);
726 }
727
728 void
729 util_format_dxt5_srgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
730 {
731 util_format_dxt5_rgba_unpack_float(dst_row, dst_stride, src_row, src_stride, width, height);
732 }
733
734 void
735 util_format_dxt5_srgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
736 {
737 util_format_dxt5_rgba_pack_float(dst_row, dst_stride, src_row, src_stride, width, height);
738 }
739
740 void
741 util_format_dxt5_srgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
742 {
743 util_format_dxt5_rgba_fetch_float(dst, src, i, j);
744 }
745