summaryrefslogtreecommitdiffstats
path: root/src/video_core
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2018-11-23 18:58:55 +0100
committerbunnei <bunneidev@gmail.com>2018-11-23 18:58:55 +0100
commit0b1842294f5f43ea2ee42bb8afd26e57c9250f4b (patch)
tree97507dc052dbec1891184e512a666a791c89b633 /src/video_core
parentMerge pull request #1770 from DarkLordZach/applet-stub (diff)
downloadyuzu-0b1842294f5f43ea2ee42bb8afd26e57c9250f4b.tar
yuzu-0b1842294f5f43ea2ee42bb8afd26e57c9250f4b.tar.gz
yuzu-0b1842294f5f43ea2ee42bb8afd26e57c9250f4b.tar.bz2
yuzu-0b1842294f5f43ea2ee42bb8afd26e57c9250f4b.tar.lz
yuzu-0b1842294f5f43ea2ee42bb8afd26e57c9250f4b.tar.xz
yuzu-0b1842294f5f43ea2ee42bb8afd26e57c9250f4b.tar.zst
yuzu-0b1842294f5f43ea2ee42bb8afd26e57c9250f4b.zip
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/memory_manager.cpp7
-rw-r--r--src/video_core/memory_manager.h3
2 files changed, 9 insertions, 1 deletions
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<u64>(PageStatus::Reserved);
+}
+
GPUVAddr MemoryManager::AllocateSpace(u64 size, u64 align) {
const std::optional<GPUVAddr> gpu_addr{FindFreeBlock(0, size, align, PageStatus::Unmapped)};
diff --git a/src/video_core/memory_manager.h b/src/video_core/memory_manager.h
index 4eb338aa2..fb03497ca 100644
--- a/src/video_core/memory_manager.h
+++ b/src/video_core/memory_manager.h
@@ -18,7 +18,7 @@ using GPUVAddr = u64;
class MemoryManager final {
public:
- MemoryManager() = default;
+ MemoryManager();
GPUVAddr AllocateSpace(u64 size, u64 align);
GPUVAddr AllocateSpace(GPUVAddr gpu_addr, u64 size, u64 align);
@@ -37,6 +37,7 @@ private:
enum class PageStatus : u64 {
Unmapped = 0xFFFFFFFFFFFFFFFFULL,
Allocated = 0xFFFFFFFFFFFFFFFEULL,
+ Reserved = 0xFFFFFFFFFFFFFFFDULL,
};
std::optional<GPUVAddr> FindFreeBlock(GPUVAddr region_start, u64 size, u64 align,