diff options
author | Michael Scire <SciresM@gmail.com> | 2019-07-09 07:19:27 +0200 |
---|---|---|
committer | Michael Scire <SciresM@gmail.com> | 2019-07-09 07:52:05 +0200 |
commit | 697206092e8ac28c7dfe83eff0eea6613082740c (patch) | |
tree | 587b19d4fbf727a88524fefff496c2c12d9f7f97 /src | |
parent | Remove unused member function declaration (diff) | |
download | yuzu-697206092e8ac28c7dfe83eff0eea6613082740c.tar yuzu-697206092e8ac28c7dfe83eff0eea6613082740c.tar.gz yuzu-697206092e8ac28c7dfe83eff0eea6613082740c.tar.bz2 yuzu-697206092e8ac28c7dfe83eff0eea6613082740c.tar.lz yuzu-697206092e8ac28c7dfe83eff0eea6613082740c.tar.xz yuzu-697206092e8ac28c7dfe83eff0eea6613082740c.tar.zst yuzu-697206092e8ac28c7dfe83eff0eea6613082740c.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/core/hle/kernel/vm_manager.cpp | 5 | ||||
-rw-r--r-- | src/video_core/memory_manager.cpp | 24 |
2 files changed, 28 insertions, 1 deletions
diff --git a/src/core/hle/kernel/vm_manager.cpp b/src/core/hle/kernel/vm_manager.cpp index 775d170bf..72a9d7717 100644 --- a/src/core/hle/kernel/vm_manager.cpp +++ b/src/core/hle/kernel/vm_manager.cpp @@ -51,6 +51,11 @@ bool VirtualMemoryArea::CanBeMergedWith(const VirtualMemoryArea& next) const { type != next.type) { return false; } + if ((attribute & MemoryAttribute::DeviceMapped) == MemoryAttribute::DeviceMapped) { + // TODO: Can device mapped memory be merged sanely? + // Not merging it may cause inaccuracies versus hardware when memory layout is queried. + return false; + } if (type == VMAType::AllocatedMemoryBlock) { return true; } diff --git a/src/video_core/memory_manager.cpp b/src/video_core/memory_manager.cpp index 322453116..3a158fa26 100644 --- a/src/video_core/memory_manager.cpp +++ b/src/video_core/memory_manager.cpp @@ -5,6 +5,9 @@ #include "common/alignment.h" #include "common/assert.h" #include "common/logging/log.h" +#include "core/core.h" +#include "core/hle/kernel/process.h" +#include "core/hle/kernel/vm_manager.h" #include "core/memory.h" #include "video_core/memory_manager.h" #include "video_core/rasterizer_interface.h" @@ -49,6 +52,12 @@ GPUVAddr MemoryManager::MapBufferEx(VAddr cpu_addr, u64 size) { const GPUVAddr gpu_addr{FindFreeRegion(address_space_base, aligned_size)}; MapBackingMemory(gpu_addr, Memory::GetPointer(cpu_addr), aligned_size, cpu_addr); + ASSERT(Core::System::GetInstance() + .CurrentProcess() + ->VMManager() + .SetMemoryAttribute(cpu_addr, size, Kernel::MemoryAttribute::DeviceMapped, + Kernel::MemoryAttribute::DeviceMapped) + .IsSuccess()); return gpu_addr; } @@ -59,7 +68,12 @@ GPUVAddr MemoryManager::MapBufferEx(VAddr cpu_addr, GPUVAddr gpu_addr, u64 size) const u64 aligned_size{Common::AlignUp(size, page_size)}; MapBackingMemory(gpu_addr, Memory::GetPointer(cpu_addr), aligned_size, cpu_addr); - + ASSERT(Core::System::GetInstance() + .CurrentProcess() + ->VMManager() + .SetMemoryAttribute(cpu_addr, size, Kernel::MemoryAttribute::DeviceMapped, + Kernel::MemoryAttribute::DeviceMapped) + .IsSuccess()); return gpu_addr; } @@ -68,9 +82,17 @@ GPUVAddr MemoryManager::UnmapBuffer(GPUVAddr gpu_addr, u64 size) { const u64 aligned_size{Common::AlignUp(size, page_size)}; const CacheAddr cache_addr{ToCacheAddr(GetPointer(gpu_addr))}; + const auto cpu_addr = GpuToCpuAddress(gpu_addr); + ASSERT(cpu_addr); rasterizer.FlushAndInvalidateRegion(cache_addr, aligned_size); UnmapRange(gpu_addr, aligned_size); + ASSERT(Core::System::GetInstance() + .CurrentProcess() + ->VMManager() + .SetMemoryAttribute(cpu_addr.value(), size, Kernel::MemoryAttribute::DeviceMapped, + Kernel::MemoryAttribute::None) + .IsSuccess()); return gpu_addr; } |