diff options
author | Fernando Sahmkow <fsahmkow27@gmail.com> | 2019-04-20 02:35:54 +0200 |
---|---|---|
committer | Fernando Sahmkow <fsahmkow27@gmail.com> | 2019-04-20 02:35:54 +0200 |
commit | db4b2bc798388fd22d3ea60eb82c5f894b2b3506 (patch) | |
tree | 76bba32ad408596e82d1d3394c269ba723b91d59 /src/video_core/memory_manager.cpp | |
parent | Implement IsBlockContinous (diff) | |
download | yuzu-db4b2bc798388fd22d3ea60eb82c5f894b2b3506.tar yuzu-db4b2bc798388fd22d3ea60eb82c5f894b2b3506.tar.gz yuzu-db4b2bc798388fd22d3ea60eb82c5f894b2b3506.tar.bz2 yuzu-db4b2bc798388fd22d3ea60eb82c5f894b2b3506.tar.lz yuzu-db4b2bc798388fd22d3ea60eb82c5f894b2b3506.tar.xz yuzu-db4b2bc798388fd22d3ea60eb82c5f894b2b3506.tar.zst yuzu-db4b2bc798388fd22d3ea60eb82c5f894b2b3506.zip |
Diffstat (limited to '')
-rw-r--r-- | src/video_core/memory_manager.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/video_core/memory_manager.cpp b/src/video_core/memory_manager.cpp index 095a7e5a4..6c98c6701 100644 --- a/src/video_core/memory_manager.cpp +++ b/src/video_core/memory_manager.cpp @@ -243,8 +243,13 @@ void MemoryManager::ReadBlockUnsafe(GPUVAddr src_addr, void* dest_buffer, while (remaining_size > 0) { const std::size_t copy_amount{ std::min(static_cast<std::size_t>(page_size) - page_offset, remaining_size)}; - const u8* src_ptr{page_table.pointers[page_index] + page_offset}; - std::memcpy(dest_buffer, src_ptr, copy_amount); + const u8* page_pointer = page_table.pointers[page_index]; + if (page_pointer) { + const u8* src_ptr{page_pointer + page_offset}; + std::memcpy(dest_buffer, src_ptr, copy_amount); + } else { + std::memset(dest_buffer, 0, copy_amount); + } page_index++; page_offset = 0; dest_buffer = static_cast<u8*>(dest_buffer) + copy_amount; @@ -288,8 +293,11 @@ void MemoryManager::WriteBlockUnsafe(GPUVAddr dest_addr, const void* src_buffer, while (remaining_size > 0) { const std::size_t copy_amount{ std::min(static_cast<std::size_t>(page_size) - page_offset, remaining_size)}; - u8* dest_ptr{page_table.pointers[page_index] + page_offset}; - std::memcpy(dest_ptr, src_buffer, copy_amount); + u8* page_pointer = page_table.pointers[page_index]; + if (page_pointer) { + u8* dest_ptr{page_pointer + page_offset}; + std::memcpy(dest_ptr, src_buffer, copy_amount); + } page_index++; page_offset = 0; src_buffer = static_cast<const u8*>(src_buffer) + copy_amount; |