jit: Ignore zero byte icache invalidates.

These were getting marked pending and were clearing all cache, causing
performance concerns in for example LittleBigPlanet.
This commit is contained in:
Unknown W. Brackets 2022-10-15 18:27:52 -07:00
parent cbe31af8cf
commit c4bf2cb5c0
5 changed files with 18 additions and 14 deletions

View file

@ -233,8 +233,9 @@ static int Replace_memcpy16() {
bool skip = false;
// Some games use memcpy on executable code. We need to flush emuhack ops.
currentMIPS->InvalidateICache(srcPtr, bytes);
if ((skipGPUReplacements & (int)GPUReplacementSkip::MEMCPY) == 0) {
if (bytes != 0)
currentMIPS->InvalidateICache(srcPtr, bytes);
if ((skipGPUReplacements & (int)GPUReplacementSkip::MEMCPY) == 0 && bytes != 0) {
if (Memory::IsVRAMAddress(destPtr) || Memory::IsVRAMAddress(srcPtr)) {
skip = gpu->PerformMemoryCopy(destPtr, srcPtr, bytes);
}
@ -305,7 +306,7 @@ static int Replace_memmove() {
bool skip = false;
// Some games use memcpy on executable code. We need to flush emuhack ops.
if ((skipGPUReplacements & (int)GPUReplacementSkip::MEMMOVE) == 0) {
if ((skipGPUReplacements & (int)GPUReplacementSkip::MEMMOVE) == 0 && bytes != 0) {
currentMIPS->InvalidateICache(srcPtr, bytes);
if (Memory::IsVRAMAddress(destPtr) || Memory::IsVRAMAddress(srcPtr)) {
skip = gpu->PerformMemoryCopy(destPtr, srcPtr, bytes);

View file

@ -49,7 +49,7 @@ static int __DmacMemcpy(u32 dst, u32 src, u32 size) {
if (Memory::IsVRAMAddress(src) || Memory::IsVRAMAddress(dst)) {
skip = gpu->PerformMemoryCopy(dst, src, size);
}
if (!skip) {
if (!skip && size != 0) {
currentMIPS->InvalidateICache(src, size);
if (MemBlockInfoDetailed(size)) {
const std::string tag = GetMemWriteTagAt("DmacMemcpy/", src, size);

View file

@ -392,7 +392,8 @@ int sceKernelDcacheInvalidateRange(u32 addr, int size)
int sceKernelIcacheInvalidateRange(u32 addr, int size) {
DEBUG_LOG(CPU, "sceKernelIcacheInvalidateRange(%08x, %i)", addr, size);
currentMIPS->InvalidateICache(addr, size);
if (size != 0)
currentMIPS->InvalidateICache(addr, size);
return 0;
}

View file

@ -624,7 +624,8 @@ static u32 sceKernelMemcpy(u32 dst, u32 src, u32 size)
DEBUG_LOG(SCEKERNEL, "sceKernelMemcpy(dest=%08x, src=%08x, size=%i)", dst, src, size);
// Some games copy from executable code. We need to flush emuhack ops.
currentMIPS->InvalidateICache(src, size);
if (size != 0)
currentMIPS->InvalidateICache(src, size);
bool skip = false;
if (Memory::IsVRAMAddress(src) || Memory::IsVRAMAddress(dst)) {

View file

@ -366,14 +366,15 @@ void MIPSState::ProcessPendingClears() {
void MIPSState::InvalidateICache(u32 address, int length) {
// Only really applies to jit.
std::lock_guard<std::recursive_mutex> guard(MIPSComp::jitLock);
if (MIPSComp::jit) {
if (coreState == CORE_RUNNING || insideJit) {
pendingClears.emplace_back(address, length);
hasPendingClears = true;
CoreTiming::ForceCheck();
} else {
MIPSComp::jit->InvalidateCacheAt(address, length);
}
if (!MIPSComp::jit || length == 0)
return;
if (coreState == CORE_RUNNING || insideJit) {
pendingClears.emplace_back(address, length);
hasPendingClears = true;
CoreTiming::ForceCheck();
} else {
MIPSComp::jit->InvalidateCacheAt(address, length);
}
}