mirror of
https://git.suyu.dev/suyu/suyu
synced 2024-12-24 18:32:49 -06:00
Merge pull request #1787 from bunnei/fix-gpu-mm
memory_manager: Do not allow 0 to be a valid GPUVAddr.
This commit is contained in:
commit
7d544c1b9d
2 changed files with 9 additions and 1 deletions
|
@ -9,6 +9,13 @@
|
||||||
|
|
||||||
namespace Tegra {
|
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) {
|
GPUVAddr MemoryManager::AllocateSpace(u64 size, u64 align) {
|
||||||
const std::optional<GPUVAddr> gpu_addr{FindFreeBlock(0, size, align, PageStatus::Unmapped)};
|
const std::optional<GPUVAddr> gpu_addr{FindFreeBlock(0, size, align, PageStatus::Unmapped)};
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ using GPUVAddr = u64;
|
||||||
|
|
||||||
class MemoryManager final {
|
class MemoryManager final {
|
||||||
public:
|
public:
|
||||||
MemoryManager() = default;
|
MemoryManager();
|
||||||
|
|
||||||
GPUVAddr AllocateSpace(u64 size, u64 align);
|
GPUVAddr AllocateSpace(u64 size, u64 align);
|
||||||
GPUVAddr AllocateSpace(GPUVAddr gpu_addr, u64 size, u64 align);
|
GPUVAddr AllocateSpace(GPUVAddr gpu_addr, u64 size, u64 align);
|
||||||
|
@ -37,6 +37,7 @@ private:
|
||||||
enum class PageStatus : u64 {
|
enum class PageStatus : u64 {
|
||||||
Unmapped = 0xFFFFFFFFFFFFFFFFULL,
|
Unmapped = 0xFFFFFFFFFFFFFFFFULL,
|
||||||
Allocated = 0xFFFFFFFFFFFFFFFEULL,
|
Allocated = 0xFFFFFFFFFFFFFFFEULL,
|
||||||
|
Reserved = 0xFFFFFFFFFFFFFFFDULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
std::optional<GPUVAddr> FindFreeBlock(GPUVAddr region_start, u64 size, u64 align,
|
std::optional<GPUVAddr> FindFreeBlock(GPUVAddr region_start, u64 size, u64 align,
|
||||||
|
|
Loading…
Reference in a new issue