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