EE Cache: Writeback dirty cache entries when exiting the interpreter.

This commit is contained in:
Ty Lamontagne 2024-12-08 14:05:03 -05:00 committed by Ty
parent 046b416f61
commit 313ddb7879
3 changed files with 21 additions and 0 deletions

View File

@ -163,6 +163,17 @@ void resetCache()
std::memset(&cache, 0, sizeof(cache)); std::memset(&cache, 0, sizeof(cache));
} }
void writebackCache()
{
for (int i = 0; i < 64; i++)
{
for (int j = 0; j < 2; j++)
{
cache.lineAt(i, j).writeBackIfNeeded();
}
}
}
static bool findInCache(const CacheSet& set, uptr ppf, int* way) static bool findInCache(const CacheSet& set, uptr ppf, int* way)
{ {
auto check = [&](int checkWay) -> bool { auto check = [&](int checkWay) -> bool {

View File

@ -8,6 +8,9 @@
#include "common/SingleRegisterTypes.h" #include "common/SingleRegisterTypes.h"
void resetCache(); void resetCache();
// Dumps all dirty cache entries to memory
// This is necessary to fix a bug when enabled the recompiler while the cache was enabled.
void writebackCache();
void writeCache8(u32 mem, u8 value, bool validPFN = true); void writeCache8(u32 mem, u8 value, bool validPFN = true);
void writeCache16(u32 mem, u16 value, bool validPFN = true); void writeCache16(u32 mem, u16 value, bool validPFN = true);
void writeCache32(u32 mem, u32 value, bool validPFN = true); void writeCache32(u32 mem, u32 value, bool validPFN = true);

View File

@ -5,6 +5,7 @@
#include "R5900OpcodeTables.h" #include "R5900OpcodeTables.h"
#include "VMManager.h" #include "VMManager.h"
#include "Elfheader.h" #include "Elfheader.h"
#include "Cache.h"
#include "DebugTools/Breakpoints.h" #include "DebugTools/Breakpoints.h"
@ -555,6 +556,8 @@ static void intEventTest()
if (intExitExecution) if (intExitExecution)
{ {
intExitExecution = false; intExitExecution = false;
if (CHECK_EEREC)
writebackCache();
fastjmp_jmp(&intJmpBuf, 1); fastjmp_jmp(&intJmpBuf, 1);
} }
} }
@ -566,7 +569,11 @@ static void intSafeExitExecution()
if (eeEventTestIsActive) if (eeEventTestIsActive)
intExitExecution = true; intExitExecution = true;
else else
{
if (CHECK_EEREC)
writebackCache();
fastjmp_jmp(&intJmpBuf, 1); fastjmp_jmp(&intJmpBuf, 1);
}
} }
static void intCancelInstruction() static void intCancelInstruction()