| 115 | } |
| 116 | |
| 117 | U32 DDSFile::getSurfaceSize( U32 height, U32 width, U32 mipLevel ) const |
| 118 | { |
| 119 | // Bump by the mip level. |
| 120 | height = getMax(U32(1), height >> mipLevel); |
| 121 | width = getMax(U32(1), width >> mipLevel); |
| 122 | |
| 123 | if(mFlags.test(CompressedData)) |
| 124 | { |
| 125 | // From the directX docs: |
| 126 | // max(1, width � 4) x max(1, height � 4) x 8(DXT1) or 16(DXT2-5) |
| 127 | |
| 128 | U32 sizeMultiple = 0; |
| 129 | |
| 130 | switch(mFormat) |
| 131 | { |
| 132 | case GFXFormatBC1: |
| 133 | case GFXFormatBC4: |
| 134 | sizeMultiple = 8; |
| 135 | break; |
| 136 | case GFXFormatBC2: |
| 137 | case GFXFormatBC3: |
| 138 | case GFXFormatBC5: |
| 139 | sizeMultiple = 16; |
| 140 | break; |
| 141 | default: |
| 142 | AssertISV(false, "DDSFile::getSurfaceSize - invalid compressed texture format, we only support DXT1-5 right now."); |
| 143 | break; |
| 144 | } |
| 145 | |
| 146 | return getMax(U32(1), width/4) * getMax(U32(1), height/4) * sizeMultiple; |
| 147 | } |
| 148 | else |
| 149 | { |
| 150 | return height * width* mBytesPerPixel; |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | U32 DDSFile::getSizeInBytes() const |
| 155 | { |
no test coverage detected