From f5ecfd230ceb2fb8849d1da3d702859b31e3957b Mon Sep 17 00:00:00 2001 From: Giovanni Bajo Date: Thu, 5 Sep 2024 23:28:30 +0200 Subject: [PATCH] n64: optimize RDRAM accesses by special casing them --- ares/n64/cpu/memory.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ares/n64/cpu/memory.cpp b/ares/n64/cpu/memory.cpp index fcd4a4165e..44fbc720ec 100644 --- a/ares/n64/cpu/memory.cpp +++ b/ares/n64/cpu/memory.cpp @@ -93,6 +93,11 @@ auto CPU::devirtualize(u64 vaddr, bool raiseAlignedError, bool raiseExceptions) if (raiseAlignedError && vaddrAlignedError(vaddr, Dir == Write)) { return PhysAccess{false}; } + //fast path for RDRAM, which is by far the most accessed memory region + if (vaddr >= 0xffff'ffff'8000'0000ull && vaddr <= 0xffff'ffff'83ef'ffffull) { + if constexpr(Dir == Read) return PhysAccess{true, true, (u32)vaddr & 0x3eff'ffff, vaddr}; + if constexpr(Dir == Write) return PhysAccess{true, true, (u32)vaddr & 0x3eff'ffff, vaddr}; + } switch(segment(vaddr)) { case Context::Segment::Unused: if(raiseExceptions) {