summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2021-01-25 07:57:00 +0100
committerGitHub <noreply@github.com>2021-01-25 07:57:00 +0100
commit62766b13264fd61e92ee287e6fb9cad0b5d00781 (patch)
tree9136e03ad81c345c0966caced9c9a7d2a152939a /src
parentMerge pull request #5823 from ReinUsesLisp/revert-flags (diff)
parentvideo_core/memory_manager: Remove unused CopyBlockUnsafe (diff)
downloadyuzu-62766b13264fd61e92ee287e6fb9cad0b5d00781.tar
yuzu-62766b13264fd61e92ee287e6fb9cad0b5d00781.tar.gz
yuzu-62766b13264fd61e92ee287e6fb9cad0b5d00781.tar.bz2
yuzu-62766b13264fd61e92ee287e6fb9cad0b5d00781.tar.lz
yuzu-62766b13264fd61e92ee287e6fb9cad0b5d00781.tar.xz
yuzu-62766b13264fd61e92ee287e6fb9cad0b5d00781.tar.zst
yuzu-62766b13264fd61e92ee287e6fb9cad0b5d00781.zip
Diffstat (limited to 'src')
-rw-r--r--src/video_core/memory_manager.cpp26
-rw-r--r--src/video_core/memory_manager.h3
2 files changed, 21 insertions, 8 deletions
diff --git a/src/video_core/memory_manager.cpp b/src/video_core/memory_manager.cpp
index 65feff588..f5cdf548e 100644
--- a/src/video_core/memory_manager.cpp
+++ b/src/video_core/memory_manager.cpp
@@ -314,17 +314,29 @@ void MemoryManager::WriteBlockUnsafe(GPUVAddr gpu_dest_addr, const void* src_buf
}
}
+void MemoryManager::FlushRegion(GPUVAddr gpu_addr, size_t size) const {
+ size_t remaining_size{size};
+ size_t page_index{gpu_addr >> page_bits};
+ size_t page_offset{gpu_addr & page_mask};
+ while (remaining_size > 0) {
+ const size_t num_bytes{std::min(page_size - page_offset, remaining_size)};
+ if (const auto page_addr{GpuToCpuAddress(page_index << page_bits)}; page_addr) {
+ rasterizer->FlushRegion(*page_addr + page_offset, num_bytes);
+ }
+ ++page_index;
+ page_offset = 0;
+ remaining_size -= num_bytes;
+ }
+}
+
void MemoryManager::CopyBlock(GPUVAddr gpu_dest_addr, GPUVAddr gpu_src_addr, std::size_t size) {
std::vector<u8> tmp_buffer(size);
ReadBlock(gpu_src_addr, tmp_buffer.data(), size);
- WriteBlock(gpu_dest_addr, tmp_buffer.data(), size);
-}
-void MemoryManager::CopyBlockUnsafe(GPUVAddr gpu_dest_addr, GPUVAddr gpu_src_addr,
- std::size_t size) {
- std::vector<u8> tmp_buffer(size);
- ReadBlockUnsafe(gpu_src_addr, tmp_buffer.data(), size);
- WriteBlockUnsafe(gpu_dest_addr, tmp_buffer.data(), size);
+ // The output block must be flushed in case it has data modified from the GPU.
+ // Fixes NPC geometry in Zombie Panic in Wonderland DX
+ FlushRegion(gpu_dest_addr, size);
+ WriteBlock(gpu_dest_addr, tmp_buffer.data(), size);
}
bool MemoryManager::IsGranularRange(GPUVAddr gpu_addr, std::size_t size) const {
diff --git a/src/video_core/memory_manager.h b/src/video_core/memory_manager.h
index c35e57689..a52fbbd8c 100644
--- a/src/video_core/memory_manager.h
+++ b/src/video_core/memory_manager.h
@@ -107,7 +107,6 @@ public:
*/
void ReadBlockUnsafe(GPUVAddr gpu_src_addr, void* dest_buffer, std::size_t size) const;
void WriteBlockUnsafe(GPUVAddr gpu_dest_addr, const void* src_buffer, std::size_t size);
- void CopyBlockUnsafe(GPUVAddr gpu_dest_addr, GPUVAddr gpu_src_addr, std::size_t size);
/**
* IsGranularRange checks if a gpu region can be simply read with a pointer.
@@ -131,6 +130,8 @@ private:
void TryLockPage(PageEntry page_entry, std::size_t size);
void TryUnlockPage(PageEntry page_entry, std::size_t size);
+ void FlushRegion(GPUVAddr gpu_addr, size_t size) const;
+
[[nodiscard]] static constexpr std::size_t PageEntryIndex(GPUVAddr gpu_addr) {
return (gpu_addr >> page_bits) & page_table_mask;
}