From 0b1842294f5f43ea2ee42bb8afd26e57c9250f4b Mon Sep 17 00:00:00 2001 From: bunnei Date: Fri, 23 Nov 2018 12:58:55 -0500 Subject: memory_manager: Do not allow 0 to be a valid GPUVAddr. - Fixes a bug with Undertale using 0 for a render target. --- src/video_core/memory_manager.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/video_core/memory_manager.cpp') diff --git a/src/video_core/memory_manager.cpp b/src/video_core/memory_manager.cpp index 77a20bb84..47247f097 100644 --- a/src/video_core/memory_manager.cpp +++ b/src/video_core/memory_manager.cpp @@ -9,6 +9,13 @@ namespace Tegra { +MemoryManager::MemoryManager() { + // Mark the first page as reserved, so that 0 is not a valid GPUVAddr. Otherwise, games might + // try to use 0 as a valid address, which is also used to mean nullptr. This fixes a bug with + // Undertale using 0 for a render target. + PageSlot(0) = static_cast(PageStatus::Reserved); +} + GPUVAddr MemoryManager::AllocateSpace(u64 size, u64 align) { const std::optional gpu_addr{FindFreeBlock(0, size, align, PageStatus::Unmapped)}; -- cgit v1.2.3