| 760 | } |
| 761 | |
| 762 | std::string TextureCache::getCachedTextureInfo() const |
| 763 | { |
| 764 | std::string ret; |
| 765 | |
| 766 | char tmp[1024]; |
| 767 | |
| 768 | unsigned int count = 0; |
| 769 | unsigned int totalBytes = 0; |
| 770 | |
| 771 | for (auto&& texture : _textures) |
| 772 | { |
| 773 | Texture2D* tex = texture.second; |
| 774 | unsigned int bpp = tex->getBitsPerPixelForFormat(); |
| 775 | // Each texture takes up width * height * bytesPerPixel bytes. |
| 776 | auto bytes = tex->getPixelsWide() * tex->getPixelsHigh() * bpp / 8; |
| 777 | totalBytes += bytes; |
| 778 | count++; |
| 779 | auto msg = fmt::format_to_z(tmp, "\"{}\" rc={} id={} {} x {} @ {} bpp => {} KB\n", texture.first, |
| 780 | tex->getReferenceCount(), fmt::ptr(tex->getBackendTexture()), tex->getPixelsWide(), |
| 781 | tex->getPixelsHigh(), bpp, bytes / 1024); |
| 782 | |
| 783 | ret += msg; |
| 784 | } |
| 785 | |
| 786 | auto msg = fmt::format_to_z(tmp, "TextureCache dumpDebugInfo: {} textures, for {} KB ({:.2f} MB)\n", count, |
| 787 | totalBytes / 1024, totalBytes / (1024.0f * 1024.0f)); |
| 788 | ret += msg; |
| 789 | |
| 790 | return ret; |
| 791 | } |
| 792 | |
| 793 | void TextureCache::renameTextureWithKey(std::string_view srcName, std::string_view dstName) |
| 794 | { |