diff options
| author | Stenzek <stenzek@gmail.com> | 2017-04-29 00:53:32 +1000 |
|---|---|---|
| committer | Stenzek <stenzek@gmail.com> | 2017-04-29 13:46:43 +1000 |
| commit | cc851c41c11bdc1c192003021df6dc3c2d2b74fb (patch) | |
| tree | 35df546c2be195f456b8c85993c4549cdd176796 /Source/Core/VideoCommon | |
| parent | de348fc9527f640435d57676a60317a96d217dd8 (diff) | |
TextureCache: Move host texture utility functions to VideoCommon
The appropriate place for these would be AbstractTexture, once it is
finished.
Diffstat (limited to 'Source/Core/VideoCommon')
| -rw-r--r-- | Source/Core/VideoCommon/TextureCacheBase.cpp | 23 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/TextureCacheBase.h | 4 |
2 files changed, 27 insertions, 0 deletions
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<size_t>(std::max(1u, row_length / 4)) * 8; + + case HostTextureFormat::DXT3: + case HostTextureFormat::DXT5: + return static_cast<size_t>(std::max(1u, row_length / 4)) * 16; + + case HostTextureFormat::RGBA8: + default: + return static_cast<size_t>(row_length) * 4; + } +} + void TextureCacheBase::CheckTempSize(size_t required_size) { if (required_size <= temp_size) diff --git a/Source/Core/VideoCommon/TextureCacheBase.h b/Source/Core/VideoCommon/TextureCacheBase.h index f621f7d92a..7f2491a5c7 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.h +++ b/Source/Core/VideoCommon/TextureCacheBase.h @@ -146,6 +146,10 @@ public: virtual ~TextureCacheBase(); // needs virtual for DX11 dtor + // TODO: Move these to AbstractTexture once it is finished. + static bool IsCompressedHostTextureFormat(HostTextureFormat format); + static size_t CalculateHostTextureLevelPitch(HostTextureFormat format, u32 row_length); + void OnConfigChanged(VideoConfig& config); // Removes textures which aren't used for more than TEXTURE_KILL_THRESHOLD frames, |
