mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-07-04 23:31:19 +01:00
video_core/memory_manager: Add GPU address based flush method
Allow flushing rasterizer contents based on a GPU address.
This commit is contained in:
parent
4cd8b2f1f7
commit
dd790abab0
2 changed files with 17 additions and 0 deletions
|
@ -314,6 +314,21 @@ 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) {
|
void MemoryManager::CopyBlock(GPUVAddr gpu_dest_addr, GPUVAddr gpu_src_addr, std::size_t size) {
|
||||||
std::vector<u8> tmp_buffer(size);
|
std::vector<u8> tmp_buffer(size);
|
||||||
ReadBlock(gpu_src_addr, tmp_buffer.data(), size);
|
ReadBlock(gpu_src_addr, tmp_buffer.data(), size);
|
||||||
|
|
|
@ -131,6 +131,8 @@ private:
|
||||||
void TryLockPage(PageEntry page_entry, std::size_t size);
|
void TryLockPage(PageEntry page_entry, std::size_t size);
|
||||||
void TryUnlockPage(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) {
|
[[nodiscard]] static constexpr std::size_t PageEntryIndex(GPUVAddr gpu_addr) {
|
||||||
return (gpu_addr >> page_bits) & page_table_mask;
|
return (gpu_addr >> page_bits) & page_table_mask;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue