diff --git a/Source/Core/DolphinWX/Debugger/DebuggerPanel.cpp b/Source/Core/DolphinWX/Debugger/DebuggerPanel.cpp index d8bcd923bc..cc818de1ed 100644 --- a/Source/Core/DolphinWX/Debugger/DebuggerPanel.cpp +++ b/Source/Core/DolphinWX/Debugger/DebuggerPanel.cpp @@ -337,7 +337,7 @@ void GFXDebuggerPanel::OnClearScreenButton(wxCommandEvent& event) void GFXDebuggerPanel::OnClearTextureCacheButton(wxCommandEvent& event) { - TextureCache::Invalidate(); + TextureCacheBase::Invalidate(); } void GFXDebuggerPanel::OnClearVertexShaderCacheButton(wxCommandEvent& event) diff --git a/Source/Core/VideoBackends/D3D/PSTextureEncoder.h b/Source/Core/VideoBackends/D3D/PSTextureEncoder.h index 2857e9de7e..40f49a0728 100644 --- a/Source/Core/VideoBackends/D3D/PSTextureEncoder.h +++ b/Source/Core/VideoBackends/D3D/PSTextureEncoder.h @@ -31,9 +31,9 @@ public: void Init(); void Shutdown(); - void Encode(u8* dst, const TextureCache::TCacheEntryBase *texture_entry, - PEControl::PixelFormat srcFormat, const EFBRectangle& srcRect, - bool isIntensity, bool scaleByHalf); + void Encode(u8* dst, const TextureCacheBase::TCacheEntryBase* texture_entry, + PEControl::PixelFormat srcFormat, const EFBRectangle& srcRect, + bool isIntensity, bool scaleByHalf); private: bool m_ready; diff --git a/Source/Core/VideoBackends/D3D/Render.cpp b/Source/Core/VideoBackends/D3D/Render.cpp index f1a146347c..a984ff6304 100644 --- a/Source/Core/VideoBackends/D3D/Render.cpp +++ b/Source/Core/VideoBackends/D3D/Render.cpp @@ -878,11 +878,11 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co OSD::DrawMessages(); D3D::EndFrame(); - TextureCache::Cleanup(frameCount); + TextureCacheBase::Cleanup(frameCount); // Enable configuration changes UpdateActiveConfig(); - TextureCache::OnConfigChanged(g_ActiveConfig); + TextureCacheBase::OnConfigChanged(g_ActiveConfig); SetWindowSize(fbStride, fbHeight); diff --git a/Source/Core/VideoBackends/D3D/TextureCache.cpp b/Source/Core/VideoBackends/D3D/TextureCache.cpp index 602c00cb18..1738a1f4d5 100644 --- a/Source/Core/VideoBackends/D3D/TextureCache.cpp +++ b/Source/Core/VideoBackends/D3D/TextureCache.cpp @@ -145,7 +145,7 @@ void TextureCache::TCacheEntry::Load(unsigned int width, unsigned int height, D3D::ReplaceRGBATexture2D(texture->GetTex(), TextureCache::temp, width, height, expanded_width, level, usage); } -TextureCache::TCacheEntryBase* TextureCache::CreateTexture(const TCacheEntryConfig& config) +TextureCacheBase::TCacheEntryBase* TextureCache::CreateTexture(const TCacheEntryConfig& config) { if (config.rendertarget) { diff --git a/Source/Core/VideoBackends/D3D/TextureCache.h b/Source/Core/VideoBackends/D3D/TextureCache.h index 4fed08ff65..fa6aeafc3b 100644 --- a/Source/Core/VideoBackends/D3D/TextureCache.h +++ b/Source/Core/VideoBackends/D3D/TextureCache.h @@ -10,7 +10,7 @@ namespace DX11 { -class TextureCache : public ::TextureCache +class TextureCache : public TextureCacheBase { public: TextureCache(); diff --git a/Source/Core/VideoBackends/D3D/TextureEncoder.h b/Source/Core/VideoBackends/D3D/TextureEncoder.h index 445fffd218..2e3eef99ad 100644 --- a/Source/Core/VideoBackends/D3D/TextureEncoder.h +++ b/Source/Core/VideoBackends/D3D/TextureEncoder.h @@ -26,7 +26,7 @@ public: virtual void Init() = 0; virtual void Shutdown() = 0; // Returns size in bytes of encoded block of memory - virtual void Encode(u8* dst, const TextureCache::TCacheEntryBase *texture_entry, + virtual void Encode(u8* dst, const TextureCacheBase::TCacheEntryBase* texture_entry, PEControl::PixelFormat srcFormat, const EFBRectangle& srcRect, bool isIntensity, bool scaleByHalf) = 0; diff --git a/Source/Core/VideoBackends/OGL/TextureCache.h b/Source/Core/VideoBackends/OGL/TextureCache.h index d24fc816f4..10c4a57378 100644 --- a/Source/Core/VideoBackends/OGL/TextureCache.h +++ b/Source/Core/VideoBackends/OGL/TextureCache.h @@ -15,7 +15,7 @@ namespace OGL { -class TextureCache : public ::TextureCache +class TextureCache : public TextureCacheBase { public: TextureCache(); diff --git a/Source/Core/VideoBackends/OGL/TextureConverter.h b/Source/Core/VideoBackends/OGL/TextureConverter.h index daec781a87..b13bbc57f2 100644 --- a/Source/Core/VideoBackends/OGL/TextureConverter.h +++ b/Source/Core/VideoBackends/OGL/TextureConverter.h @@ -26,7 +26,7 @@ void EncodeToRamYUYV(GLuint srcTexture, const TargetRectangle& sourceRc, void DecodeToTexture(u32 xfbAddr, int srcWidth, int srcHeight, GLuint destTexture); // returns size of the encoded data (in bytes) -void EncodeToRamFromTexture(u8 *dest_ptr, const TextureCache::TCacheEntryBase *texture_entry, +void EncodeToRamFromTexture(u8* dest_ptr, const TextureCacheBase::TCacheEntryBase* texture_entry, GLuint source_texture, bool bFromZBuffer, bool bIsIntensityFmt, int bScaleByHalf, const EFBRectangle& source); } diff --git a/Source/Core/VideoCommon/BPStructs.cpp b/Source/Core/VideoCommon/BPStructs.cpp index 0b94fcc2cc..6dc505c28e 100644 --- a/Source/Core/VideoCommon/BPStructs.cpp +++ b/Source/Core/VideoCommon/BPStructs.cpp @@ -224,9 +224,9 @@ static void BPWritten(const BPCmd& bp) if (PE_copy.copy_to_xfb == 0) { // bpmem.zcontrol.pixel_format to PEControl::Z24 is when the game wants to copy from ZBuffer (Zbuffer uses 24-bit Format) - TextureCache::CopyRenderTargetToTexture(destAddr, PE_copy.tp_realFormat(), destStride, - bpmem.zcontrol.pixel_format, srcRect, - !!PE_copy.intensity_fmt, !!PE_copy.half_scale); + TextureCacheBase::CopyRenderTargetToTexture(destAddr, PE_copy.tp_realFormat(), destStride, + bpmem.zcontrol.pixel_format, srcRect, + !!PE_copy.intensity_fmt, !!PE_copy.half_scale); } else { diff --git a/Source/Core/VideoCommon/MainBase.cpp b/Source/Core/VideoCommon/MainBase.cpp index fc36906cdb..72ba4c5bef 100644 --- a/Source/Core/VideoCommon/MainBase.cpp +++ b/Source/Core/VideoCommon/MainBase.cpp @@ -227,7 +227,7 @@ void VideoBackendHardware::CheckInvalidState() m_invalid = false; BPReload(); - TextureCache::Invalidate(); + TextureCacheBase::Invalidate(); } } diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index 75d646adc7..89bfa4dce1 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -88,7 +88,7 @@ Renderer::Renderer() , bLastFrameDumped(false) { UpdateActiveConfig(); - TextureCache::OnConfigChanged(g_ActiveConfig); + TextureCacheBase::OnConfigChanged(g_ActiveConfig); #if defined _WIN32 || defined HAVE_LIBAV bAVIDumping = false; diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index c404e0d4df..9ed4a72261 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -28,25 +28,25 @@ static const int TEXTURE_KILL_THRESHOLD = 64; // Sonic the Fighters (inside Soni static const int TEXTURE_POOL_KILL_THRESHOLD = 3; static const int FRAMECOUNT_INVALID = 0; -TextureCache* g_texture_cache; +TextureCacheBase* g_texture_cache; -alignas(16) u8* TextureCache::temp = nullptr; -size_t TextureCache::temp_size; +alignas(16) u8* TextureCacheBase::temp = nullptr; +size_t TextureCacheBase::temp_size; -TextureCache::TexCache TextureCache::textures_by_address; -TextureCache::TexCache TextureCache::textures_by_hash; -TextureCache::TexPool TextureCache::texture_pool; -TextureCache::TCacheEntryBase* TextureCache::bound_textures[8]; +TextureCacheBase::TexCache TextureCacheBase::textures_by_address; +TextureCacheBase::TexCache TextureCacheBase::textures_by_hash; +TextureCacheBase::TexPool TextureCacheBase::texture_pool; +TextureCacheBase::TCacheEntryBase* TextureCacheBase::bound_textures[8]; -TextureCache::BackupConfig TextureCache::backup_config; +TextureCacheBase::BackupConfig TextureCacheBase::backup_config; static bool invalidate_texture_cache_requested; -TextureCache::TCacheEntryBase::~TCacheEntryBase() +TextureCacheBase::TCacheEntryBase::~TCacheEntryBase() { } -void TextureCache::CheckTempSize(size_t required_size) +void TextureCacheBase::CheckTempSize(size_t required_size) { if (required_size <= temp_size) return; @@ -56,7 +56,7 @@ void TextureCache::CheckTempSize(size_t required_size) temp = (u8*)AllocateAlignedMemory(temp_size, 16); } -TextureCache::TextureCache() +TextureCacheBase::TextureCacheBase() { temp_size = 2048 * 2048 * 4; if (!temp) @@ -71,12 +71,12 @@ TextureCache::TextureCache() invalidate_texture_cache_requested = false; } -void TextureCache::RequestInvalidateTextureCache() +void TextureCacheBase::RequestInvalidateTextureCache() { invalidate_texture_cache_requested = true; } -void TextureCache::Invalidate() +void TextureCacheBase::Invalidate() { UnbindTextures(); @@ -94,7 +94,7 @@ void TextureCache::Invalidate() texture_pool.clear(); } -TextureCache::~TextureCache() +TextureCacheBase::~TextureCacheBase() { HiresTexture::Shutdown(); Invalidate(); @@ -102,7 +102,7 @@ TextureCache::~TextureCache() temp = nullptr; } -void TextureCache::OnConfigChanged(VideoConfig& config) +void TextureCacheBase::OnConfigChanged(VideoConfig& config) { if (g_texture_cache) { @@ -143,7 +143,7 @@ void TextureCache::OnConfigChanged(VideoConfig& config) backup_config.s_efb_mono_depth = config.bStereoEFBMonoDepth; } -void TextureCache::Cleanup(int _frameCount) +void TextureCacheBase::Cleanup(int _frameCount) { TexCache::iterator iter = textures_by_address.begin(); TexCache::iterator tcend = textures_by_address.end(); @@ -201,7 +201,7 @@ void TextureCache::Cleanup(int _frameCount) } } -bool TextureCache::TCacheEntryBase::OverlapsMemoryRange(u32 range_address, u32 range_size) const +bool TextureCacheBase::TCacheEntryBase::OverlapsMemoryRange(u32 range_address, u32 range_size) const { if (addr + size_in_bytes <= range_address) return false; @@ -212,7 +212,7 @@ bool TextureCache::TCacheEntryBase::OverlapsMemoryRange(u32 range_address, u32 r return true; } -TextureCache::TCacheEntryBase* TextureCache::DoPartialTextureUpdates(TexCache::iterator iter_t) +TextureCacheBase::TCacheEntryBase* TextureCacheBase::DoPartialTextureUpdates(TexCache::iterator iter_t) { TCacheEntryBase* entry_to_update = iter_t->second; const bool isPaletteTexture = (entry_to_update->format == GX_TF_C4 @@ -272,7 +272,7 @@ TextureCache::TCacheEntryBase* TextureCache::DoPartialTextureUpdates(TexCache::i } if (entry_to_update->config.width != w || entry_to_update->config.height != h) { - TextureCache::TCacheEntryConfig newconfig; + TextureCacheBase::TCacheEntryConfig newconfig; newconfig.width = w; newconfig.height = h; newconfig.rendertarget = true; @@ -315,7 +315,7 @@ TextureCache::TCacheEntryBase* TextureCache::DoPartialTextureUpdates(TexCache::i return entry_to_update; } -void TextureCache::DumpTexture(TCacheEntryBase* entry, std::string basename, unsigned int level) +void TextureCacheBase::DumpTexture(TCacheEntryBase* entry, std::string basename, unsigned int level) { std::string szDir = File::GetUserPath(D_DUMPTEXTURES_IDX) + SConfig::GetInstance().m_strUniqueID; @@ -339,8 +339,8 @@ static u32 CalculateLevelSize(u32 level_0_size, u32 level) return (level_0_size + ((1 << level) - 1)) >> level; } -// Used by TextureCache::Load -TextureCache::TCacheEntryBase* TextureCache::ReturnEntry(unsigned int stage, TCacheEntryBase* entry) +// Used by TextureCacheBase::Load +TextureCacheBase::TCacheEntryBase* TextureCacheBase::ReturnEntry(unsigned int stage, TCacheEntryBase* entry) { entry->frameCount = FRAMECOUNT_INVALID; bound_textures[stage] = entry; @@ -350,7 +350,7 @@ TextureCache::TCacheEntryBase* TextureCache::ReturnEntry(unsigned int stage, TCa return entry; } -void TextureCache::BindTextures() +void TextureCacheBase::BindTextures() { for (int i = 0; i < 8; ++i) { @@ -359,12 +359,12 @@ void TextureCache::BindTextures() } } -void TextureCache::UnbindTextures() +void TextureCacheBase::UnbindTextures() { std::fill(std::begin(bound_textures), std::end(bound_textures), nullptr); } -TextureCache::TCacheEntryBase* TextureCache::Load(const u32 stage) +TextureCacheBase::TCacheEntryBase* TextureCacheBase::Load(const u32 stage) { const FourTexUnits &tex = bpmem.tex[stage >> 2]; const u32 id = stage & 3; @@ -724,8 +724,8 @@ TextureCache::TCacheEntryBase* TextureCache::Load(const u32 stage) return ReturnEntry(stage, entry); } -void TextureCache::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat, u32 dstStride, PEControl::PixelFormat srcFormat, - const EFBRectangle& srcRect, bool isIntensity, bool scaleByHalf) +void TextureCacheBase::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat, u32 dstStride, PEControl::PixelFormat srcFormat, + const EFBRectangle& srcRect, bool isIntensity, bool scaleByHalf) { // Emulation methods: // @@ -1101,10 +1101,10 @@ void TextureCache::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat textures_by_address.emplace((u64)dstAddr, entry); } -TextureCache::TCacheEntryBase* TextureCache::AllocateTexture(const TCacheEntryConfig& config) +TextureCacheBase::TCacheEntryBase* TextureCacheBase::AllocateTexture(const TCacheEntryConfig& config) { TexPool::iterator iter = texture_pool.find(config); - TextureCache::TCacheEntryBase* entry; + TextureCacheBase::TCacheEntryBase* entry; if (iter != texture_pool.end()) { entry = iter->second; @@ -1120,7 +1120,7 @@ TextureCache::TCacheEntryBase* TextureCache::AllocateTexture(const TCacheEntryCo return entry; } -TextureCache::TexCache::iterator TextureCache::FreeTexture(TexCache::iterator iter) +TextureCacheBase::TexCache::iterator TextureCacheBase::FreeTexture(TexCache::iterator iter) { TCacheEntryBase* entry = iter->second; @@ -1136,7 +1136,7 @@ TextureCache::TexCache::iterator TextureCache::FreeTexture(TexCache::iterator it return textures_by_address.erase(iter); } -u32 TextureCache::TCacheEntryBase::BytesPerRow() const +u32 TextureCacheBase::TCacheEntryBase::BytesPerRow() const { const u32 blockW = TexDecoder_GetBlockWidthInTexels(format); @@ -1151,7 +1151,7 @@ u32 TextureCache::TCacheEntryBase::BytesPerRow() const return numBlocksX * bytes_per_block; } -u32 TextureCache::TCacheEntryBase::NumBlocksY() const +u32 TextureCacheBase::TCacheEntryBase::NumBlocksY() const { u32 blockH = TexDecoder_GetBlockHeightInTexels(format); // Round up source height to multiple of block size @@ -1160,7 +1160,7 @@ u32 TextureCache::TCacheEntryBase::NumBlocksY() const return actualHeight / blockH; } -void TextureCache::TCacheEntryBase::SetEfbCopy(u32 stride) +void TextureCacheBase::TCacheEntryBase::SetEfbCopy(u32 stride) { is_efb_copy = true; memory_stride = stride; @@ -1171,7 +1171,7 @@ void TextureCache::TCacheEntryBase::SetEfbCopy(u32 stride) } // Fill gamecube memory backing this texture with zeros. -void TextureCache::TCacheEntryBase::Zero(u8* ptr) +void TextureCacheBase::TCacheEntryBase::Zero(u8* ptr) { for (u32 i = 0; i < NumBlocksY(); i++) { @@ -1180,7 +1180,7 @@ void TextureCache::TCacheEntryBase::Zero(u8* ptr) } } -u64 TextureCache::TCacheEntryBase::CalculateHash() const +u64 TextureCacheBase::TCacheEntryBase::CalculateHash() const { u8* ptr = Memory::GetPointer(addr); if (memory_stride == BytesPerRow()) diff --git a/Source/Core/VideoCommon/TextureCacheBase.h b/Source/Core/VideoCommon/TextureCacheBase.h index e7d274818c..9ecb61c8ae 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.h +++ b/Source/Core/VideoCommon/TextureCacheBase.h @@ -17,7 +17,7 @@ struct VideoConfig; -class TextureCache +class TextureCacheBase { public: struct TCacheEntryConfig @@ -35,7 +35,7 @@ public: struct Hasher : std::hash { - size_t operator()(const TextureCache::TCacheEntryConfig& c) const + size_t operator()(const TextureCacheBase::TCacheEntryConfig& c) const { u64 id = (u64)c.rendertarget << 63 | (u64)c.layers << 48 | (u64)c.levels << 32 | (u64)c.height << 16 | (u64)c.width; return std::hash::operator()(id); @@ -118,7 +118,7 @@ public: u64 CalculateHash() const; }; - virtual ~TextureCache(); // needs virtual for DX11 dtor + virtual ~TextureCacheBase(); // needs virtual for DX11 dtor static void OnConfigChanged(VideoConfig& config); @@ -144,7 +144,7 @@ public: virtual void ConvertTexture(TCacheEntryBase* entry, TCacheEntryBase* unconverted, void* palette, TlutFormat format) = 0; protected: - TextureCache(); + TextureCacheBase(); alignas(16) static u8* temp; static size_t temp_size; @@ -180,4 +180,4 @@ private: } backup_config; }; -extern TextureCache *g_texture_cache; +extern TextureCacheBase* g_texture_cache; diff --git a/Source/Core/VideoCommon/VertexManagerBase.cpp b/Source/Core/VideoCommon/VertexManagerBase.cpp index 973e93e9b4..84f24cd6e2 100644 --- a/Source/Core/VideoCommon/VertexManagerBase.cpp +++ b/Source/Core/VideoCommon/VertexManagerBase.cpp @@ -211,10 +211,10 @@ void VertexManagerBase::Flush() if (bpmem.tevind[i].IsActive() && bpmem.tevind[i].bt < bpmem.genMode.numindstages) usedtextures[bpmem.tevindref.getTexMap(bpmem.tevind[i].bt)] = true; - TextureCache::UnbindTextures(); + TextureCacheBase::UnbindTextures(); for (unsigned int i : usedtextures) { - const TextureCache::TCacheEntryBase* tentry = TextureCache::Load(i); + const TextureCacheBase::TCacheEntryBase* tentry = TextureCacheBase::Load(i); if (tentry) { @@ -226,7 +226,7 @@ void VertexManagerBase::Flush() ERROR_LOG(VIDEO, "error loading texture"); } } - TextureCache::BindTextures(); + TextureCacheBase::BindTextures(); } // set global vertex constants