diff options
| author | Markus Wick <markus+github@selfnet.de> | 2015-01-13 22:45:49 +0100 |
|---|---|---|
| committer | Markus Wick <markus+github@selfnet.de> | 2015-01-13 22:45:49 +0100 |
| commit | 7069450ce570dea3e9a286f7f3538122f5d0f99c (patch) | |
| tree | 203d2ae24edde90b5e0fd383e897e51b879f0350 /Source/Core/VideoCommon/TextureCacheBase.h | |
| parent | 0932282caf926347c60f49af60c17612fc9624b5 (diff) | |
| parent | 22e06daf5c41c3d201edba8c22c85df5bafee63b (diff) | |
Merge pull request #1872 from degasus/texcache
Texcache cleanup 2
Diffstat (limited to 'Source/Core/VideoCommon/TextureCacheBase.h')
| -rw-r--r-- | Source/Core/VideoCommon/TextureCacheBase.h | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/Source/Core/VideoCommon/TextureCacheBase.h b/Source/Core/VideoCommon/TextureCacheBase.h index 0b8cf48918..0b58591939 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.h +++ b/Source/Core/VideoCommon/TextureCacheBase.h @@ -25,9 +25,18 @@ public: TCET_EC_DYNAMIC, // EFB copy which sits in RAM and needs to be decoded before being used }; + struct TCacheEntryConfig + { + TCacheEntryConfig() : width(0), height(0), levels(1), layers(1), rendertarget(false) {} + + u32 width, height; + u32 levels, layers; + bool rendertarget; + }; + struct TCacheEntryBase { -#define TEXHASH_INVALID 0 + const TCacheEntryConfig config; // common members u32 addr; @@ -37,30 +46,25 @@ public: enum TexCacheEntryType type; - unsigned int num_mipmaps; - unsigned int num_layers; unsigned int native_width, native_height; // Texture dimensions from the GameCube's point of view - unsigned int virtual_width, virtual_height; // Texture dimensions from OUR point of view - for hires textures or scaled EFB copies + unsigned int native_levels; // used to delete textures which haven't been used for TEXTURE_KILL_THRESHOLD frames int frameCount; - void SetGeneralParameters(u32 _addr, u32 _size, u32 _format, unsigned int _num_mipmaps, unsigned int _num_layers) + void SetGeneralParameters(u32 _addr, u32 _size, u32 _format) { addr = _addr; size_in_bytes = _size; format = _format; - num_mipmaps = _num_mipmaps; - num_layers = _num_layers; } - void SetDimensions(unsigned int _native_width, unsigned int _native_height, unsigned int _virtual_width, unsigned int _virtual_height) + void SetDimensions(unsigned int _native_width, unsigned int _native_height, unsigned int _native_levels) { native_width = _native_width; native_height = _native_height; - virtual_width = _virtual_width; - virtual_height = _virtual_height; + native_levels = _native_levels; } void SetHashes(u64 _hash) @@ -68,7 +72,7 @@ public: hash = _hash; } - + TCacheEntryBase(const TCacheEntryConfig& c) : config(c) {} virtual ~TCacheEntryBase(); virtual void Bind(unsigned int stage) = 0; @@ -81,7 +85,7 @@ public: bool isIntensity, bool scaleByHalf, unsigned int cbufid, const float *colmat) = 0; - int IntersectsMemoryRange(u32 range_address, u32 range_size) const; + bool OverlapsMemoryRange(u32 range_address, u32 range_size) const; bool IsEfbCopy() { return (type == TCET_EC_VRAM || type == TCET_EC_DYNAMIC); } }; @@ -89,7 +93,10 @@ public: virtual ~TextureCache(); // needs virtual for DX11 dtor static void OnConfigChanged(VideoConfig& config); - static void Cleanup(); + + // Removes textures which aren't used for more than TEXTURE_KILL_THRESHOLD frames, + // frameCount is the current frame number. + static void Cleanup(int frameCount); static void Invalidate(); static void InvalidateRange(u32 start_address, u32 size); @@ -99,13 +106,12 @@ public: virtual TCacheEntryBase* CreateTexture(unsigned int width, unsigned int height, unsigned int tex_levels, PC_TexFormat pcfmt) = 0; - virtual TCacheEntryBase* CreateRenderTargetTexture(unsigned int scaled_tex_w, unsigned int scaled_tex_h) = 0; + virtual TCacheEntryBase* CreateRenderTargetTexture(unsigned int scaled_tex_w, unsigned int scaled_tex_h, unsigned int layers) = 0; virtual void CompileShaders() = 0; // currently only implemented by OGL virtual void DeleteShaders() = 0; // currently only implemented by OGL - static TCacheEntryBase* Load(unsigned int stage, u32 address, unsigned int width, unsigned int height, - int format, unsigned int tlutaddr, int tlutfmt, bool use_mipmaps, unsigned int maxlevel, bool from_tmem); + static TCacheEntryBase* Load(const u32 stage); static void CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat, PEControl::PixelFormat srcFormat, const EFBRectangle& srcRect, bool isIntensity, bool scaleByHalf); @@ -121,7 +127,7 @@ private: static void DumpTexture(TCacheEntryBase* entry, std::string basename, unsigned int level); static void CheckTempSize(size_t required_size); - static TCacheEntryBase* AllocateRenderTarget(unsigned int width, unsigned int height); + static TCacheEntryBase* AllocateRenderTarget(unsigned int width, unsigned int height, unsigned int layers); static void FreeRenderTarget(TCacheEntryBase* entry); typedef std::map<u32, TCacheEntryBase*> TexCache; @@ -134,10 +140,6 @@ private: static struct BackupConfig { int s_colorsamples; - bool s_copy_efb_to_texture; - bool s_copy_efb_scaled; - bool s_copy_efb; - int s_efb_scale; bool s_texfmt_overlay; bool s_texfmt_overlay_center; bool s_hires_textures; |
