Merge pull request #10935 from Pokechu22/icache-dont-save-lookup-table
PPCCache: Stop storing lookup table in savestates
This commit is contained in:
commit
f93b04dc94
|
@ -204,13 +204,53 @@ u32 InstructionCache::ReadInstruction(u32 addr)
|
||||||
|
|
||||||
void InstructionCache::DoState(PointerWrap& p)
|
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(data);
|
||||||
p.DoArray(tags);
|
p.DoArray(tags);
|
||||||
p.DoArray(plru);
|
p.DoArray(plru);
|
||||||
p.DoArray(valid);
|
p.DoArray(valid);
|
||||||
p.DoArray(lookup_table);
|
|
||||||
p.DoArray(lookup_table_ex);
|
if (p.IsReadMode())
|
||||||
p.DoArray(lookup_table_vmem);
|
{
|
||||||
|
// 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()
|
void InstructionCache::RefreshConfig()
|
||||||
|
|
|
@ -27,6 +27,8 @@ struct InstructionCache
|
||||||
std::array<u32, ICACHE_SETS> plru{};
|
std::array<u32, ICACHE_SETS> plru{};
|
||||||
std::array<u32, ICACHE_SETS> valid{};
|
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 << 20> lookup_table{};
|
||||||
std::array<u8, 1 << 21> lookup_table_ex{};
|
std::array<u8, 1 << 21> lookup_table_ex{};
|
||||||
std::array<u8, 1 << 20> lookup_table_vmem{};
|
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;
|
static std::thread g_save_thread;
|
||||||
|
|
||||||
// Don't forget to increase this after doing changes on the savestate system
|
// 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.
|
// Maps savestate versions to Dolphin versions.
|
||||||
// Versions after 42 don't need to be added to this list,
|
// Versions after 42 don't need to be added to this list,
|
||||||
|
|
Loading…
Reference in New Issue