diff options
| author | Mat M <mathew1800@gmail.com> | 2016-12-23 04:33:42 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-12-23 04:33:42 -0500 |
| commit | 9160be50dbfa31073eda0148378786f69b219805 (patch) | |
| tree | 579bca3b98e8dd47ec3b18911504a669a2853cf9 /Source/Core/VideoCommon/TextureCacheBase.h | |
| parent | f2322bee90c1bd973a6cc4e99d4df78c7d2d0027 (diff) | |
| parent | 58a53951735aba77899ea8f8910a6b68dc52449a (diff) | |
Merge pull request #4224 from lioncash/tcache
TextureCacheBase: Eliminate static state
Diffstat (limited to 'Source/Core/VideoCommon/TextureCacheBase.h')
| -rw-r--r-- | Source/Core/VideoCommon/TextureCacheBase.h | 80 |
1 files changed, 41 insertions, 39 deletions
diff --git a/Source/Core/VideoCommon/TextureCacheBase.h b/Source/Core/VideoCommon/TextureCacheBase.h index 437392569f..f097037fa2 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.h +++ b/Source/Core/VideoCommon/TextureCacheBase.h @@ -127,16 +127,13 @@ public: const MathUtil::Rectangle<int>& srcrect, const MathUtil::Rectangle<int>& dstrect) = 0; - virtual void Load(unsigned int width, unsigned int height, unsigned int expanded_width, - unsigned int level) = 0; + virtual void Load(const u8* buffer, u32 width, u32 height, u32 expanded_width, u32 level) = 0; virtual void FromRenderTarget(u8* dst, PEControl::PixelFormat srcFormat, const EFBRectangle& srcRect, bool scaleByHalf, unsigned int cbufid, const float* colmat) = 0; bool OverlapsMemoryRange(u32 range_address, u32 range_size) const; - TextureCacheBase::TCacheEntryBase* ApplyPalette(u8* palette, u32 tlutfmt); - bool IsEfbCopy() const { return is_efb_copy; } u32 NumBlocksY() const; u32 BytesPerRow() const; @@ -146,13 +143,13 @@ public: virtual ~TextureCacheBase(); // needs virtual for DX11 dtor - static void OnConfigChanged(VideoConfig& config); + void OnConfigChanged(VideoConfig& config); // Removes textures which aren't used for more than TEXTURE_KILL_THRESHOLD frames, // frameCount is the current frame number. - static void Cleanup(int _frameCount); + void Cleanup(int _frameCount); - static void Invalidate(); + void Invalidate(); virtual TCacheEntryBase* CreateTexture(const TCacheEntryConfig& config) = 0; @@ -163,13 +160,12 @@ public: virtual bool CompileShaders() = 0; virtual void DeleteShaders() = 0; - static TCacheEntryBase* Load(const u32 stage); - static void UnbindTextures(); + TCacheEntryBase* Load(const u32 stage); + void UnbindTextures(); virtual void BindTextures(); - static void CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat, u32 dstStride, - PEControl::PixelFormat srcFormat, - const EFBRectangle& srcRect, bool isIntensity, - bool scaleByHalf); + void CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat, u32 dstStride, + PEControl::PixelFormat srcFormat, const EFBRectangle& srcRect, + bool isIntensity, bool scaleByHalf); virtual void ConvertTexture(TCacheEntryBase* entry, TCacheEntryBase* unconverted, void* palette, TlutFormat format) = 0; @@ -177,46 +173,52 @@ public: protected: TextureCacheBase(); - alignas(16) static u8* temp; - static size_t temp_size; + alignas(16) u8* temp = nullptr; + size_t temp_size = 0; - static TCacheEntryBase* bound_textures[8]; + TCacheEntryBase* bound_textures[8] = {}; private: typedef std::multimap<u64, TCacheEntryBase*> TexCache; typedef std::unordered_multimap<TCacheEntryConfig, TCacheEntryBase*, TCacheEntryConfig::Hasher> TexPool; - static void ScaleTextureCacheEntryTo(TCacheEntryBase** entry, u32 new_width, u32 new_height); - static TCacheEntryBase* DoPartialTextureUpdates(TexCache::iterator iter, u8* palette, - u32 tlutfmt); - static void DumpTexture(TCacheEntryBase* entry, std::string basename, unsigned int level); - static void CheckTempSize(size_t required_size); - static TCacheEntryBase* AllocateTexture(const TCacheEntryConfig& config); - static TexPool::iterator FindMatchingTextureFromPool(const TCacheEntryConfig& config); - static TexCache::iterator GetTexCacheIter(TCacheEntryBase* entry); + void SetBackupConfig(const VideoConfig& config); + + TCacheEntryBase* ApplyPaletteToEntry(TCacheEntryBase* entry, u8* palette, u32 tlutfmt); + + void ScaleTextureCacheEntryTo(TCacheEntryBase** entry, u32 new_width, u32 new_height); + TCacheEntryBase* DoPartialTextureUpdates(TexCache::iterator iter, u8* palette, u32 tlutfmt); + + void DumpTexture(TCacheEntryBase* entry, std::string basename, unsigned int level); + void CheckTempSize(size_t required_size); + + TCacheEntryBase* AllocateTexture(const TCacheEntryConfig& config); + TexPool::iterator FindMatchingTextureFromPool(const TCacheEntryConfig& config); + TexCache::iterator GetTexCacheIter(TCacheEntryBase* entry); // Removes and unlinks texture from texture cache and returns it to the pool - static TexCache::iterator InvalidateTexture(TexCache::iterator t_iter); + TexCache::iterator InvalidateTexture(TexCache::iterator t_iter); - static TCacheEntryBase* ReturnEntry(unsigned int stage, TCacheEntryBase* entry); + TCacheEntryBase* ReturnEntry(unsigned int stage, TCacheEntryBase* entry); - static TexCache textures_by_address; - static TexCache textures_by_hash; - static TexPool texture_pool; + TexCache textures_by_address; + TexCache textures_by_hash; + TexPool texture_pool; // Backup configuration values - static struct BackupConfig + struct BackupConfig { - int s_colorsamples; - bool s_texfmt_overlay; - bool s_texfmt_overlay_center; - bool s_hires_textures; - bool s_cache_hires_textures; - bool s_copy_cache_enable; - bool s_stereo_3d; - bool s_efb_mono_depth; - } backup_config; + int color_samples; + bool texfmt_overlay; + bool texfmt_overlay_center; + bool hires_textures; + bool cache_hires_textures; + bool copy_cache_enable; + bool stereo_3d; + bool efb_mono_depth; + }; + BackupConfig backup_config = {}; }; extern std::unique_ptr<TextureCacheBase> g_texture_cache; |
