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