VideoCommon: rename TextureCache to TextureCacheBase

This commit is contained in:
Tillmann Karras 2015-11-06 01:28:05 +01:00
parent f26b3708e7
commit 81d9cce70c
14 changed files with 59 additions and 59 deletions

View File

@ -337,7 +337,7 @@ void GFXDebuggerPanel::OnClearScreenButton(wxCommandEvent& event)
void GFXDebuggerPanel::OnClearTextureCacheButton(wxCommandEvent& event) void GFXDebuggerPanel::OnClearTextureCacheButton(wxCommandEvent& event)
{ {
TextureCache::Invalidate(); TextureCacheBase::Invalidate();
} }
void GFXDebuggerPanel::OnClearVertexShaderCacheButton(wxCommandEvent& event) void GFXDebuggerPanel::OnClearVertexShaderCacheButton(wxCommandEvent& event)

View File

@ -31,9 +31,9 @@ public:
void Init(); void Init();
void Shutdown(); void Shutdown();
void Encode(u8* dst, const TextureCache::TCacheEntryBase *texture_entry, void Encode(u8* dst, const TextureCacheBase::TCacheEntryBase* texture_entry,
PEControl::PixelFormat srcFormat, const EFBRectangle& srcRect, PEControl::PixelFormat srcFormat, const EFBRectangle& srcRect,
bool isIntensity, bool scaleByHalf); bool isIntensity, bool scaleByHalf);
private: private:
bool m_ready; bool m_ready;

View File

@ -878,11 +878,11 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co
OSD::DrawMessages(); OSD::DrawMessages();
D3D::EndFrame(); D3D::EndFrame();
TextureCache::Cleanup(frameCount); TextureCacheBase::Cleanup(frameCount);
// Enable configuration changes // Enable configuration changes
UpdateActiveConfig(); UpdateActiveConfig();
TextureCache::OnConfigChanged(g_ActiveConfig); TextureCacheBase::OnConfigChanged(g_ActiveConfig);
SetWindowSize(fbStride, fbHeight); SetWindowSize(fbStride, fbHeight);

View File

@ -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); 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) if (config.rendertarget)
{ {

View File

@ -10,7 +10,7 @@
namespace DX11 namespace DX11
{ {
class TextureCache : public ::TextureCache class TextureCache : public TextureCacheBase
{ {
public: public:
TextureCache(); TextureCache();

View File

@ -26,7 +26,7 @@ public:
virtual void Init() = 0; virtual void Init() = 0;
virtual void Shutdown() = 0; virtual void Shutdown() = 0;
// Returns size in bytes of encoded block of memory // 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, PEControl::PixelFormat srcFormat, const EFBRectangle& srcRect,
bool isIntensity, bool scaleByHalf) = 0; bool isIntensity, bool scaleByHalf) = 0;

View File

@ -15,7 +15,7 @@
namespace OGL namespace OGL
{ {
class TextureCache : public ::TextureCache class TextureCache : public TextureCacheBase
{ {
public: public:
TextureCache(); TextureCache();

View File

@ -26,7 +26,7 @@ void EncodeToRamYUYV(GLuint srcTexture, const TargetRectangle& sourceRc,
void DecodeToTexture(u32 xfbAddr, int srcWidth, int srcHeight, GLuint destTexture); void DecodeToTexture(u32 xfbAddr, int srcWidth, int srcHeight, GLuint destTexture);
// returns size of the encoded data (in bytes) // 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); GLuint source_texture, bool bFromZBuffer, bool bIsIntensityFmt, int bScaleByHalf, const EFBRectangle& source);
} }

View File

@ -224,9 +224,9 @@ static void BPWritten(const BPCmd& bp)
if (PE_copy.copy_to_xfb == 0) 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) // 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, TextureCacheBase::CopyRenderTargetToTexture(destAddr, PE_copy.tp_realFormat(), destStride,
bpmem.zcontrol.pixel_format, srcRect, bpmem.zcontrol.pixel_format, srcRect,
!!PE_copy.intensity_fmt, !!PE_copy.half_scale); !!PE_copy.intensity_fmt, !!PE_copy.half_scale);
} }
else else
{ {

View File

@ -227,7 +227,7 @@ void VideoBackendHardware::CheckInvalidState()
m_invalid = false; m_invalid = false;
BPReload(); BPReload();
TextureCache::Invalidate(); TextureCacheBase::Invalidate();
} }
} }

