PPCCache: Stop storing lookup table in savestates
These lookup tables total 4 megabytes, and contain data that's entirely redundant to the actual cache state (as part of an optimization, though I'm not sure whether the optimization actually is useful). This change instead recomputes these lookup tables when loading the state (which involves filling the lookup table with a marker (0xff), and then setting the 128 * 8 valid entries (1 kilobyte)).
This commit is contained in:
parent
fb45ed3981
commit
134397754e
|
@ -204,13 +204,53 @@ u32 InstructionCache::ReadInstruction(u32 addr)
|
|||
|
||||
void InstructionCache::DoState(PointerWrap& p)
|
||||
{
|
||||
if (p.IsReadMode())
|
||||
{
|
||||
// Clear valid parts of the lookup tables (this is done instead of using fill(0xff) to avoid
|
||||
// loading the entire 4MB of tables into cache)
|
||||
for (u32 set = 0; set < ICACHE_SETS; set++)
|
||||
{
|
||||
for (u32 way = 0; way < ICACHE_WAYS; way++)
|
||||
{
|
||||
if ((valid[set] & (1 << way)) != 0)
|
||||
{
|
||||
const u32 addr = (tags[set][way] << 12) | (set << 5);
|
||||
if (addr & ICACHE_VMEM_BIT)
|
||||
lookup_table_vmem[(addr >> 5) & 0xfffff] = 0xff;
|
||||
else if (addr & ICACHE_EXRAM_BIT)
|
||||
lookup_table_ex[(addr >> 5) & 0x1fffff] = 0xff;
|
||||
else
|
||||
lookup_table[(addr >> 5) & 0xfffff] = 0xff;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
p.DoArray(data);
|
||||
p.DoArray(tags);
|
||||
p.DoArray(plru);
|
||||
p.DoArray(valid);
|
||||
p.DoArray(lookup_table);
|
||||
p.DoArray(lookup_table_ex);
|
||||
p.DoArray(lookup_table_vmem);
|
||||
|
||||
if (p.IsReadMode())
|
||||
{
|
||||
// Recompute lookup tables
|
||||
for (u32 set = 0; set < ICACHE_SETS; set++)
|
||||
{
|
||||
for (u32 way = 0; way < ICACHE_WAYS; way++)
|
||||
{
|
||||
if ((valid[set] & (1 << way)) != 0)
|
||||
{
|
||||
const u32 addr = (tags[set][way] << 12) | (set << 5);
|
||||
if (addr & ICACHE_VMEM_BIT)
|
||||
lookup_table_vmem[(addr >> 5) & 0xfffff] = way;
|
||||
else if (addr & ICACHE_EXRAM_BIT)
|
||||
lookup_table_ex[(addr >> 5) & 0x1fffff] = way;
|
||||
else
|
||||
lookup_table[(addr >> 5) & 0xfffff] = way;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void InstructionCache::RefreshConfig()
|
||||
|
|
|
@ -27,6 +27,8 @@ struct InstructionCache
|
|||
std::array<u32, ICACHE_SETS> plru{};
|
||||
std::array<u32, ICACHE_SETS> valid{};
|
||||
|
||||
// Note: This is only for performance purposes; this same data could be computed at runtime
|
||||
// from the tags and valid fields (and that's how it's done on the actual cache)
|
||||
std::array<u8, 1 << 20> lookup_table{};
|
||||
std::array<u8, 1 << 21> lookup_table_ex{};
|
||||
std::array<u8, 1 << 20> lookup_table_vmem{};
|
||||
|
|
|
@ -74,7 +74,7 @@ static std::recursive_mutex g_save_thread_mutex;
|
|||
static std::thread g_save_thread;
|
||||
|
||||
// Don't forget to increase this after doing changes on the savestate system
|
||||
constexpr u32 STATE_VERSION = 146; // Last changed in PR 10883
|
||||
constexpr u32 STATE_VERSION = 147; // Last changed in PR 10935
|
||||
|
||||
// Maps savestate versions to Dolphin versions.
|
||||
// Versions after 42 don't need to be added to this list,
|
||||
|
|
Loading…
Reference in New Issue