mirror of
https://github.com/ran-j/PS2Recomp.git
synced 2026-09-28 17:39:16 -04:00
Feature vu1 cache (#158)
* feat: explode vu1 in files feat: added way more tests for vu1 * feat: added VU1 cache
This commit is contained in:
@@ -285,6 +285,7 @@ public:
|
||||
uint64_t gifCopyCount() const { return m_gifCopyCount.load(std::memory_order_relaxed); }
|
||||
uint64_t gsWriteCount() const { return m_gsWriteCount.load(std::memory_order_relaxed); }
|
||||
uint64_t vifWriteCount() const { return m_vifWriteCount.load(std::memory_order_relaxed); }
|
||||
uint64_t getVU1CodeGeneration() const { return m_vu1CodeGeneration.load(std::memory_order_relaxed); }
|
||||
|
||||
// Read/write memory
|
||||
uint8_t read8(uint32_t address);
|
||||
@@ -371,6 +372,7 @@ public:
|
||||
std::atomic<uint64_t> m_gifCopyCount{0};
|
||||
std::atomic<uint64_t> m_gsWriteCount{0};
|
||||
std::atomic<uint64_t> m_vifWriteCount{0};
|
||||
std::atomic<uint64_t> m_vu1CodeGeneration{0};
|
||||
// I/O registers
|
||||
std::unordered_map<uint32_t, uint32_t> m_ioRegisters;
|
||||
|
||||
@@ -429,6 +431,7 @@ public:
|
||||
|
||||
bool isAddressInRegion(uint32_t address, const CodeRegion ®ion);
|
||||
void markModified(uint32_t address, uint32_t size);
|
||||
void markVU1CodeModified() { m_vu1CodeGeneration.fetch_add(1, std::memory_order_relaxed); }
|
||||
bool isScratchpad(uint32_t address) const;
|
||||
uint8_t *mapVuMemory(uint32_t physAddr, uint32_t size, uint32_t &offset, uint32_t &limit);
|
||||
const uint8_t *mapVuMemory(uint32_t physAddr, uint32_t size, uint32_t &offset, uint32_t &limit) const;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define PS2_VU1_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
class GS;
|
||||
class PS2Memory;
|
||||
@@ -19,8 +20,8 @@ struct VU1State
|
||||
uint32_t clip;
|
||||
uint32_t status;
|
||||
bool ebit;
|
||||
uint32_t top; // VIF1 TOP visible to VU1 XTOP
|
||||
uint32_t itop; // VIF1 ITOP visible to VU1 XITOP
|
||||
uint32_t top; // VIF1 TOP visible to VU1 XTOP
|
||||
uint32_t itop; // VIF1 ITOP visible to VU1 XITOP
|
||||
|
||||
bool branchPending;
|
||||
uint32_t branchTarget;
|
||||
@@ -49,12 +50,33 @@ public:
|
||||
const VU1State &state() const { return m_state; }
|
||||
|
||||
private:
|
||||
struct DecodedInstructionPair
|
||||
{
|
||||
uint32_t lower = 0;
|
||||
uint32_t upper = 0;
|
||||
bool iBit = false;
|
||||
bool eBit = false;
|
||||
bool lowerBeforeUpper = false;
|
||||
};
|
||||
|
||||
VU1State m_state;
|
||||
std::vector<DecodedInstructionPair> m_decodedCodeCache;
|
||||
const uint8_t *m_cachedVuCode = nullptr;
|
||||
const PS2Memory *m_cachedMemory = nullptr;
|
||||
uint32_t m_cachedCodeSize = 0;
|
||||
uint64_t m_cachedCodeGeneration = 0;
|
||||
bool m_decodedCodeCacheValid = false;
|
||||
|
||||
void run(uint8_t *vuCode, uint32_t codeSize,
|
||||
uint8_t *vuData, uint32_t dataSize,
|
||||
GS &gs, PS2Memory *memory, uint32_t maxCycles);
|
||||
|
||||
DecodedInstructionPair decodeInstructionPair(const uint8_t *vuCode, uint32_t pc) const;
|
||||
DecodedInstructionPair getDecodedInstructionPairForPc(const uint8_t *vuCode, uint32_t codeSize,
|
||||
PS2Memory *memory, uint32_t pc);
|
||||
void rebuildDecodedCodeCache(const uint8_t *vuCode, uint32_t codeSize,
|
||||
const PS2Memory *memory, uint64_t generation);
|
||||
|
||||
void execUpper(uint32_t instr);
|
||||
void execLower(uint32_t instr, uint8_t *vuData, uint32_t dataSize, GS &gs, PS2Memory *memory, uint32_t upperInstr);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user