uint32 DX::textureSize( const Texture *constTexture ) { BW_GUARD; if (constTexture == NULL) return 0; // The operations on the texture are really const operations Texture *texture = const_cast<Texture *>(constTexture); // Determine the mip-map texture size scaling factor double mipmapScaler = ( 4 - pow(0.25, (double)texture->GetLevelCount() - 1 ) ) / 3; // Get a surface to determine the width, height, and format D3DSURFACE_DESC surfaceDesc; texture->GetLevelDesc(0, &surfaceDesc); // Get the surface size uint32 surfaceSize = DX::surfaceSize(surfaceDesc); // Track memory usage return (uint32)(surfaceSize * mipmapScaler); }