diff options
| author | 2018-11-23 12:58:55 -0500 | |
|---|---|---|
| committer | 2018-11-23 12:58:55 -0500 | |
| commit | 0b1842294f5f43ea2ee42bb8afd26e57c9250f4b (patch) | |
| tree | 97507dc052dbec1891184e512a666a791c89b633 /src | |
| parent | Merge pull request #1770 from DarkLordZach/applet-stub (diff) | |
| download | yuzu-0b1842294f5f43ea2ee42bb8afd26e57c9250f4b.tar.gz yuzu-0b1842294f5f43ea2ee42bb8afd26e57c9250f4b.tar.xz yuzu-0b1842294f5f43ea2ee42bb8afd26e57c9250f4b.zip | |
memory_manager: Do not allow 0 to be a valid GPUVAddr.
- Fixes a bug with Undertale using 0 for a render target.
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/memory_manager.cpp | 7 | ||||
| -rw-r--r-- | src/video_core/memory_manager.h | 3 |
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 @@ | |||
| 9 | 9 | ||
| 10 | namespace Tegra { | 10 | namespace Tegra { |
| 11 | 11 | ||
| 12 | MemoryManager::MemoryManager() { | ||
| 13 | // Mark the first page as reserved, so that 0 is not a valid GPUVAddr. Otherwise, games might | ||
| 14 | // try to use 0 as a valid address, which is also used to mean nullptr. This fixes a bug with | ||
| 15 | // Undertale using 0 for a render target. | ||
| 16 | PageSlot(0) = static_cast<u64>(PageStatus::Reserved); | ||
| 17 | } | ||
| 18 | |||
| 12 | GPUVAddr MemoryManager::AllocateSpace(u64 size, u64 align) { | 19 | GPUVAddr MemoryManager::AllocateSpace(u64 size, u64 align) { |
| 13 | const std::optional<GPUVAddr> gpu_addr{FindFreeBlock(0, size, align, PageStatus::Unmapped)}; | 20 | const std::optional<GPUVAddr> gpu_addr{FindFreeBlock(0, size, align, PageStatus::Unmapped)}; |
| 14 | 21 | ||
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; | |||
| 18 | 18 | ||
| 19 | class MemoryManager final { | 19 | class MemoryManager final { |
| 20 | public: | 20 | public: |
| 21 | MemoryManager() = default; | 21 | MemoryManager(); |
| 22 | 22 | ||
| 23 | GPUVAddr AllocateSpace(u64 size, u64 align); | 23 | GPUVAddr AllocateSpace(u64 size, u64 align); |
| 24 | GPUVAddr AllocateSpace(GPUVAddr gpu_addr, u64 size, u64 align); | 24 | GPUVAddr AllocateSpace(GPUVAddr gpu_addr, u64 size, u64 align); |
| @@ -37,6 +37,7 @@ private: | |||
| 37 | enum class PageStatus : u64 { | 37 | enum class PageStatus : u64 { |
| 38 | Unmapped = 0xFFFFFFFFFFFFFFFFULL, | 38 | Unmapped = 0xFFFFFFFFFFFFFFFFULL, |
| 39 | Allocated = 0xFFFFFFFFFFFFFFFEULL, | 39 | Allocated = 0xFFFFFFFFFFFFFFFEULL, |
| 40 | Reserved = 0xFFFFFFFFFFFFFFFDULL, | ||
| 40 | }; | 41 | }; |
| 41 | 42 | ||
| 42 | std::optional<GPUVAddr> FindFreeBlock(GPUVAddr region_start, u64 size, u64 align, | 43 | std::optional<GPUVAddr> FindFreeBlock(GPUVAddr region_start, u64 size, u64 align, |