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:
Ranieri
2026-07-07 21:48:26 -03:00
committed by GitHub
parent 52edf07657
commit ecc86f4b5d
14 changed files with 2145 additions and 1628 deletions
+15 -4
View File
@@ -351,6 +351,7 @@ bool PS2Memory::initialize(size_t ramSize)
m_vu1Data = new uint8_t[PS2_VU1_DATA_SIZE];
std::memset(m_vu1Code, 0, PS2_VU1_CODE_SIZE);
std::memset(m_vu1Data, 0, PS2_VU1_DATA_SIZE);
markVU1CodeModified();
// Initialize VIF registers
memset(&vif0_regs, 0, sizeof(vif0_regs));
@@ -764,6 +765,8 @@ void PS2Memory::write8(uint32_t address, uint8_t value)
{
(void)vuLimit;
vuMem[vuOffset] = value;
if (vuMem == m_vu1Code)
markVU1CodeModified();
return;
}
}
@@ -803,6 +806,8 @@ void PS2Memory::write16(uint32_t address, uint16_t value)
if (uint8_t *vuMem = mapVuMemory(physAddr, sizeof(uint16_t), vuOffset, vuLimit))
{
storeScalar<uint16_t>(vuMem, vuOffset, vuLimit, value, "write16 vu", address);
if (vuMem == m_vu1Code)
markVU1CodeModified();
return;
}
}
@@ -863,6 +868,8 @@ void PS2Memory::write32(uint32_t address, uint32_t value)
if (uint8_t *vuMem = mapVuMemory(physAddr, sizeof(uint32_t), vuOffset, vuLimit))
{
storeScalar<uint32_t>(vuMem, vuOffset, vuLimit, value, "write32 vu", address);
if (vuMem == m_vu1Code)
markVU1CodeModified();
return;
}
}
@@ -914,6 +921,8 @@ void PS2Memory::write64(uint32_t address, uint64_t value)
if (uint8_t *vuMem = mapVuMemory(physAddr, sizeof(uint64_t), vuOffset, vuLimit))
{
storeScalar<uint64_t>(vuMem, vuOffset, vuLimit, value, "write64 vu", address);
if (vuMem == m_vu1Code)
markVU1CodeModified();
return;
}
}
@@ -953,6 +962,8 @@ void PS2Memory::write128(uint32_t address, __m128i value)
{
inRange(vuOffset, sizeof(__m128i), vuLimit, "write128 vu", address);
_mm_storeu_si128(reinterpret_cast<__m128i *>(vuMem + vuOffset), value);
if (vuMem == m_vu1Code)
markVU1CodeModified();
return;
}
}
@@ -1208,9 +1219,9 @@ bool PS2Memory::writeIORegister(uint32_t address, uint32_t value)
auto appendCompactVif1TagData = [&](uint32_t localTagAddr, uint32_t qwCount)
{
uint32_t tagPhys = 0u;
const bool tagScratch = isScratchpad(localTagAddr);
const bool tagScratch = isScratchpad(localTagAddr);
tagPhys = translateAddress(localTagAddr);
const uint8_t *localBase = tagScratch ? m_scratchpad : m_rdram;
const uint32_t localMax = tagScratch ? PS2_SCRATCHPAD_SIZE : PS2_RAM_SIZE;
if (tagPhys + 16u > localMax)
@@ -1718,11 +1729,11 @@ void PS2Memory::processGIFPacket(uint32_t srcPhysAddr, uint32_t qwCount)
chunk = PS2_RAM_SIZE - srcPhysAddr;
if (chunk == 0)
break;
m_seenGifCopy = true;
m_gifCopyCount.fetch_add(1, std::memory_order_relaxed);
submitGifPacket(GifPathId::Path3, m_rdram + srcPhysAddr, chunk);
bytesLeft -= chunk;
srcPhysAddr += chunk;
}