Skip to content

Commit

Permalink
memory: Fix order of checks in PhysicalToVirtualAddressForRasterizer.…
Browse files Browse the repository at this point in the history
… (#7328)
  • Loading branch information
Steveice10 authored Jan 7, 2024
1 parent b2c740e commit 96aa1b3
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/core/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -691,19 +691,20 @@ std::vector<VAddr> MemorySystem::PhysicalToVirtualAddressForRasterizer(PAddr add
if (addr >= VRAM_PADDR && addr < VRAM_PADDR_END) {
return {addr - VRAM_PADDR + VRAM_VADDR};
}
if (addr >= FCRAM_PADDR && addr < FCRAM_PADDR_END) {
return {addr - FCRAM_PADDR + LINEAR_HEAP_VADDR, addr - FCRAM_PADDR + NEW_LINEAR_HEAP_VADDR};
}
if (addr >= FCRAM_PADDR_END && addr < FCRAM_N3DS_PADDR_END) {
return {addr - FCRAM_PADDR + NEW_LINEAR_HEAP_VADDR};
}
// NOTE: Order matters here.
auto plg_ldr = Service::PLGLDR::GetService(impl->system);
if (plg_ldr) {
auto fb_addr = plg_ldr->GetPluginFBAddr();
if (addr >= fb_addr && addr < fb_addr + PLUGIN_3GX_FB_SIZE) {
return {addr - fb_addr + PLUGIN_3GX_FB_VADDR};
}
}
if (addr >= FCRAM_PADDR && addr < FCRAM_PADDR_END) {
return {addr - FCRAM_PADDR + LINEAR_HEAP_VADDR, addr - FCRAM_PADDR + NEW_LINEAR_HEAP_VADDR};
}
if (addr >= FCRAM_PADDR_END && addr < FCRAM_N3DS_PADDR_END) {
return {addr - FCRAM_PADDR + NEW_LINEAR_HEAP_VADDR};
}
// While the physical <-> virtual mapping is 1:1 for the regions supported by the cache,
// some games (like Pokemon Super Mystery Dungeon) will try to use textures that go beyond
// the end address of VRAM, causing the Virtual->Physical translation to fail when flushing
Expand Down

0 comments on commit 96aa1b3

Please sign in to comment.