util: Move gallium's PIPE_FORMAT utils to /util/format/
[mesa.git] / src / util / format / 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 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
23 *
24 **************************************************************************/
25
26 #include "util/format/u_format.h"
27 #include "util/format/u_format_s3tc.h"
28 #include "util/format_srgb.h"
29 #include "util/u_math.h"
30 #include "../../mesa/main/texcompress_s3tc_tmp.h"
31
32
33 util_format_dxtn_fetch_t util_format_dxt1_rgb_fetch = (util_format_dxtn_fetch_t)fetch_2d_texel_rgb_dxt1;
34 util_format_dxtn_fetch_t util_format_dxt1_rgba_fetch = (util_format_dxtn_fetch_t)fetch_2d_texel_rgba_dxt1;
35 util_format_dxtn_fetch_t util_format_dxt3_rgba_fetch = (util_format_dxtn_fetch_t)fetch_2d_texel_rgba_dxt3;
36 util_format_dxtn_fetch_t util_format_dxt5_rgba_fetch = (util_format_dxtn_fetch_t)fetch_2d_texel_rgba_dxt5;
37
38 util_format_dxtn_pack_t util_format_dxtn_pack = (util_format_dxtn_pack_t)tx_compress_dxtn;
39
40
41 /*
42 * Pixel fetch.
43 */
44
45 void
46 util_format_dxt1_rgb_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
47 {
48 util_format_dxt1_rgb_fetch(0, src, i, j, dst);
49 }
50
51 void
52 util_format_dxt1_rgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
53 {
54 util_format_dxt1_rgba_fetch(0, src, i, j, dst);
55 }
56
57 void
58 util_format_dxt3_rgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
59 {
60 util_format_dxt3_rgba_fetch(0, src, i, j, dst);
61 }
62
63 void
64 util_format_dxt5_rgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
65 {
66 util_format_dxt5_rgba_fetch(0, src, i, j, dst);
67 }
68
69 void
70 util_format_dxt1_rgb_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
71 {
72 uint8_t tmp[4];
73 util_format_dxt1_rgb_fetch(0, src, i, j, tmp);
74 dst[0] = ubyte_to_float(tmp[0]);
75 dst[1] = ubyte_to_float(tmp[1]);
76 dst[2] = ubyte_to_float(tmp[2]);
77 dst[3] = 1.0;
78 }
79
80 void
81 util_format_dxt1_rgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
82 {
83 uint8_t tmp[4];
84 util_format_dxt1_rgba_fetch(0, src, i, j, tmp);
85 dst[0] = ubyte_to_float(tmp[0]);
86 dst[1] = ubyte_to_float(tmp[1]);
87 dst[2] = ubyte_to_float(tmp[2]);
88 dst[3] = ubyte_to_float(tmp[3]);
89 }
90
91 void
92 util_format_dxt3_rgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
93 {
94 uint8_t tmp[4];
95 util_format_dxt3_rgba_fetch(0, src, i, j, tmp);
96 dst[0] = ubyte_to_float(tmp[0]);
97 dst[1] = ubyte_to_float(tmp[1]);
98 dst[2] = ubyte_to_float(tmp[2]);
99 dst[3] = ubyte_to_float(tmp[3]);
100 }
101
102 void
103 util_format_dxt5_rgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
104 {
105 uint8_t tmp[4];
106 util_format_dxt5_rgba_fetch(0, src, i, j, tmp);
107 dst[0] = ubyte_to_float(tmp[0]);
108 dst[1] = ubyte_to_float(tmp[1]);
109 dst[2] = ubyte_to_float(tmp[2]);
110 dst[3] = ubyte_to_float(tmp[3]);
111 }
112
113
114 /*
115 * Block decompression.
116 */
117
118 static inline void
119 util_format_dxtn_rgb_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
120 const uint8_t *src_row, unsigned src_stride,
121 unsigned width, unsigned height,
122 util_format_dxtn_fetch_t fetch,
123 unsigned block_size, boolean srgb)
124 {
125 const unsigned bw = 4, bh = 4, comps = 4;
126 unsigned x, y, i, j;
127 for(y = 0; y < height; y += bh) {
128 const uint8_t *src = src_row;
129 for(x = 0; x < width; x += bw) {
130 for(j = 0; j < bh; ++j) {
131 for(i = 0; i < bw; ++i) {
132 uint8_t *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*comps;
133 fetch(0, src, i, j, dst);
134 if (srgb) {
135 dst[0] = util_format_srgb_to_linear_8unorm(dst[0]);
136 dst[1] = util_format_srgb_to_linear_8unorm(dst[1]);
137 dst[2] = util_format_srgb_to_linear_8unorm(dst[2]);
138 }
139 }
140 }
141 src += block_size;
142 }
143 src_row += src_stride;
144 }
145 }
146
147 void
148 util_format_dxt1_rgb_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
149 const uint8_t *src_row, unsigned src_stride,
150 unsigned width, unsigned height)
151 {
152 util_format_dxtn_rgb_unpack_rgba_8unorm(dst_row, dst_stride,
153 src_row, src_stride,
154 width, height,
155 util_format_dxt1_rgb_fetch,
156 8, FALSE);
157 }
158
159 void
160 util_format_dxt1_rgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
161 const uint8_t *src_row, unsigned src_stride,
162 unsigned width, unsigned height)
163 {
164 util_format_dxtn_rgb_unpack_rgba_8unorm(dst_row, dst_stride,
165 src_row, src_stride,
166 width, height,
167 util_format_dxt1_rgba_fetch,
168 8, FALSE);
169 }
170
171 void
172 util_format_dxt3_rgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
173 const uint8_t *src_row, unsigned src_stride,
174 unsigned width, unsigned height)
175 {
176 util_format_dxtn_rgb_unpack_rgba_8unorm(dst_row, dst_stride,
177 src_row, src_stride,
178 width, height,
179 util_format_dxt3_rgba_fetch,
180 16, FALSE);
181 }
182
183 void
184 util_format_dxt5_rgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
185 const uint8_t *src_row, unsigned src_stride,
186 unsigned width, unsigned height)
187 {
188 util_format_dxtn_rgb_unpack_rgba_8unorm(dst_row, dst_stride,
189 src_row, src_stride,
190 width, height,
191 util_format_dxt5_rgba_fetch,
192 16, FALSE);
193 }
194
195 static inline void
196 util_format_dxtn_rgb_unpack_rgba_float(float *dst_row, unsigned dst_stride,
197 const uint8_t *src_row, unsigned src_stride,
198 unsigned width, unsigned height,
199 util_format_dxtn_fetch_t fetch,
200 unsigned block_size, boolean srgb)
201 {
202 unsigned x, y, i, j;
203 for(y = 0; y < height; y += 4) {
204 const uint8_t *src = src_row;
205 for(x = 0; x < width; x += 4) {
206 for(j = 0; j < 4; ++j) {
207 for(i = 0; i < 4; ++i) {
208 float *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4;
209 uint8_t tmp[4];
210 fetch(0, src, i, j, tmp);
211 if (srgb) {
212 dst[0] = util_format_srgb_8unorm_to_linear_float(tmp[0]);
213 dst[1] = util_format_srgb_8unorm_to_linear_float(tmp[1]);
214 dst[2] = util_format_srgb_8unorm_to_linear_float(tmp[2]);
215 }
216 else {
217 dst[0] = ubyte_to_float(tmp[0]);
218 dst[1] = ubyte_to_float(tmp[1]);
219 dst[2] = ubyte_to_float(tmp[2]);
220 }
221 dst[3] = ubyte_to_float(tmp[3]);
222 }
223 }
224 src += block_size;
225 }
226 src_row += src_stride;
227 }
228 }
229
230 void
231 util_format_dxt1_rgb_unpack_rgba_float(float *dst_row, unsigned dst_stride,
232 const uint8_t *src_row, unsigned src_stride,
233 unsigned width, unsigned height)
234 {
235 util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride,
236 src_row, src_stride,
237 width, height,
238 util_format_dxt1_rgb_fetch,
239 8, FALSE);
240 }
241
242 void
243 util_format_dxt1_rgba_unpack_rgba_float(float *dst_row, unsigned dst_stride,
244 const uint8_t *src_row, unsigned src_stride,
245 unsigned width, unsigned height)
246 {
247 util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride,
248 src_row, src_stride,
249 width, height,
250 util_format_dxt1_rgba_fetch,
251 8, FALSE);
252 }
253
254 void
255 util_format_dxt3_rgba_unpack_rgba_float(float *dst_row, unsigned dst_stride,
256 const uint8_t *src_row, unsigned src_stride,
257 unsigned width, unsigned height)
258 {
259 util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride,
260 src_row, src_stride,
261 width, height,
262 util_format_dxt3_rgba_fetch,
263 16, FALSE);
264 }
265
266 void
267 util_format_dxt5_rgba_unpack_rgba_float(float *dst_row, unsigned dst_stride,
268 const uint8_t *src_row, unsigned src_stride,
269 unsigned width, unsigned height)
270 {
271 util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride,
272 src_row, src_stride,
273 width, height,
274 util_format_dxt5_rgba_fetch,
275 16, FALSE);
276 }
277
278
279 /*
280 * Block compression.
281 */
282
283 static inline void
284 util_format_dxtn_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
285 const uint8_t *src, unsigned src_stride,
286 unsigned width, unsigned height,
287 enum util_format_dxtn format,
288 unsigned block_size, boolean srgb)
289 {
290 const unsigned bw = 4, bh = 4, comps = 4;
291 unsigned x, y, i, j, k;
292 for(y = 0; y < height; y += bh) {
293 uint8_t *dst = dst_row;
294 for(x = 0; x < width; x += bw) {
295 uint8_t tmp[4][4][4]; /* [bh][bw][comps] */
296 for(j = 0; j < bh; ++j) {
297 for(i = 0; i < bw; ++i) {
298 uint8_t src_tmp;
299 for(k = 0; k < 3; ++k) {
300 src_tmp = src[(y + j)*src_stride/sizeof(*src) + (x+i)*comps + k];
301 if (srgb) {
302 tmp[j][i][k] = util_format_linear_to_srgb_8unorm(src_tmp);
303 }
304 else {
305 tmp[j][i][k] = src_tmp;
306 }
307 }
308 /* for sake of simplicity there's an unneeded 4th component for dxt1_rgb */
309 tmp[j][i][3] = src[(y + j)*src_stride/sizeof(*src) + (x+i)*comps + 3];
310 }
311 }
312 /* even for dxt1_rgb have 4 src comps */
313 util_format_dxtn_pack(4, 4, 4, &tmp[0][0][0], format, dst, 0);
314 dst += block_size;
315 }
316 dst_row += dst_stride / sizeof(*dst_row);
317 }
318
319 }
320
321 void
322 util_format_dxt1_rgb_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
323 const uint8_t *src, unsigned src_stride,
324 unsigned width, unsigned height)
325 {
326 util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src, src_stride,
327 width, height, UTIL_FORMAT_DXT1_RGB,
328 8, FALSE);
329 }
330
331 void
332 util_format_dxt1_rgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
333 const uint8_t *src, unsigned src_stride,
334 unsigned width, unsigned height)
335 {
336 util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src, src_stride,
337 width, height, UTIL_FORMAT_DXT1_RGBA,
338 8, FALSE);
339 }
340
341 void
342 util_format_dxt3_rgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
343 const uint8_t *src, unsigned src_stride,
344 unsigned width, unsigned height)
345 {
346 util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src, src_stride,
347 width, height, UTIL_FORMAT_DXT3_RGBA,
348 16, FALSE);
349 }
350
351 void
352 util_format_dxt5_rgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
353 const uint8_t *src, unsigned src_stride,
354 unsigned width, unsigned height)
355 {
356 util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src, src_stride,
357 width, height, UTIL_FORMAT_DXT5_RGBA,
358 16, FALSE);
359 }
360
361 static inline void
362 util_format_dxtn_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
363 const float *src, unsigned src_stride,
364 unsigned width, unsigned height,
365 enum util_format_dxtn format,
366 unsigned block_size, boolean srgb)
367 {
368 unsigned x, y, i, j, k;
369 for(y = 0; y < height; y += 4) {
370 uint8_t *dst = dst_row;
371 for(x = 0; x < width; x += 4) {
372 uint8_t tmp[4][4][4];
373 for(j = 0; j < 4; ++j) {
374 for(i = 0; i < 4; ++i) {
375 float src_tmp;
376 for(k = 0; k < 3; ++k) {
377 src_tmp = src[(y + j)*src_stride/sizeof(*src) + (x+i)*4 + k];
378 if (srgb) {
379 tmp[j][i][k] = util_format_linear_float_to_srgb_8unorm(src_tmp);
380 }
381 else {
382 tmp[j][i][k] = float_to_ubyte(src_tmp);
383 }
384 }
385 /* for sake of simplicity there's an unneeded 4th component for dxt1_rgb */
386 src_tmp = src[(y + j)*src_stride/sizeof(*src) + (x+i)*4 + 3];
387 tmp[j][i][3] = float_to_ubyte(src_tmp);
388 }
389 }
390 util_format_dxtn_pack(4, 4, 4, &tmp[0][0][0], format, dst, 0);
391 dst += block_size;
392 }
393 dst_row += 4*dst_stride/sizeof(*dst_row);
394 }
395 }
396
397 void
398 util_format_dxt1_rgb_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
399 const float *src, unsigned src_stride,
400 unsigned width, unsigned height)
401 {
402 util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src, src_stride,
403 width, height, UTIL_FORMAT_DXT1_RGB,
404 8, FALSE);
405 }
406
407 void
408 util_format_dxt1_rgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
409 const float *src, unsigned src_stride,
410 unsigned width, unsigned height)
411 {
412 util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src, src_stride,
413 width, height, UTIL_FORMAT_DXT1_RGBA,
414 8, FALSE);
415 }
416
417 void
418 util_format_dxt3_rgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
419 const float *src, unsigned src_stride,
420 unsigned width, unsigned height)
421 {
422 util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src, src_stride,
423 width, height, UTIL_FORMAT_DXT3_RGBA,
424 16, FALSE);
425 }
426
427 void
428 util_format_dxt5_rgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
429 const float *src, unsigned src_stride,
430 unsigned width, unsigned height)
431 {
432 util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src, src_stride,
433 width, height, UTIL_FORMAT_DXT5_RGBA,
434 16, FALSE);
435 }
436
437
438 /*
439 * SRGB variants.
440 */
441
442 void
443 util_format_dxt1_srgb_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
444 {
445 uint8_t tmp[4];
446 util_format_dxt1_rgb_fetch(0, src, i, j, tmp);
447 dst[0] = util_format_srgb_to_linear_8unorm(tmp[0]);
448 dst[1] = util_format_srgb_to_linear_8unorm(tmp[1]);
449 dst[2] = util_format_srgb_to_linear_8unorm(tmp[2]);
450 dst[3] = 255;
451 }
452
453 void
454 util_format_dxt1_srgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
455 {
456 uint8_t tmp[4];
457 util_format_dxt1_rgba_fetch(0, src, i, j, tmp);
458 dst[0] = util_format_srgb_to_linear_8unorm(tmp[0]);
459 dst[1] = util_format_srgb_to_linear_8unorm(tmp[1]);
460 dst[2] = util_format_srgb_to_linear_8unorm(tmp[2]);
461 dst[3] = tmp[3];
462 }
463
464 void
465 util_format_dxt3_srgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
466 {
467 uint8_t tmp[4];
468 util_format_dxt3_rgba_fetch(0, src, i, j, tmp);
469 dst[0] = util_format_srgb_to_linear_8unorm(tmp[0]);
470 dst[1] = util_format_srgb_to_linear_8unorm(tmp[1]);
471 dst[2] = util_format_srgb_to_linear_8unorm(tmp[2]);
472 dst[3] = tmp[3];
473 }
474
475 void
476 util_format_dxt5_srgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
477 {
478 uint8_t tmp[4];
479 util_format_dxt5_rgba_fetch(0, src, i, j, tmp);
480 dst[0] = util_format_srgb_to_linear_8unorm(tmp[0]);
481 dst[1] = util_format_srgb_to_linear_8unorm(tmp[1]);
482 dst[2] = util_format_srgb_to_linear_8unorm(tmp[2]);
483 dst[3] = tmp[3];
484 }
485
486 void
487 util_format_dxt1_srgb_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
488 {
489 uint8_t tmp[4];
490 util_format_dxt1_rgb_fetch(0, src, i, j, tmp);
491 dst[0] = util_format_srgb_8unorm_to_linear_float(tmp[0]);
492 dst[1] = util_format_srgb_8unorm_to_linear_float(tmp[1]);
493 dst[2] = util_format_srgb_8unorm_to_linear_float(tmp[2]);
494 dst[3] = 1.0f;
495 }
496
497 void
498 util_format_dxt1_srgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
499 {
500 uint8_t tmp[4];
501 util_format_dxt1_rgba_fetch(0, src, i, j, tmp);
502 dst[0] = util_format_srgb_8unorm_to_linear_float(tmp[0]);
503 dst[1] = util_format_srgb_8unorm_to_linear_float(tmp[1]);
504 dst[2] = util_format_srgb_8unorm_to_linear_float(tmp[2]);
505 dst[3] = ubyte_to_float(tmp[3]);
506 }
507
508 void
509 util_format_dxt3_srgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
510 {
511 uint8_t tmp[4];
512 util_format_dxt3_rgba_fetch(0, src, i, j, tmp);
513 dst[0] = util_format_srgb_8unorm_to_linear_float(tmp[0]);
514 dst[1] = util_format_srgb_8unorm_to_linear_float(tmp[1]);
515 dst[2] = util_format_srgb_8unorm_to_linear_float(tmp[2]);
516 dst[3] = ubyte_to_float(tmp[3]);
517 }
518
519 void
520 util_format_dxt5_srgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
521 {
522 uint8_t tmp[4];
523 util_format_dxt5_rgba_fetch(0, src, i, j, tmp);
524 dst[0] = util_format_srgb_8unorm_to_linear_float(tmp[0]);
525 dst[1] = util_format_srgb_8unorm_to_linear_float(tmp[1]);
526 dst[2] = util_format_srgb_8unorm_to_linear_float(tmp[2]);
527 dst[3] = ubyte_to_float(tmp[3]);
528 }
529
530 void
531 util_format_dxt1_srgb_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
532 {
533 util_format_dxtn_rgb_unpack_rgba_8unorm(dst_row, dst_stride,
534 src_row, src_stride,
535 width, height,
536 util_format_dxt1_rgb_fetch,
537 8, TRUE);
538 }
539
540 void
541 util_format_dxt1_srgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
542 {
543 util_format_dxtn_rgb_unpack_rgba_8unorm(dst_row, dst_stride,
544 src_row, src_stride,
545 width, height,
546 util_format_dxt1_rgba_fetch,
547 8, TRUE);
548 }
549
550 void
551 util_format_dxt3_srgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
552 {
553 util_format_dxtn_rgb_unpack_rgba_8unorm(dst_row, dst_stride,
554 src_row, src_stride,
555 width, height,
556 util_format_dxt3_rgba_fetch,
557 16, TRUE);
558 }
559
560 void
561 util_format_dxt5_srgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
562 {
563 util_format_dxtn_rgb_unpack_rgba_8unorm(dst_row, dst_stride,
564 src_row, src_stride,
565 width, height,
566 util_format_dxt5_rgba_fetch,
567 16, TRUE);
568 }
569
570 void
571 util_format_dxt1_srgb_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
572 {
573 util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride,
574 src_row, src_stride,
575 width, height,
576 util_format_dxt1_rgb_fetch,
577 8, TRUE);
578 }
579
580 void
581 util_format_dxt1_srgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
582 {
583 util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride,
584 src_row, src_stride,
585 width, height,
586 util_format_dxt1_rgba_fetch,
587 8, TRUE);
588 }
589
590 void
591 util_format_dxt3_srgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
592 {
593 util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride,
594 src_row, src_stride,
595 width, height,
596 util_format_dxt3_rgba_fetch,
597 16, TRUE);
598 }
599
600 void
601 util_format_dxt5_srgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
602 {
603 util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride,
604 src_row, src_stride,
605 width, height,
606 util_format_dxt5_rgba_fetch,
607 16, TRUE);
608 }
609
610 void
611 util_format_dxt1_srgb_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
612 {
613 util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride,
614 width, height, UTIL_FORMAT_DXT1_RGB,
615 8, TRUE);
616 }
617
618 void
619 util_format_dxt1_srgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
620 {
621 util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride,
622 width, height, UTIL_FORMAT_DXT1_RGBA,
623 8, TRUE);
624 }
625
626 void
627 util_format_dxt3_srgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
628 {
629 util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride,
630 width, height, UTIL_FORMAT_DXT3_RGBA,
631 16, TRUE);
632 }
633
634 void
635 util_format_dxt5_srgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
636 {
637 util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride,
638 width, height, UTIL_FORMAT_DXT5_RGBA,
639 16, TRUE);
640 }
641
642 void
643 util_format_dxt1_srgb_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
644 {
645 util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src_row, src_stride,
646 width, height, UTIL_FORMAT_DXT1_RGB,
647 8, TRUE);
648 }
649
650 void
651 util_format_dxt1_srgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
652 {
653 util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src_row, src_stride,
654 width, height, UTIL_FORMAT_DXT1_RGBA,
655 8, TRUE);
656 }
657
658 void
659 util_format_dxt3_srgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
660 {
661 util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src_row, src_stride,
662 width, height, UTIL_FORMAT_DXT3_RGBA,
663 16, TRUE);
664 }
665
666 void
667 util_format_dxt5_srgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
668 {
669 util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src_row, src_stride,
670 width, height, UTIL_FORMAT_DXT5_RGBA,
671 16, TRUE);
672 }
673