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