From 34510bcda84aa0d3acc6af543eb4b38e76e6ab84 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 5 Apr 2019 20:25:25 -0400 Subject: video_core/memory_manager: Add a const qualified variant of GetPointer() Allows retrieving read-only pointers from a const context externally. --- src/video_core/memory_manager.cpp | 18 ++++++++++++++++-- src/video_core/memory_manager.h | 1 + 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'src/video_core') diff --git a/src/video_core/memory_manager.cpp b/src/video_core/memory_manager.cpp index 11b1d022a..bb7e21e7d 100644 --- a/src/video_core/memory_manager.cpp +++ b/src/video_core/memory_manager.cpp @@ -180,8 +180,22 @@ u8* MemoryManager::GetPointer(GPUVAddr addr) { return {}; } - u8* page_pointer{page_table.pointers[addr >> page_bits]}; - if (page_pointer) { + u8* const page_pointer{page_table.pointers[addr >> page_bits]}; + if (page_pointer != nullptr) { + return page_pointer + (addr & page_mask); + } + + LOG_ERROR(HW_GPU, "Unknown GetPointer @ 0x{:016X}", addr); + return {}; +} + +const u8* MemoryManager::GetPointer(GPUVAddr addr) const { + if (!IsAddressValid(addr)) { + return {}; + } + + const u8* const page_pointer{page_table.pointers[addr >> page_bits]}; + if (page_pointer != nullptr) { return page_pointer + (addr & page_mask); } diff --git a/src/video_core/memory_manager.h b/src/video_core/memory_manager.h index d75c1c5c0..4309bfce7 100644 --- a/src/video_core/memory_manager.h +++ b/src/video_core/memory_manager.h @@ -59,6 +59,7 @@ public: void Write(GPUVAddr addr, T data); u8* GetPointer(GPUVAddr addr); + const u8* GetPointer(GPUVAddr addr) const; void ReadBlock(GPUVAddr src_addr, void* dest_buffer, std::size_t size); void WriteBlock(GPUVAddr dest_addr, const void* src_buffer, std::size_t size); -- cgit v1.2.3