diff options
author | Fernando Sahmkow <fsahmkow27@gmail.com> | 2019-04-16 05:01:35 +0200 |
---|---|---|
committer | Fernando Sahmkow <fsahmkow27@gmail.com> | 2019-04-16 05:01:35 +0200 |
commit | 367704aa829a515188d87860ffd230b1b2a136c8 (patch) | |
tree | 86258d0c357bc05516a459b31553bb334b0eead3 /src/video_core/memory_manager.cpp | |
parent | Merge pull request #2378 from lioncash/ro (diff) | |
download | yuzu-367704aa829a515188d87860ffd230b1b2a136c8.tar yuzu-367704aa829a515188d87860ffd230b1b2a136c8.tar.gz yuzu-367704aa829a515188d87860ffd230b1b2a136c8.tar.bz2 yuzu-367704aa829a515188d87860ffd230b1b2a136c8.tar.lz yuzu-367704aa829a515188d87860ffd230b1b2a136c8.tar.xz yuzu-367704aa829a515188d87860ffd230b1b2a136c8.tar.zst yuzu-367704aa829a515188d87860ffd230b1b2a136c8.zip |
Diffstat (limited to '')
-rw-r--r-- | src/video_core/memory_manager.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/video_core/memory_manager.cpp b/src/video_core/memory_manager.cpp index 0f4e820aa..3b9f6caf0 100644 --- a/src/video_core/memory_manager.cpp +++ b/src/video_core/memory_manager.cpp @@ -226,6 +226,22 @@ void MemoryManager::ReadBlock(GPUVAddr src_addr, void* dest_buffer, std::size_t } } +void MemoryManager::ReadBlockUnsafe(GPUVAddr src_addr, void* dest_buffer, std::size_t size) const { + std::size_t remaining_size{size}; + std::size_t page_index{src_addr >> page_bits}; + std::size_t page_offset{src_addr & page_mask}; + + while (remaining_size > 0) { + const std::size_t copy_amount{ + std::min(static_cast<std::size_t>(page_size) - page_offset, remaining_size)}; + std::memcpy(dest_buffer, src_ptr, copy_amount); + page_index++; + page_offset = 0; + dest_buffer = static_cast<u8*>(dest_buffer) + copy_amount; + remaining_size -= copy_amount; + } +} + void MemoryManager::WriteBlock(GPUVAddr dest_addr, const void* src_buffer, std::size_t size) { std::size_t remaining_size{size}; std::size_t page_index{dest_addr >> page_bits}; @@ -253,6 +269,22 @@ void MemoryManager::WriteBlock(GPUVAddr dest_addr, const void* src_buffer, std:: } } +void MemoryManager::WriteBlockUnsafe(GPUVAddr dest_addr, const void* src_buffer, std::size_t size) { + std::size_t remaining_size{size}; + std::size_t page_index{dest_addr >> page_bits}; + std::size_t page_offset{dest_addr & page_mask}; + + while (remaining_size > 0) { + const std::size_t copy_amount{ + std::min(static_cast<std::size_t>(page_size) - page_offset, remaining_size)}; + std::memcpy(dest_ptr, src_buffer, copy_amount); + page_index++; + page_offset = 0; + src_buffer = static_cast<const u8*>(src_buffer) + copy_amount; + remaining_size -= copy_amount; + } +} + void MemoryManager::CopyBlock(GPUVAddr dest_addr, GPUVAddr src_addr, std::size_t size) { std::size_t remaining_size{size}; std::size_t page_index{src_addr >> page_bits}; |