| 186 | } |
| 187 | |
| 188 | CMP_ERROR CMP_API CMP_CreateMipSet(CMP_MipSet* pMipSet, CMP_INT nWidth, CMP_INT nHeight, CMP_INT nDepth, ChannelFormat channelFormat, TextureType textureType) |
| 189 | { |
| 190 | CMP_CMIPS CMips; |
| 191 | |
| 192 | pMipSet->m_Flags = MS_FLAG_Default; |
| 193 | pMipSet->m_nHeight = nHeight; |
| 194 | pMipSet->m_nWidth = nWidth; |
| 195 | pMipSet->dwWidth = 0; |
| 196 | pMipSet->dwHeight = 0; |
| 197 | pMipSet->m_ChannelFormat = channelFormat; |
| 198 | pMipSet->m_dwFourCC = 0; |
| 199 | pMipSet->m_nBlockHeight = 4; |
| 200 | pMipSet->m_nBlockWidth = 4; |
| 201 | pMipSet->m_nMaxMipLevels = CMP_CalcMaxMipLevel(nHeight, nWidth, false); |
| 202 | pMipSet->m_nMipLevels = 1; |
| 203 | pMipSet->m_TextureType = textureType; |
| 204 | pMipSet->m_nDepth = nDepth; |
| 205 | |
| 206 | if (!CMips.AllocateMipSet(pMipSet, channelFormat, TDT_ARGB, pMipSet->m_TextureType, nWidth, nHeight, nDepth)) |
| 207 | return CMP_ERR_MEM_ALLOC_FOR_MIPSET; |
| 208 | |
| 209 | //---------------------------------------------------------------- |
| 210 | // Access the data table for mip level 0 (full texture width and height) |
| 211 | //---------------------------------------------------------------- |
| 212 | |
| 213 | MipLevel* pOutMipLevel = CMips.GetMipLevel(pMipSet, 0); |
| 214 | |
| 215 | //----------------------------------------------------------------------- |
| 216 | // Calculate the target compressed block buffer size (4 bytes x 4 bytes) |
| 217 | //----------------------------------------------------------------------- |
| 218 | CMP_INT bytesPerChannel; // use m_ChannelFormat for this |
| 219 | |
| 220 | switch (channelFormat) |
| 221 | { |
| 222 | case CF_16bit: |
| 223 | case CF_Float16: |
| 224 | bytesPerChannel = 8; |
| 225 | break; |
| 226 | case CF_32bit: |
| 227 | case CF_Float32: |
| 228 | bytesPerChannel = 16; |
| 229 | break; |
| 230 | case CF_1010102: |
| 231 | case CF_2101010: |
| 232 | case CF_Float9995E: |
| 233 | case CF_YUV_420: |
| 234 | case CF_YUV_422: |
| 235 | case CF_YUV_444: |
| 236 | case CF_YUV_4444: |
| 237 | // toDo |
| 238 | return CMP_ERR_UNSUPPORTED_SOURCE_FORMAT; |
| 239 | break; |
| 240 | case CF_Compressed: |
| 241 | bytesPerChannel = 1; |
| 242 | break; |
| 243 | default: |
| 244 | bytesPerChannel = 4; |
| 245 | break; |