Blender V2.61 - r43446

BlockDXT.cpp

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * Contributors: Amorilia (amorilia@users.sourceforge.net)
00019  *
00020  * ***** END GPL LICENSE BLOCK *****
00021  */
00022 
00028 /*
00029  * This file is based on a similar file from the NVIDIA texture tools
00030  * (http://nvidia-texture-tools.googlecode.com/)
00031  *
00032  * Original license from NVIDIA follows.
00033  */
00034 
00035 // Copyright NVIDIA Corporation 2007 -- Ignacio Castano <icastano@nvidia.com>
00036 // 
00037 // Permission is hereby granted, free of charge, to any person
00038 // obtaining a copy of this software and associated documentation
00039 // files (the "Software"), to deal in the Software without
00040 // restriction, including without limitation the rights to use,
00041 // copy, modify, merge, publish, distribute, sublicense, and/or sell
00042 // copies of the Software, and to permit persons to whom the
00043 // Software is furnished to do so, subject to the following
00044 // conditions:
00045 // 
00046 // The above copyright notice and this permission notice shall be
00047 // included in all copies or substantial portions of the Software.
00048 // 
00049 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00050 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
00051 // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00052 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
00053 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
00054 // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00055 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00056 // OTHER DEALINGS IN THE SOFTWARE.
00057 
00058 #include <Common.h>
00059 #include <Stream.h>
00060 #include <ColorBlock.h>
00061 #include <BlockDXT.h>
00062 
00063 /*----------------------------------------------------------------------------
00064     BlockDXT1
00065 ----------------------------------------------------------------------------*/
00066 
00067 uint BlockDXT1::evaluatePalette(Color32 color_array[4]) const
00068 {
00069     // Does bit expansion before interpolation.
00070     color_array[0].b = (col0.b << 3) | (col0.b >> 2);
00071     color_array[0].g = (col0.g << 2) | (col0.g >> 4);
00072     color_array[0].r = (col0.r << 3) | (col0.r >> 2);
00073     color_array[0].a = 0xFF;
00074     
00075     // @@ Same as above, but faster?
00076 //  Color32 c;
00077 //  c.u = ((col0.u << 3) & 0xf8) | ((col0.u << 5) & 0xfc00) | ((col0.u << 8) & 0xf80000);
00078 //  c.u |= (c.u >> 5) & 0x070007;
00079 //  c.u |= (c.u >> 6) & 0x000300;
00080 //  color_array[0].u = c.u;
00081     
00082     color_array[1].r = (col1.r << 3) | (col1.r >> 2);
00083     color_array[1].g = (col1.g << 2) | (col1.g >> 4);
00084     color_array[1].b = (col1.b << 3) | (col1.b >> 2);
00085     color_array[1].a = 0xFF;
00086     
00087     // @@ Same as above, but faster?
00088 //  c.u = ((col1.u << 3) & 0xf8) | ((col1.u << 5) & 0xfc00) | ((col1.u << 8) & 0xf80000);
00089 //  c.u |= (c.u >> 5) & 0x070007;
00090 //  c.u |= (c.u >> 6) & 0x000300;
00091 //  color_array[1].u = c.u;
00092     
00093     if( col0.u > col1.u ) {
00094         // Four-color block: derive the other two colors.
00095         color_array[2].r = (2 * color_array[0].r + color_array[1].r) / 3;
00096         color_array[2].g = (2 * color_array[0].g + color_array[1].g) / 3;
00097         color_array[2].b = (2 * color_array[0].b + color_array[1].b) / 3;
00098         color_array[2].a = 0xFF;
00099         
00100         color_array[3].r = (2 * color_array[1].r + color_array[0].r) / 3;
00101         color_array[3].g = (2 * color_array[1].g + color_array[0].g) / 3;
00102         color_array[3].b = (2 * color_array[1].b + color_array[0].b) / 3;
00103         color_array[3].a = 0xFF;
00104         
00105         return 4;
00106     }
00107     else {
00108         // Three-color block: derive the other color.
00109         color_array[2].r = (color_array[0].r + color_array[1].r) / 2;
00110         color_array[2].g = (color_array[0].g + color_array[1].g) / 2;
00111         color_array[2].b = (color_array[0].b + color_array[1].b) / 2;
00112         color_array[2].a = 0xFF;
00113         
00114         // Set all components to 0 to match DXT specs.
00115         color_array[3].r = 0x00; // color_array[2].r;
00116         color_array[3].g = 0x00; // color_array[2].g;
00117         color_array[3].b = 0x00; // color_array[2].b;
00118         color_array[3].a = 0x00;
00119         
00120         return 3;
00121     }
00122 }
00123 
00124 
00125 uint BlockDXT1::evaluatePaletteNV5x(Color32 color_array[4]) const
00126 {
00127     // Does bit expansion before interpolation.
00128     color_array[0].b = (3 * col0.b * 22) / 8;
00129     color_array[0].g = (col0.g << 2) | (col0.g >> 4);
00130     color_array[0].r = (3 * col0.r * 22) / 8;
00131     color_array[0].a = 0xFF;
00132 
00133     color_array[1].r = (3 * col1.r * 22) / 8;
00134     color_array[1].g = (col1.g << 2) | (col1.g >> 4);
00135     color_array[1].b = (3 * col1.b * 22) / 8;
00136     color_array[1].a = 0xFF;
00137     
00138     int gdiff = color_array[1].g - color_array[0].g;
00139 
00140     if( col0.u > col1.u ) {
00141         // Four-color block: derive the other two colors.
00142         color_array[2].r = ((2 * col0.r + col1.r) * 22) / 8;
00143         color_array[2].g = (256 * color_array[0].g + gdiff / 4 + 128 + gdiff * 80) / 256;
00144         color_array[2].b = ((2 * col0.b + col1.b) * 22) / 8;
00145         color_array[2].a = 0xFF;
00146         
00147         color_array[3].r = ((2 * col1.r + col0.r) * 22) / 8;
00148         color_array[3].g = (256 * color_array[1].g - gdiff / 4 + 128 - gdiff * 80) / 256;
00149         color_array[3].b = ((2 * col1.b + col0.b) * 22) / 8;
00150         color_array[3].a = 0xFF;
00151 
00152         return 4;
00153     }
00154     else {
00155         // Three-color block: derive the other color.
00156         color_array[2].r = ((col0.r + col1.r) * 33) / 8;
00157         color_array[2].g = (256 * color_array[0].g + gdiff / 4 + 128 + gdiff * 128) / 256;
00158         color_array[2].b = ((col0.b + col1.b) * 33) / 8;
00159         color_array[2].a = 0xFF;
00160         
00161         // Set all components to 0 to match DXT specs.
00162         color_array[3].r = 0x00; // color_array[2].r;
00163         color_array[3].g = 0x00; // color_array[2].g;
00164         color_array[3].b = 0x00; // color_array[2].b;
00165         color_array[3].a = 0x00;
00166         
00167         return 3;
00168     }
00169 }
00170 
00171 // Evaluate palette assuming 3 color block.
00172 void BlockDXT1::evaluatePalette3(Color32 color_array[4]) const
00173 {
00174     color_array[0].b = (col0.b << 3) | (col0.b >> 2);
00175     color_array[0].g = (col0.g << 2) | (col0.g >> 4);
00176     color_array[0].r = (col0.r << 3) | (col0.r >> 2);
00177     color_array[0].a = 0xFF;
00178     
00179     color_array[1].r = (col1.r << 3) | (col1.r >> 2);
00180     color_array[1].g = (col1.g << 2) | (col1.g >> 4);
00181     color_array[1].b = (col1.b << 3) | (col1.b >> 2);
00182     color_array[1].a = 0xFF;
00183     
00184     // Three-color block: derive the other color.
00185     color_array[2].r = (color_array[0].r + color_array[1].r) / 2;
00186     color_array[2].g = (color_array[0].g + color_array[1].g) / 2;
00187     color_array[2].b = (color_array[0].b + color_array[1].b) / 2;
00188     color_array[2].a = 0xFF;
00189         
00190     // Set all components to 0 to match DXT specs.
00191     color_array[3].r = 0x00; // color_array[2].r;
00192     color_array[3].g = 0x00; // color_array[2].g;
00193     color_array[3].b = 0x00; // color_array[2].b;
00194     color_array[3].a = 0x00;
00195 }
00196 
00197 // Evaluate palette assuming 4 color block.
00198 void BlockDXT1::evaluatePalette4(Color32 color_array[4]) const
00199 {
00200     color_array[0].b = (col0.b << 3) | (col0.b >> 2);
00201     color_array[0].g = (col0.g << 2) | (col0.g >> 4);
00202     color_array[0].r = (col0.r << 3) | (col0.r >> 2);
00203     color_array[0].a = 0xFF;
00204     
00205     color_array[1].r = (col1.r << 3) | (col1.r >> 2);
00206     color_array[1].g = (col1.g << 2) | (col1.g >> 4);
00207     color_array[1].b = (col1.b << 3) | (col1.b >> 2);
00208     color_array[1].a = 0xFF;
00209     
00210     // Four-color block: derive the other two colors.
00211     color_array[2].r = (2 * color_array[0].r + color_array[1].r) / 3;
00212     color_array[2].g = (2 * color_array[0].g + color_array[1].g) / 3;
00213     color_array[2].b = (2 * color_array[0].b + color_array[1].b) / 3;
00214     color_array[2].a = 0xFF;
00215         
00216     color_array[3].r = (2 * color_array[1].r + color_array[0].r) / 3;
00217     color_array[3].g = (2 * color_array[1].g + color_array[0].g) / 3;
00218     color_array[3].b = (2 * color_array[1].b + color_array[0].b) / 3;
00219     color_array[3].a = 0xFF;
00220 }
00221 
00222 
00223 void BlockDXT1::decodeBlock(ColorBlock * block) const
00224 {
00225     // Decode color block.
00226     Color32 color_array[4];
00227     evaluatePalette(color_array);
00228     
00229     // Write color block.
00230     for( uint j = 0; j < 4; j++ ) {
00231         for( uint i = 0; i < 4; i++ ) {
00232             uint idx = (row[j] >> (2 * i)) & 3;
00233             block->color(i, j) = color_array[idx];
00234         }
00235     }   
00236 }
00237 
00238 void BlockDXT1::decodeBlockNV5x(ColorBlock * block) const
00239 {
00240     // Decode color block.
00241     Color32 color_array[4];
00242     evaluatePaletteNV5x(color_array);
00243 
00244     // Write color block.
00245     for( uint j = 0; j < 4; j++ ) {
00246         for( uint i = 0; i < 4; i++ ) {
00247             uint idx = (row[j] >> (2 * i)) & 3;
00248             block->color(i, j) = color_array[idx];
00249         }
00250     }
00251 }
00252 
00253 void BlockDXT1::setIndices(int * idx)
00254 {
00255     indices = 0;
00256     for(uint i = 0; i < 16; i++) {
00257         indices |= (idx[i] & 3) << (2 * i);
00258     }
00259 }
00260 
00261 
00263 inline void BlockDXT1::flip4()
00264 {
00265     swap(row[0], row[3]);
00266     swap(row[1], row[2]);
00267 }
00268 
00270 inline void BlockDXT1::flip2()
00271 {
00272     swap(row[0], row[1]);
00273 }
00274 
00275 
00276 /*----------------------------------------------------------------------------
00277     BlockDXT3
00278 ----------------------------------------------------------------------------*/
00279 
00280 void BlockDXT3::decodeBlock(ColorBlock * block) const
00281 {
00282     // Decode color.
00283     color.decodeBlock(block);
00284     
00285     // Decode alpha.
00286     alpha.decodeBlock(block);
00287 }
00288 
00289 void BlockDXT3::decodeBlockNV5x(ColorBlock * block) const
00290 {
00291     color.decodeBlockNV5x(block);
00292     alpha.decodeBlock(block);
00293 }
00294 
00295 void AlphaBlockDXT3::decodeBlock(ColorBlock * block) const
00296 {
00297     block->color(0x0).a = (alpha0 << 4) | alpha0;
00298     block->color(0x1).a = (alpha1 << 4) | alpha1;
00299     block->color(0x2).a = (alpha2 << 4) | alpha2;
00300     block->color(0x3).a = (alpha3 << 4) | alpha3;
00301     block->color(0x4).a = (alpha4 << 4) | alpha4;
00302     block->color(0x5).a = (alpha5 << 4) | alpha5;
00303     block->color(0x6).a = (alpha6 << 4) | alpha6;
00304     block->color(0x7).a = (alpha7 << 4) | alpha7;
00305     block->color(0x8).a = (alpha8 << 4) | alpha8;
00306     block->color(0x9).a = (alpha9 << 4) | alpha9;
00307     block->color(0xA).a = (alphaA << 4) | alphaA;
00308     block->color(0xB).a = (alphaB << 4) | alphaB;
00309     block->color(0xC).a = (alphaC << 4) | alphaC;
00310     block->color(0xD).a = (alphaD << 4) | alphaD;
00311     block->color(0xE).a = (alphaE << 4) | alphaE;
00312     block->color(0xF).a = (alphaF << 4) | alphaF;
00313 }
00314 
00316 void AlphaBlockDXT3::flip4()
00317 {
00318     swap(row[0], row[3]);
00319     swap(row[1], row[2]);
00320 }
00321 
00323 void AlphaBlockDXT3::flip2()
00324 {
00325     swap(row[0], row[1]);
00326 }
00327 
00329 void BlockDXT3::flip4()
00330 {
00331     alpha.flip4();
00332     color.flip4();
00333 }
00334 
00336 void BlockDXT3::flip2()
00337 {
00338     alpha.flip2();
00339     color.flip2();
00340 }
00341 
00342 
00343 /*----------------------------------------------------------------------------
00344     BlockDXT5
00345 ----------------------------------------------------------------------------*/
00346 
00347 void AlphaBlockDXT5::evaluatePalette(uint8 alpha[8]) const
00348 {
00349     if (alpha0() > alpha1()) {
00350         evaluatePalette8(alpha);
00351     }
00352     else {
00353         evaluatePalette6(alpha);
00354     }
00355 }
00356 
00357 void AlphaBlockDXT5::evaluatePalette8(uint8 alpha[8]) const
00358 {
00359     // 8-alpha block:  derive the other six alphas.
00360     // Bit code 000 = alpha0, 001 = alpha1, others are interpolated.
00361     alpha[0] = alpha0();
00362     alpha[1] = alpha1();
00363     alpha[2] = (6 * alpha[0] + 1 * alpha[1]) / 7;   // bit code 010
00364     alpha[3] = (5 * alpha[0] + 2 * alpha[1]) / 7;   // bit code 011
00365     alpha[4] = (4 * alpha[0] + 3 * alpha[1]) / 7;   // bit code 100
00366     alpha[5] = (3 * alpha[0] + 4 * alpha[1]) / 7;   // bit code 101
00367     alpha[6] = (2 * alpha[0] + 5 * alpha[1]) / 7;   // bit code 110
00368     alpha[7] = (1 * alpha[0] + 6 * alpha[1]) / 7;   // bit code 111
00369 }
00370 
00371 void AlphaBlockDXT5::evaluatePalette6(uint8 alpha[8]) const
00372 {
00373     // 6-alpha block.
00374     // Bit code 000 = alpha0, 001 = alpha1, others are interpolated.
00375     alpha[0] = alpha0();
00376     alpha[1] = alpha1();
00377     alpha[2] = (4 * alpha[0] + 1 * alpha[1]) / 5;   // Bit code 010
00378     alpha[3] = (3 * alpha[0] + 2 * alpha[1]) / 5;   // Bit code 011
00379     alpha[4] = (2 * alpha[0] + 3 * alpha[1]) / 5;   // Bit code 100
00380     alpha[5] = (1 * alpha[0] + 4 * alpha[1]) / 5;   // Bit code 101
00381     alpha[6] = 0x00;                            // Bit code 110
00382     alpha[7] = 0xFF;                            // Bit code 111
00383 }
00384 
00385 void AlphaBlockDXT5::indices(uint8 index_array[16]) const
00386 {
00387     index_array[0x0] = bits0();
00388     index_array[0x1] = bits1();
00389     index_array[0x2] = bits2();
00390     index_array[0x3] = bits3();
00391     index_array[0x4] = bits4();
00392     index_array[0x5] = bits5();
00393     index_array[0x6] = bits6();
00394     index_array[0x7] = bits7();
00395     index_array[0x8] = bits8();
00396     index_array[0x9] = bits9();
00397     index_array[0xA] = bitsA();
00398     index_array[0xB] = bitsB();
00399     index_array[0xC] = bitsC();
00400     index_array[0xD] = bitsD();
00401     index_array[0xE] = bitsE();
00402     index_array[0xF] = bitsF();
00403 }
00404 
00405 uint AlphaBlockDXT5::index(uint index) const
00406 {
00407     int offset = (3 * index + 16);
00408     return uint((this->u >> offset) & 0x7);
00409 }
00410 
00411 void AlphaBlockDXT5::setIndex(uint index, uint value)
00412 {
00413     int offset = (3 * index + 16);
00414     uint64 mask = uint64(0x7) << offset;
00415     this->u = (this->u & ~mask) | (uint64(value) << offset);
00416 }
00417 
00418 void AlphaBlockDXT5::decodeBlock(ColorBlock * block) const
00419 {
00420     uint8 alpha_array[8];
00421     evaluatePalette(alpha_array);
00422     
00423     uint8 index_array[16];
00424     indices(index_array);
00425     
00426     for(uint i = 0; i < 16; i++) {
00427         block->color(i).a = alpha_array[index_array[i]];
00428     }
00429 }
00430 
00431 void AlphaBlockDXT5::flip4()
00432 {
00433     uint64 * b = (uint64 *)this;
00434     
00435     // @@ The masks might have to be byte swapped.
00436     uint64 tmp = (*b & (uint64)(0x000000000000FFFFLL));
00437     tmp |= (*b & (uint64)(0x000000000FFF0000LL)) << 36;
00438     tmp |= (*b & (uint64)(0x000000FFF0000000LL)) << 12;
00439     tmp |= (*b & (uint64)(0x000FFF0000000000LL)) >> 12;
00440     tmp |= (*b & (uint64)(0xFFF0000000000000LL)) >> 36;
00441     
00442     *b = tmp;
00443 }
00444 
00445 void AlphaBlockDXT5::flip2()
00446 {
00447     uint * b = (uint *)this;
00448     
00449     // @@ The masks might have to be byte swapped.
00450     uint tmp = (*b & 0xFF000000);
00451     tmp |=  (*b & 0x00000FFF) << 12;
00452     tmp |= (*b & 0x00FFF000) >> 12;
00453     
00454     *b = tmp;
00455 }
00456 
00457 void BlockDXT5::decodeBlock(ColorBlock * block) const
00458 {
00459     // Decode color.
00460     color.decodeBlock(block);
00461     
00462     // Decode alpha.
00463     alpha.decodeBlock(block);
00464 }
00465 
00466 void BlockDXT5::decodeBlockNV5x(ColorBlock * block) const
00467 {
00468     // Decode color.
00469     color.decodeBlockNV5x(block);
00470     
00471     // Decode alpha.
00472     alpha.decodeBlock(block);
00473 }
00474 
00476 void BlockDXT5::flip4()
00477 {
00478     alpha.flip4();
00479     color.flip4();
00480 }
00481 
00483 void BlockDXT5::flip2()
00484 {
00485     alpha.flip2();
00486     color.flip2();
00487 }
00488 
00489 
00491 void BlockATI1::decodeBlock(ColorBlock * block) const
00492 {
00493     uint8 alpha_array[8];
00494     alpha.evaluatePalette(alpha_array);
00495     
00496     uint8 index_array[16];
00497     alpha.indices(index_array);
00498     
00499     for(uint i = 0; i < 16; i++) {
00500         Color32 & c = block->color(i);
00501         c.b = c.g = c.r = alpha_array[index_array[i]];
00502         c.a = 255;
00503     }
00504 }
00505 
00507 void BlockATI1::flip4()
00508 {
00509     alpha.flip4();
00510 }
00511 
00513 void BlockATI1::flip2()
00514 {
00515     alpha.flip2();
00516 }
00517 
00518 
00520 void BlockATI2::decodeBlock(ColorBlock * block) const
00521 {
00522     uint8 alpha_array[8];
00523     uint8 index_array[16];
00524     
00525     x.evaluatePalette(alpha_array);
00526     x.indices(index_array);
00527     
00528     for(uint i = 0; i < 16; i++) {
00529         Color32 & c = block->color(i);
00530         c.r = alpha_array[index_array[i]];
00531     }
00532 
00533     y.evaluatePalette(alpha_array);
00534     y.indices(index_array);
00535     
00536     for(uint i = 0; i < 16; i++) {
00537         Color32 & c = block->color(i);
00538         c.g = alpha_array[index_array[i]];
00539         c.b = 0;
00540         c.a = 255;
00541     }
00542 }
00543 
00545 void BlockATI2::flip4()
00546 {
00547     x.flip4();
00548     y.flip4();
00549 }
00550 
00552 void BlockATI2::flip2()
00553 {
00554     x.flip2();
00555     y.flip2();
00556 }
00557 
00558 
00559 void BlockCTX1::evaluatePalette(Color32 color_array[4]) const
00560 {
00561     // Does bit expansion before interpolation.
00562     color_array[0].b = 0x00;
00563     color_array[0].g = col0[1];
00564     color_array[0].r = col0[0];
00565     color_array[0].a = 0xFF;
00566     
00567     color_array[1].r = 0x00;
00568     color_array[1].g = col0[1];
00569     color_array[1].b = col1[0];
00570     color_array[1].a = 0xFF;
00571     
00572     color_array[2].r = 0x00;
00573     color_array[2].g = (2 * color_array[0].g + color_array[1].g) / 3;
00574     color_array[2].b = (2 * color_array[0].b + color_array[1].b) / 3;
00575     color_array[2].a = 0xFF;
00576         
00577     color_array[3].r = 0x00;
00578     color_array[3].g = (2 * color_array[1].g + color_array[0].g) / 3;
00579     color_array[3].b = (2 * color_array[1].b + color_array[0].b) / 3;
00580     color_array[3].a = 0xFF;
00581 }
00582 
00583 void BlockCTX1::decodeBlock(ColorBlock * block) const
00584 {
00585     // Decode color block.
00586     Color32 color_array[4];
00587     evaluatePalette(color_array);
00588     
00589     // Write color block.
00590     for( uint j = 0; j < 4; j++ ) {
00591         for( uint i = 0; i < 4; i++ ) {
00592             uint idx = (row[j] >> (2 * i)) & 3;
00593             block->color(i, j) = color_array[idx];
00594         }
00595     }   
00596 }
00597 
00598 void BlockCTX1::setIndices(int * idx)
00599 {
00600     indices = 0;
00601     for(uint i = 0; i < 16; i++) {
00602         indices |= (idx[i] & 3) << (2 * i);
00603     }
00604 }
00605 
00606 
00608 inline void BlockCTX1::flip4()
00609 {
00610     swap(row[0], row[3]);
00611     swap(row[1], row[2]);
00612 }
00613 
00615 inline void BlockCTX1::flip2()
00616 {
00617     swap(row[0], row[1]);
00618 }
00619 
00620 void mem_read(Stream & mem, BlockDXT1 & block)
00621 {
00622     mem_read(mem, block.col0.u);
00623     mem_read(mem, block.col1.u);
00624     mem_read(mem, block.indices);
00625 }
00626 
00627 void mem_read(Stream & mem, AlphaBlockDXT3 & block)
00628 {
00629     for (unsigned int i = 0; i < 4; i++) mem_read(mem, block.row[i]);
00630 }
00631 
00632 void mem_read(Stream & mem, BlockDXT3 & block)
00633 {
00634     mem_read(mem, block.alpha);
00635     mem_read(mem, block.color);
00636 }
00637 
00638 void mem_read(Stream & mem, AlphaBlockDXT5 & block)
00639 {
00640     mem_read(mem, block.u);
00641 }
00642 
00643 void mem_read(Stream & mem, BlockDXT5 & block)
00644 {
00645     mem_read(mem, block.alpha);
00646     mem_read(mem, block.color);
00647 }
00648 
00649 void mem_read(Stream & mem, BlockATI1 & block)
00650 {
00651     mem_read(mem, block.alpha);
00652 }
00653 
00654 void mem_read(Stream & mem, BlockATI2 & block)
00655 {
00656     mem_read(mem, block.x);
00657     mem_read(mem, block.y);
00658 }
00659 
00660 void mem_read(Stream & mem, BlockCTX1 & block)
00661 {
00662     mem_read(mem, block.col0[0]);
00663     mem_read(mem, block.col0[1]);
00664     mem_read(mem, block.col1[0]);
00665     mem_read(mem, block.col1[1]);
00666     mem_read(mem, block.indices);
00667 }
00668