| 158 | } |
| 159 | |
| 160 | U32 DDSFile::getSurfaceSize( U32 height, U32 width, U32 mipLevel ) const |
| 161 | { |
| 162 | // Bump by the mip level. |
| 163 | height = getMax(U32(1), height >> mipLevel); |
| 164 | width = getMax(U32(1), width >> mipLevel); |
| 165 | |
| 166 | if(mFlags.test(CompressedData)) |
| 167 | { |
| 168 | // From the directX docs: |
| 169 | // max(1, width � 4) x max(1, height � 4) x 8(DXT1) or 16(DXT2-5) |
| 170 | |
| 171 | U32 sizeMultiple = 0; |
| 172 | |
| 173 | switch(mFormat) |
| 174 | { |
| 175 | case GFXFormatDXT1: |
| 176 | sizeMultiple = 8; |
| 177 | break; |
| 178 | case GFXFormatDXT2: |
| 179 | case GFXFormatDXT3: |
| 180 | case GFXFormatDXT4: |
| 181 | case GFXFormatDXT5: |
| 182 | sizeMultiple = 16; |
| 183 | break; |
| 184 | default: |
| 185 | AssertISV(false, "DDSFile::getSurfaceSize - invalid compressed texture format, we only support DXT1-5 right now."); |
| 186 | break; |
| 187 | } |
| 188 | |
| 189 | return getMax(U32(1), width/4) * getMax(U32(1), height/4) * sizeMultiple; |
| 190 | } |
| 191 | else |
| 192 | { |
| 193 | return height * width* mBytesPerPixel; |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | U32 DDSFile::getSizeInBytes() const |
| 198 | { |
no test coverage detected