View File

@ -88,7 +88,7 @@ Renderer::Renderer()
, bLastFrameDumped(false) , bLastFrameDumped(false)
{ {
UpdateActiveConfig(); UpdateActiveConfig();
TextureCache::OnConfigChanged(g_ActiveConfig); TextureCacheBase::OnConfigChanged(g_ActiveConfig);
#if defined _WIN32 || defined HAVE_LIBAV #if defined _WIN32 || defined HAVE_LIBAV
bAVIDumping = false; bAVIDumping = false;

View File

@ -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 TEXTURE_POOL_KILL_THRESHOLD = 3;
static const int FRAMECOUNT_INVALID = 0; static const int FRAMECOUNT_INVALID = 0;
TextureCache* g_texture_cache; TextureCacheBase* g_texture_cache;
alignas(16) u8* TextureCache::temp = nullptr; alignas(16) u8* TextureCacheBase::temp = nullptr;
size_t TextureCache::temp_size; size_t TextureCacheBase::temp_size;
TextureCache::TexCache TextureCache::textures_by_address; TextureCacheBase::TexCache TextureCacheBase::textures_by_address;
TextureCache::TexCache TextureCache::textures_by_hash; TextureCacheBase::TexCache TextureCacheBase::textures_by_hash;
TextureCache::TexPool TextureCache::texture_pool; TextureCacheBase::TexPool TextureCacheBase::texture_pool;
TextureCache::TCacheEntryBase* TextureCache::bound_textures[8]; TextureCacheBase::TCacheEntryBase* TextureCacheBase::bound_textures[8];
TextureCache::BackupConfig TextureCache::backup_config; TextureCacheBase::BackupConfig TextureCacheBase::backup_config;
static bool invalidate_texture_cache_requested; 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) if (required_size <= temp_size)
return; return;
@ -56,7 +56,7 @@ void TextureCache::CheckTempSize(size_t required_size)
temp = (u8*)AllocateAlignedMemory(temp_size, 16); temp = (u8*)AllocateAlignedMemory(temp_size, 16);
} }
TextureCache::TextureCache() TextureCacheBase::TextureCacheBase()
{ {
temp_size = 2048 * 2048 * 4; temp_size = 2048 * 2048 * 4;
if (!temp) if (!temp)
@ -71,12 +71,12 @@ TextureCache::TextureCache()
invalidate_texture_cache_requested = false; invalidate_texture_cache_requested = false;
} }
void TextureCache::RequestInvalidateTextureCache() void TextureCacheBase::RequestInvalidateTextureCache()
{ {
invalidate_texture_cache_requested = true; invalidate_texture_cache_requested = true;
} }
void TextureCache::Invalidate() void TextureCacheBase::Invalidate()
{ {
UnbindTextures(); UnbindTextures();
@ -94,7 +94,7 @@ void TextureCache::Invalidate()
texture_pool.clear(); texture_pool.clear();
} }
TextureCache::~TextureCache() TextureCacheBase::~TextureCacheBase()
{ {
HiresTexture::Shutdown(); HiresTexture::Shutdown();
Invalidate(); Invalidate();
@ -102,7 +102,7 @@ TextureCache::~TextureCache()
temp = nullptr; temp = nullptr;
} }
void TextureCache::OnConfigChanged(VideoConfig& config) void TextureCacheBase::OnConfigChanged(VideoConfig& config)
{ {
if (g_texture_cache) if (g_texture_cache)
{ {
@ -143,7 +143,7 @@ void TextureCache::OnConfigChanged(VideoConfig& config)
backup_config.s_efb_mono_depth = config.bStereoEFBMonoDepth; 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 iter = textures_by_address.begin();
TexCache::iterator tcend = textures_by_address.end(); 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) if (addr + size_in_bytes <= range_address)
return false; return false;
@ -212,7 +212,7 @@ bool TextureCache::TCacheEntryBase::OverlapsMemoryRange(u32 range_address, u32 r
return true; 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; TCacheEntryBase* entry_to_update = iter_t->second;
const bool isPaletteTexture = (entry_to_update->format == GX_TF_C4 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) if (entry_to_update->config.width != w || entry_to_update->config.height != h)
{ {
TextureCache::TCacheEntryConfig newconfig; TextureCacheBase::TCacheEntryConfig newconfig;
newconfig.width = w; newconfig.width = w;
newconfig.height = h; newconfig.height = h;
newconfig.rendertarget = true; newconfig.rendertarget = true;
@ -315,7 +315,7 @@ TextureCache::TCacheEntryBase* TextureCache::DoPartialTextureUpdates(TexCache::i
return entry_to_update; 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) + std::string szDir = File::GetUserPath(D_DUMPTEXTURES_IDX) +
SConfig::GetInstance().m_strUniqueID; 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; return (level_0_size + ((1 << level) - 1)) >> level;
} }
// Used by TextureCache::Load // Used by TextureCacheBase::Load
TextureCache::TCacheEntryBase* TextureCache::ReturnEntry(unsigned int stage, TCacheEntryBase* entry) TextureCacheBase::TCacheEntryBase* TextureCacheBase::ReturnEntry(unsigned int stage, TCacheEntryBase* entry)
{ {
entry->frameCount = FRAMECOUNT_INVALID; entry->frameCount = FRAMECOUNT_INVALID;
bound_textures[stage] = entry; bound_textures[stage] = entry;
@ -350,7 +350,7 @@ TextureCache::TCacheEntryBase* TextureCache::ReturnEntry(unsigned int stage, TCa
return entry; return entry;
} }
void TextureCache::BindTextures() void TextureCacheBase::BindTextures()
{ {
for (int i = 0; i < 8; ++i) 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); 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 FourTexUnits &tex = bpmem.tex[stage >> 2];
const u32 id = stage & 3; const u32 id = stage & 3;
@ -724,8 +724,8 @@ TextureCache::TCacheEntryBase* TextureCache::Load(const u32 stage)
return ReturnEntry(stage, entry); return ReturnEntry(stage, entry);
} }
void TextureCache::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat, u32 dstStride, PEControl::PixelFormat srcFormat, void TextureCacheBase::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat, u32 dstStride, PEControl::PixelFormat srcFormat,
const EFBRectangle& srcRect, bool isIntensity, bool scaleByHalf) const EFBRectangle& srcRect, bool isIntensity, bool scaleByHalf)
{ {
// Emulation methods: // Emulation methods:
// //
@ -1101,10 +1101,10 @@ void TextureCache::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat
textures_by_address.emplace((u64)dstAddr, entry); 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); TexPool::iterator iter = texture_pool.find(config);
TextureCache::TCacheEntryBase* entry; TextureCacheBase::TCacheEntryBase* entry;
if (iter != texture_pool.end()) if (iter != texture_pool.end())
{ {
entry = iter->second; entry = iter->second;
@ -1120,7 +1120,7 @@ TextureCache::TCacheEntryBase* TextureCache::AllocateTexture(const TCacheEntryCo
return entry; return entry;
} }
TextureCache::TexCache::iterator TextureCache::FreeTexture(TexCache::iterator iter) TextureCacheBase::TexCache::iterator TextureCacheBase::FreeTexture(TexCache::iterator iter)
{ {
TCacheEntryBase* entry = iter->second; TCacheEntryBase* entry = iter->second;
@ -1136,7 +1136,7 @@ TextureCache::TexCache::iterator TextureCache::FreeTexture(TexCache::iterator it
return textures_by_address.erase(iter); return textures_by_address.erase(iter);
} }
u32 TextureCache::TCacheEntryBase::BytesPerRow() const u32 TextureCacheBase::TCacheEntryBase::BytesPerRow() const
{ {
const u32 blockW = TexDecoder_GetBlockWidthInTexels(format); const u32 blockW = TexDecoder_GetBlockWidthInTexels(format);
@ -1151,7 +1151,7 @@ u32 TextureCache::TCacheEntryBase::BytesPerRow() const
return numBlocksX * bytes_per_block; return numBlocksX * bytes_per_block;
} }
u32 TextureCache::TCacheEntryBase::NumBlocksY() const u32 TextureCacheBase::TCacheEntryBase::NumBlocksY() const
{ {
u32 blockH = TexDecoder_GetBlockHeightInTexels(format); u32 blockH = TexDecoder_GetBlockHeightInTexels(format);
// Round up source height to multiple of block size // Round up source height to multiple of block size
@ -1160,7 +1160,7 @@ u32 TextureCache::TCacheEntryBase::NumBlocksY() const
return actualHeight / blockH; return actualHeight / blockH;
} }
void TextureCache::TCacheEntryBase::SetEfbCopy(u32 stride) void TextureCacheBase::TCacheEntryBase::SetEfbCopy(u32 stride)
{ {
is_efb_copy = true; is_efb_copy = true;
memory_stride = stride; memory_stride = stride;
@ -1171,7 +1171,7 @@ void TextureCache::TCacheEntryBase::SetEfbCopy(u32 stride)
} }
// Fill gamecube memory backing this texture with zeros. // 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++) 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); u8* ptr = Memory::GetPointer(addr);
if (memory_stride == BytesPerRow()) if (memory_stride == BytesPerRow())

View File

@ -17,7 +17,7 @@
struct VideoConfig; struct VideoConfig;
class TextureCache class TextureCacheBase
{ {
public: public:
struct TCacheEntryConfig struct TCacheEntryConfig
@ -35,7 +35,7 @@ public:
struct Hasher : std::hash<u64> struct Hasher : std::hash<u64>
{ {
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; u64 id = (u64)c.rendertarget << 63 | (u64)c.layers << 48 | (u64)c.levels << 32 | (u64)c.height << 16 | (u64)c.width;
return std::hash<u64>::operator()(id); return std::hash<u64>::operator()(id);
@ -118,7 +118,7 @@ public:
u64 CalculateHash() const; u64 CalculateHash() const;
}; };
virtual ~TextureCache(); // needs virtual for DX11 dtor virtual ~TextureCacheBase(); // needs virtual for DX11 dtor
static void OnConfigChanged(VideoConfig& config); static void OnConfigChanged(VideoConfig& config);
@ -144,7 +144,7 @@ public:
virtual void ConvertTexture(TCacheEntryBase* entry, TCacheEntryBase* unconverted, void* palette, TlutFormat format) = 0; virtual void ConvertTexture(TCacheEntryBase* entry, TCacheEntryBase* unconverted, void* palette, TlutFormat format) = 0;
protected: protected:
TextureCache(); TextureCacheBase();
alignas(16) static u8* temp; alignas(16) static u8* temp;
static size_t temp_size; static size_t temp_size;
@ -180,4 +180,4 @@ private:
} backup_config; } backup_config;
}; };
extern TextureCache *g_texture_cache; extern TextureCacheBase* g_texture_cache;

View File

@ -211,10 +211,10 @@ void VertexManagerBase::Flush()
if (bpmem.tevind[i].IsActive() && bpmem.tevind[i].bt < bpmem.genMode.numindstages) if (bpmem.tevind[i].IsActive() && bpmem.tevind[i].bt < bpmem.genMode.numindstages)
usedtextures[bpmem.tevindref.getTexMap(bpmem.tevind[i].bt)] = true; usedtextures[bpmem.tevindref.getTexMap(bpmem.tevind[i].bt)] = true;
TextureCache::UnbindTextures(); TextureCacheBase::UnbindTextures();
for (unsigned int i : usedtextures) for (unsigned int i : usedtextures)
{ {
const TextureCache::TCacheEntryBase* tentry = TextureCache::Load(i); const TextureCacheBase::TCacheEntryBase* tentry = TextureCacheBase::Load(i);
if (tentry) if (tentry)
{ {
@ -226,7 +226,7 @@ void VertexManagerBase::Flush()
ERROR_LOG(VIDEO, "error loading texture"); ERROR_LOG(VIDEO, "error loading texture");
} }
} }
TextureCache::BindTextures(); TextureCacheBase::BindTextures();
} }
// set global vertex constants // set global vertex constants