1
0
Fork 0
forked from suyu/suyu

video_core/memory_manager: Make GpuToCpuAddress() a const member function

This doesn't modify any internal state, so it can be made a const member
function to allow its use in const contexts.
This commit is contained in:
Lioncash 2019-04-05 20:18:27 -04:00
parent 66be5150d6
commit 9dec087fca
2 changed files with 3 additions and 3 deletions

View file

@ -99,12 +99,12 @@ bool MemoryManager::IsAddressValid(GPUVAddr addr) const {
return (addr >> page_bits) < page_table.pointers.size(); return (addr >> page_bits) < page_table.pointers.size();
} }
std::optional<VAddr> MemoryManager::GpuToCpuAddress(GPUVAddr addr) { std::optional<VAddr> MemoryManager::GpuToCpuAddress(GPUVAddr addr) const {
if (!IsAddressValid(addr)) { if (!IsAddressValid(addr)) {
return {}; return {};
} }
VAddr cpu_addr{page_table.backing_addr[addr >> page_bits]}; const VAddr cpu_addr{page_table.backing_addr[addr >> page_bits]};
if (cpu_addr) { if (cpu_addr) {
return cpu_addr + (addr & page_mask); return cpu_addr + (addr & page_mask);
} }

View file

@ -50,7 +50,7 @@ public:
GPUVAddr MapBufferEx(VAddr cpu_addr, u64 size); GPUVAddr MapBufferEx(VAddr cpu_addr, u64 size);
GPUVAddr MapBufferEx(VAddr cpu_addr, GPUVAddr addr, u64 size); GPUVAddr MapBufferEx(VAddr cpu_addr, GPUVAddr addr, u64 size);
GPUVAddr UnmapBuffer(GPUVAddr addr, u64 size); GPUVAddr UnmapBuffer(GPUVAddr addr, u64 size);
std::optional<VAddr> GpuToCpuAddress(GPUVAddr addr); std::optional<VAddr> GpuToCpuAddress(GPUVAddr addr) const;
template <typename T> template <typename T>
T Read(GPUVAddr addr); T Read(GPUVAddr addr);