MCPcopy Create free account
hub / github.com/GPUOpen-Tools/compressonator / FreeMipSet

Method FreeMipSet

cmp_framework/common/cmp_mips.cpp:1100–1164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1098}
1099
1100void CMP_CMIPS::FreeMipSet(CMP_MipSet* pMipSet)
1101{
1102 //TODO test
1103 int nTotalOldMipLevels = 0;
1104 assert(pMipSet);
1105 if (pMipSet)
1106 {
1107 if (pMipSet->m_pMipLevelTable)
1108 {
1109 //determine number of miplevels in the old mipleveltable
1110 switch (pMipSet->m_TextureType)
1111 {
1112 case TT_1D:
1113 case TT_2D:
1114 nTotalOldMipLevels = pMipSet->m_nMaxMipLevels;
1115 break;
1116 case TT_CubeMap:
1117 nTotalOldMipLevels = pMipSet->m_nMaxMipLevels * pMipSet->m_nDepth;
1118 break;
1119 case TT_VolumeTexture:
1120 for (int depth = pMipSet->m_nDepth, mipLevels = 0; mipLevels < pMipSet->m_nMaxMipLevels; mipLevels++)
1121 {
1122 nTotalOldMipLevels += depth;
1123 if (depth > 1)
1124 {
1125 depth >>= 1;
1126 }
1127 }
1128 break;
1129 default:
1130 assert(0);
1131 }
1132
1133 for (int i = 0; i < nTotalOldMipLevels; i++)
1134 {
1135 if (pMipSet->m_pMipLevelTable[i]->m_pbData)
1136 {
1137#ifdef USE_BASIS
1138 if (pMipSet->m_format == CMP_FORMAT_BASIS)
1139 {
1140 CMP_VEC8& basis_data = *(pMipSet->m_pMipLevelTable[i]->m_pvec8Data);
1141 if (basis_data.size() > 0)
1142 delete &basis_data;
1143 }
1144 else
1145#endif
1146 free(pMipSet->m_pMipLevelTable[i]->m_pbData);
1147
1148 pMipSet->m_pMipLevelTable[i]->m_pbData = NULL;
1149 }
1150
1151 if (pMipSet->m_pMipLevelTable[i])
1152 {
1153 free(pMipSet->m_pMipLevelTable[i]);
1154 pMipSet->m_pMipLevelTable[i] = NULL;
1155 }
1156 }
1157

Callers 7

clearMipImagesMethod · 0.80
DeallocateMipSetFunction · 0.80
ProcessCMDLineFunction · 0.80
DecompressMIPSetFunction · 0.80
CleanMipSetMethod · 0.80
CMP_ProcessTextureFunction · 0.80
CMP_FreeMipSetFunction · 0.80

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected