diff options
| author | 2019-04-16 15:45:24 -0400 | |
|---|---|---|
| committer | 2019-04-16 18:49:35 -0400 | |
| commit | d0082de82a094c98a5ef8907583415daef91604a (patch) | |
| tree | f9e634136a921a76d81a34457bdc9633177a9ea3 /src | |
| parent | Use ReadBlockUnsafe for fetyching DMA CommandLists (diff) | |
| download | yuzu-d0082de82a094c98a5ef8907583415daef91604a.tar.gz yuzu-d0082de82a094c98a5ef8907583415daef91604a.tar.xz yuzu-d0082de82a094c98a5ef8907583415daef91604a.zip | |
Implement IsBlockContinous
This detects when a GPU Memory Block is not continous within host cpu
memory.
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/memory_manager.cpp | 8 | ||||
| -rw-r--r-- | src/video_core/memory_manager.h | 7 |
2 files changed, 13 insertions, 2 deletions
diff --git a/src/video_core/memory_manager.cpp b/src/video_core/memory_manager.cpp index 18a8d2684..095a7e5a4 100644 --- a/src/video_core/memory_manager.cpp +++ b/src/video_core/memory_manager.cpp | |||
| @@ -199,6 +199,14 @@ const u8* MemoryManager::GetPointer(GPUVAddr addr) const { | |||
| 199 | return {}; | 199 | return {}; |
| 200 | } | 200 | } |
| 201 | 201 | ||
| 202 | bool MemoryManager::IsBlockContinous(const GPUVAddr start, const std::size_t size) { | ||
| 203 | const GPUVAddr end = start + size; | ||
| 204 | const auto host_ptr_start = reinterpret_cast<std::uintptr_t>(GetPointer(start)); | ||
| 205 | const auto host_ptr_end = reinterpret_cast<std::uintptr_t>(GetPointer(end)); | ||
| 206 | const std::size_t range = static_cast<std::size_t>(host_ptr_end - host_ptr_start); | ||
| 207 | return range == size; | ||
| 208 | } | ||
| 209 | |||
| 202 | void MemoryManager::ReadBlock(GPUVAddr src_addr, void* dest_buffer, const std::size_t size) const { | 210 | void MemoryManager::ReadBlock(GPUVAddr src_addr, void* dest_buffer, const std::size_t size) const { |
| 203 | std::size_t remaining_size{size}; | 211 | std::size_t remaining_size{size}; |
| 204 | std::size_t page_index{src_addr >> page_bits}; | 212 | std::size_t page_index{src_addr >> page_bits}; |
diff --git a/src/video_core/memory_manager.h b/src/video_core/memory_manager.h index 017b051cf..e4f0c4bd6 100644 --- a/src/video_core/memory_manager.h +++ b/src/video_core/memory_manager.h | |||
| @@ -65,7 +65,10 @@ public: | |||
| 65 | u8* GetPointer(GPUVAddr addr); | 65 | u8* GetPointer(GPUVAddr addr); |
| 66 | const u8* GetPointer(GPUVAddr addr) const; | 66 | const u8* GetPointer(GPUVAddr addr) const; |
| 67 | 67 | ||
| 68 | /* | 68 | // Returns true if the block is continous in host memory, false otherwise |
| 69 | bool IsBlockContinous(const GPUVAddr start, const std::size_t size); | ||
| 70 | |||
| 71 | /** | ||
| 69 | * ReadBlock and WriteBlock are full read and write operations over virtual | 72 | * ReadBlock and WriteBlock are full read and write operations over virtual |
| 70 | * GPU Memory. It's important to use these when GPU memory may not be continous | 73 | * GPU Memory. It's important to use these when GPU memory may not be continous |
| 71 | * in the Host Memory counterpart. Note: This functions cause Host GPU Memory | 74 | * in the Host Memory counterpart. Note: This functions cause Host GPU Memory |
| @@ -75,7 +78,7 @@ public: | |||
| 75 | void WriteBlock(GPUVAddr dest_addr, const void* src_buffer, const std::size_t size); | 78 | void WriteBlock(GPUVAddr dest_addr, const void* src_buffer, const std::size_t size); |
| 76 | void CopyBlock(GPUVAddr dest_addr, GPUVAddr src_addr, const std::size_t size); | 79 | void CopyBlock(GPUVAddr dest_addr, GPUVAddr src_addr, const std::size_t size); |
| 77 | 80 | ||
| 78 | /* | 81 | /** |
| 79 | * ReadBlockUnsafe and WriteBlockUnsafe are special versions of ReadBlock and | 82 | * ReadBlockUnsafe and WriteBlockUnsafe are special versions of ReadBlock and |
| 80 | * WriteBlock respectively. In this versions, no flushing or invalidation is actually | 83 | * WriteBlock respectively. In this versions, no flushing or invalidation is actually |
| 81 | * done and their performance is similar to a memcpy. This functions can be used | 84 | * done and their performance is similar to a memcpy. This functions can be used |