Skip to content

Commit

Permalink
EE Cache: Writeback dirty cache entries when exiting the interpreter.
Browse files Browse the repository at this point in the history
  • Loading branch information
F0bes committed Dec 8, 2024
1 parent 046b416 commit 313ddb7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pcsx2/Cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,17 @@ void resetCache()
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)
{
auto check = [&](int checkWay) -> bool {
Expand Down
3 changes: 3 additions & 0 deletions pcsx2/Cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#include "common/SingleRegisterTypes.h"

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 writeCache16(u32 mem, u16 value, bool validPFN = true);
void writeCache32(u32 mem, u32 value, bool validPFN = true);
Expand Down
7 changes: 7 additions & 0 deletions pcsx2/Interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "R5900OpcodeTables.h"
#include "VMManager.h"
#include "Elfheader.h"
#include "Cache.h"

#include "DebugTools/Breakpoints.h"

Expand Down Expand Up @@ -555,6 +556,8 @@ static void intEventTest()
if (intExitExecution)
{
intExitExecution = false;
if (CHECK_EEREC)
writebackCache();
fastjmp_jmp(&intJmpBuf, 1);
}
}
Expand All @@ -566,7 +569,11 @@ static void intSafeExitExecution()
if (eeEventTestIsActive)
intExitExecution = true;
else
{
if (CHECK_EEREC)
writebackCache();
fastjmp_jmp(&intJmpBuf, 1);
}
}

static void intCancelInstruction()
Expand Down

0 comments on commit 313ddb7

Please sign in to comment.