invalidate JIT blocks in ARM7 WVRAM when it's remapped

This commit is contained in:
RSDuck 2022-08-22 00:39:08 +02:00
parent d56219c33c
commit 32609bbc98
4 changed files with 32 additions and 3 deletions

View File

@ -1086,11 +1086,34 @@ void InvalidateByAddr(u32 localAddr)
void CheckAndInvalidateITCM()
{
for (u32 i = 0; i < ITCMPhysicalSize; i+=16)
for (u32 i = 0; i < ITCMPhysicalSize; i+=512)
{
if (CodeIndexITCM[i / 512].Code & (1 << ((i & 0x1FF) / 16)))
if (CodeIndexITCM[i / 512].Code)
{
InvalidateByAddr(i | (ARMJIT_Memory::memregion_ITCM << 27));
// maybe using bitscan would be better here?
// The thing is that in densely populated sets
// The old fashioned way can actually be faster
for (u32 j = 0; j < 512; j += 16)
{
if (CodeIndexITCM[i / 512].Code & (1 << ((j & 0x1FF) / 16)))
InvalidateByAddr((i+j) | (ARMJIT_Memory::memregion_ITCM << 27));
}
}
}
}
void CheckAndInvalidateWVRAM(int bank)
{
u32 start = bank == 1 ? 0x20000 : 0;
for (u32 i = start; i < start+0x20000; i+=512)
{
if (CodeIndexARM7WVRAM[i / 512].Code)
{
for (u32 j = 0; j < 512; j += 16)
{
if (CodeIndexARM7WVRAM[i / 512].Code & (1 << ((j & 0x1FF) / 16)))
InvalidateByAddr((i+j) | (ARMJIT_Memory::memregion_VWRAM << 27));
}
}
}
}

View File

@ -44,6 +44,7 @@ void DeInit();
void Reset();
void CheckAndInvalidateITCM();
void CheckAndInvalidateWVRAM(int bank);
void InvalidateByAddr(u32 pseudoPhysical);

View File

@ -134,6 +134,9 @@ void ARMv5::UpdateITCMSetting()
if (CP15Control & (1<<18))
{
ITCMSize = 0x200 << ((ITCMSetting >> 1) & 0x1F);
#ifdef JIT_ENABLED
FastBlockLookupSize = 0;
#endif
}
else
{

View File

@ -20,6 +20,7 @@
#include <string.h>
#include "NDS.h"
#include "GPU.h"
#include "ARMJIT.h"
#include "GPU2D_Soft.h"
@ -653,6 +654,7 @@ void MapVRAM_CD(u32 bank, u8 cnt)
VRAMMap_ARM7[ofs] |= bankmask;
memset(VRAMDirty[bank].Data, 0xFF, sizeof(VRAMDirty[bank].Data));
VRAMSTAT |= (1 << (bank-2));
ARMJIT::CheckAndInvalidateWVRAM(ofs);
break;
case 3: // texture