yuzu-emu
/
yuzu-mainline
Archived
1
0
Fork 0

video_core/memory_manager: Add a const qualified variant of GetPointer()

Allows retrieving read-only pointers from a const context externally.
This commit is contained in:
Lioncash 2019-04-05 20:25:25 -04:00
parent 085b388a7a
commit 34510bcda8
2 changed files with 17 additions and 2 deletions

View File

@ -180,8 +180,22 @@ u8* MemoryManager::GetPointer(GPUVAddr addr) {
return {}; return {};
} }
u8* page_pointer{page_table.pointers[addr >> page_bits]}; u8* const page_pointer{page_table.pointers[addr >> page_bits]};
if (page_pointer) { 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); return page_pointer + (addr & page_mask);
} }

View File

@ -59,6 +59,7 @@ public:
void Write(GPUVAddr addr, T data); void Write(GPUVAddr addr, T data);
u8* GetPointer(GPUVAddr addr); u8* GetPointer(GPUVAddr addr);
const u8* GetPointer(GPUVAddr addr) const;
void ReadBlock(GPUVAddr src_addr, void* dest_buffer, std::size_t size); 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); void WriteBlock(GPUVAddr dest_addr, const void* src_buffer, std::size_t size);