mirror of https://github.com/PCSX2/pcsx2.git
GS: Track hash cache memory usage
This commit is contained in:
parent
5d33af13ca
commit
b3a2d3c1e4
|
@ -679,14 +679,29 @@ void GSgetStats(std::string& info)
|
|||
}
|
||||
else
|
||||
{
|
||||
info = format("%s HW | %d P | %d D | %d DC | %d RB | %d TC | %d TU",
|
||||
api_name,
|
||||
(int)pm.Get(GSPerfMon::Prim),
|
||||
(int)pm.Get(GSPerfMon::Draw),
|
||||
(int)std::ceil(pm.Get(GSPerfMon::DrawCalls)),
|
||||
(int)std::ceil(pm.Get(GSPerfMon::Readbacks)),
|
||||
(int)std::ceil(pm.Get(GSPerfMon::TextureCopies)),
|
||||
(int)std::ceil(pm.Get(GSPerfMon::TextureUploads)));
|
||||
if (GSConfig.TexturePreloading == TexturePreloadingLevel::Full)
|
||||
{
|
||||
info = format("%s HW | HC: %d MB | %d P | %d D | %d DC | %d RB | %d TC | %d TU",
|
||||
api_name,
|
||||
(int)std::ceil(static_cast<GSRendererHW*>(s_gs.get())->GetTextureCache()->GetHashCacheMemoryUsage() / 1048576.0f),
|
||||
(int)pm.Get(GSPerfMon::Prim),
|
||||
(int)pm.Get(GSPerfMon::Draw),
|
||||
(int)std::ceil(pm.Get(GSPerfMon::DrawCalls)),
|
||||
(int)std::ceil(pm.Get(GSPerfMon::Readbacks)),
|
||||
(int)std::ceil(pm.Get(GSPerfMon::TextureCopies)),
|
||||
(int)std::ceil(pm.Get(GSPerfMon::TextureUploads)));
|
||||
}
|
||||
else
|
||||
{
|
||||
info = format("%s HW | %d P | %d D | %d DC | %d RB | %d TC | %d TU",
|
||||
api_name,
|
||||
(int)pm.Get(GSPerfMon::Prim),
|
||||
(int)pm.Get(GSPerfMon::Draw),
|
||||
(int)std::ceil(pm.Get(GSPerfMon::DrawCalls)),
|
||||
(int)std::ceil(pm.Get(GSPerfMon::Readbacks)),
|
||||
(int)std::ceil(pm.Get(GSPerfMon::TextureCopies)),
|
||||
(int)std::ceil(pm.Get(GSPerfMon::TextureUploads)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -137,5 +137,5 @@ public:
|
|||
float OffsetHack_mody;
|
||||
|
||||
// Typical size of a RGBA texture
|
||||
virtual u32 GetMemUsage() { return m_size.x * m_size.y * 4; }
|
||||
virtual u32 GetMemUsage() { return m_size.x * m_size.y * (m_format == Format::UNorm8 ? 1 : 4); }
|
||||
};
|
||||
|
|
|
@ -164,6 +164,8 @@ public:
|
|||
GSRendererHW();
|
||||
virtual ~GSRendererHW() override;
|
||||
|
||||
__fi GSTextureCache* GetTextureCache() const { return m_tc; }
|
||||
|
||||
void Destroy() override;
|
||||
|
||||
void SetGameCRC(u32 crc, int options) override;
|
||||
|
|
|
@ -100,6 +100,7 @@ void GSTextureCache::RemoveAll()
|
|||
for (auto it : m_hash_cache)
|
||||
g_gs_device->Recycle(it.second.texture);
|
||||
m_hash_cache.clear();
|
||||
m_hash_cache_memory_usage = 0;
|
||||
|
||||
m_palette_map.Clear();
|
||||
}
|
||||
|
@ -1132,6 +1133,7 @@ void GSTextureCache::IncAge()
|
|||
HashCacheEntry& e = it->second;
|
||||
if (e.refcount == 0 && ++e.age > max_hash_cache_age)
|
||||
{
|
||||
m_hash_cache_memory_usage -= e.texture->GetMemUsage();
|
||||
g_gs_device->Recycle(e.texture);
|
||||
m_hash_cache.erase(it++);
|
||||
}
|
||||
|
@ -1465,6 +1467,7 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con
|
|||
// insert it into the hash cache
|
||||
HashCacheEntry entry{ src->m_texture, 1, 0 };
|
||||
it = m_hash_cache.emplace(key, entry).first;
|
||||
m_hash_cache_memory_usage += src->m_texture->GetMemUsage();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -275,6 +275,7 @@ protected:
|
|||
PaletteMap m_palette_map;
|
||||
SourceMap m_src;
|
||||
std::unordered_map<HashCacheKey, HashCacheEntry, HashCacheKeyHash> m_hash_cache;
|
||||
u64 m_hash_cache_memory_usage = 0;
|
||||
FastList<Target*> m_dst[2];
|
||||
bool m_preload_frame;
|
||||
static u8* m_temp;
|
||||
|
@ -298,6 +299,9 @@ protected:
|
|||
public:
|
||||
GSTextureCache(GSRenderer* r);
|
||||
~GSTextureCache();
|
||||
|
||||
__fi u64 GetHashCacheMemoryUsage() const { return m_hash_cache_memory_usage; }
|
||||
|
||||
void Read(Target* t, const GSVector4i& r);
|
||||
void Read(Source* t, const GSVector4i& r);
|
||||
void RemoveAll();
|
||||
|
|
Loading…
Reference in New Issue