Skip to content

Commit

Permalink
EE Cache: Use std::array for cached tlb entries
Browse files Browse the repository at this point in the history
  • Loading branch information
F0bes committed Dec 26, 2024
1 parent fa9abbe commit 3c53503
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 25 deletions.
13 changes: 8 additions & 5 deletions pcsx2/COP0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,14 @@ void UnmapTLB(const tlbs& t, int i)
{
if (cachedTlbs.PFN0s[i] == t.PFN0() && cachedTlbs.PFN1s[i] == t.PFN1() && cachedTlbs.PageMasks[i] == ConvertPageMask(t.PageMask.UL))
{
cachedTlbs.PFN0s.erase(cachedTlbs.PFN0s.begin() + i);
cachedTlbs.PFN1s.erase(cachedTlbs.PFN1s.begin() + i);
cachedTlbs.PageMasks.erase(cachedTlbs.PageMasks.begin() + i);
cachedTlbs.CacheEnabled0.erase(cachedTlbs.CacheEnabled0.begin() + i);
cachedTlbs.CacheEnabled1.erase(cachedTlbs.CacheEnabled1.begin() + i);
for (size_t j = i; j < cachedTlbs.count - 1; j++)
{
cachedTlbs.CacheEnabled0[j] = cachedTlbs.CacheEnabled0[j + 1];
cachedTlbs.CacheEnabled1[j] = cachedTlbs.CacheEnabled1[j + 1];
cachedTlbs.PFN0s[j] = cachedTlbs.PFN0s[j + 1];
cachedTlbs.PFN1s[j] = cachedTlbs.PFN1s[j + 1];
cachedTlbs.PageMasks[j] = cachedTlbs.PageMasks[j + 1];
}
cachedTlbs.count--;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion pcsx2/R5900.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void cpuReset()
std::memset(&cpuRegs, 0, sizeof(cpuRegs));
std::memset(&fpuRegs, 0, sizeof(fpuRegs));
std::memset(&tlb, 0, sizeof(tlb));
cachedTlbs.reset();
cachedTlbs.count = 0;

cpuRegs.pc = 0xbfc00000; //set pc reg to stack
cpuRegs.CP0.n.Config = 0x440;
Expand Down
26 changes: 7 additions & 19 deletions pcsx2/R5900.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#include "common/Pcsx2Defs.h"

#include <array>

// --------------------------------------------------------------------------------------
// EE Bios function name tables.
// --------------------------------------------------------------------------------------
Expand Down Expand Up @@ -266,26 +268,12 @@ alignas(16) extern tlbs tlb[48];
struct cachedTlbs_t
{
u32 count;
std::vector<u32> PageMasks;
std::vector<u32> PFN1s;
std::vector<u32> CacheEnabled1;
std::vector<u32> PFN0s;
std::vector<u32> CacheEnabled0;

inline void reset()
{
count = 0;
PageMasks.clear();
PageMasks.resize(48);
PFN1s.clear();
PFN1s.resize(48);
PFN0s.clear();
PFN0s.resize(48);
CacheEnabled1.clear();
CacheEnabled1.resize(48);
CacheEnabled0.clear();
CacheEnabled0.resize(48);
}
alignas(16) std::array<u32, 48> PageMasks;
alignas(16) std::array<u32, 48> PFN1s;
alignas(16) std::array<u32, 48> CacheEnabled1;
alignas(16) std::array<u32, 48> PFN0s;
alignas(16) std::array<u32, 48> CacheEnabled0;
};

extern cachedTlbs_t cachedTlbs;
Expand Down

0 comments on commit 3c53503

Please sign in to comment.