From cc851c41c11bdc1c192003021df6dc3c2d2b74fb Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sat, 29 Apr 2017 00:53:32 +1000 Subject: TextureCache: Move host texture utility functions to VideoCommon The appropriate place for these would be AbstractTexture, once it is finished. --- Source/Core/VideoCommon/TextureCacheBase.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'Source/Core/VideoCommon/TextureCacheBase.cpp') diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index e3a9daa69d..613f2dfed9 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -47,6 +47,29 @@ TextureCacheBase::TCacheEntryBase::~TCacheEntryBase() { } +bool TextureCacheBase::IsCompressedHostTextureFormat(HostTextureFormat format) +{ + // This will need to be changed if we add any other uncompressed formats. + return format != HostTextureFormat::RGBA8; +} + +size_t TextureCacheBase::CalculateHostTextureLevelPitch(HostTextureFormat format, u32 row_length) +{ + switch (format) + { + case HostTextureFormat::DXT1: + return static_cast(std::max(1u, row_length / 4)) * 8; + + case HostTextureFormat::DXT3: + case HostTextureFormat::DXT5: + return static_cast(std::max(1u, row_length / 4)) * 16; + + case HostTextureFormat::RGBA8: + default: + return static_cast(row_length) * 4; + } +} + void TextureCacheBase::CheckTempSize(size_t required_size) { if (required_size <= temp_size) -- cgit v1.2.3