diff options
author | bunnei <bunneidev@gmail.com> | 2018-08-28 03:35:15 +0200 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2018-08-31 19:07:27 +0200 |
commit | d647d9550c838fdfb16ad053f3ff243de3e15482 (patch) | |
tree | 8bde428c4c670d134dd13b849044e4369566d8f9 /src/core/memory.cpp | |
parent | gl_rasterizer: Fix issues with the rasterizer cache. (diff) | |
download | yuzu-d647d9550c838fdfb16ad053f3ff243de3e15482.tar yuzu-d647d9550c838fdfb16ad053f3ff243de3e15482.tar.gz yuzu-d647d9550c838fdfb16ad053f3ff243de3e15482.tar.bz2 yuzu-d647d9550c838fdfb16ad053f3ff243de3e15482.tar.lz yuzu-d647d9550c838fdfb16ad053f3ff243de3e15482.tar.xz yuzu-d647d9550c838fdfb16ad053f3ff243de3e15482.tar.zst yuzu-d647d9550c838fdfb16ad053f3ff243de3e15482.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/memory.cpp | 51 |
1 files changed, 15 insertions, 36 deletions
diff --git a/src/core/memory.cpp b/src/core/memory.cpp index bc34bfd6d..0e4e0157c 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -251,8 +251,8 @@ std::string ReadCString(VAddr vaddr, std::size_t max_length) { return string; } -void RasterizerMarkRegionCached(Tegra::GPUVAddr gpu_addr, u64 size, bool cached) { - if (gpu_addr == 0) { +void RasterizerMarkRegionCached(VAddr vaddr, u64 size, bool cached) { + if (vaddr == 0) { return; } @@ -261,19 +261,8 @@ void RasterizerMarkRegionCached(Tegra::GPUVAddr gpu_addr, u64 size, bool cached) // CPU pages, hence why we iterate on a CPU page basis (note: GPU page size is different). This // assumes the specified GPU address region is contiguous as well. - u64 num_pages = ((gpu_addr + size - 1) >> PAGE_BITS) - (gpu_addr >> PAGE_BITS) + 1; - for (unsigned i = 0; i < num_pages; ++i, gpu_addr += PAGE_SIZE) { - boost::optional<VAddr> maybe_vaddr = - Core::System::GetInstance().GPU().MemoryManager().GpuToCpuAddress(gpu_addr); - // The GPU <-> CPU virtual memory mapping is not 1:1 - if (!maybe_vaddr) { - LOG_ERROR(HW_Memory, - "Trying to flush a cached region to an invalid physical address {:016X}", - gpu_addr); - continue; - } - VAddr vaddr = *maybe_vaddr; - + u64 num_pages = ((vaddr + size - 1) >> PAGE_BITS) - (vaddr >> PAGE_BITS) + 1; + for (unsigned i = 0; i < num_pages; ++i, vaddr += PAGE_SIZE) { PageType& page_type = current_page_table->attributes[vaddr >> PAGE_BITS]; if (cached) { @@ -344,29 +333,19 @@ void RasterizerFlushVirtualRegion(VAddr start, u64 size, FlushMode mode) { const VAddr overlap_start = std::max(start, region_start); const VAddr overlap_end = std::min(end, region_end); - - const std::vector<Tegra::GPUVAddr> gpu_addresses = - system_instance.GPU().MemoryManager().CpuToGpuAddress(overlap_start); - - if (gpu_addresses.empty()) { - return; - } - const u64 overlap_size = overlap_end - overlap_start; - for (const auto& gpu_address : gpu_addresses) { - auto& rasterizer = system_instance.Renderer().Rasterizer(); - switch (mode) { - case FlushMode::Flush: - rasterizer.FlushRegion(gpu_address, overlap_size); - break; - case FlushMode::Invalidate: - rasterizer.InvalidateRegion(gpu_address, overlap_size); - break; - case FlushMode::FlushAndInvalidate: - rasterizer.FlushAndInvalidateRegion(gpu_address, overlap_size); - break; - } + auto& rasterizer = system_instance.Renderer().Rasterizer(); + switch (mode) { + case FlushMode::Flush: + rasterizer.FlushRegion(overlap_start, overlap_size); + break; + case FlushMode::Invalidate: + rasterizer.InvalidateRegion(overlap_start, overlap_size); + break; + case FlushMode::FlushAndInvalidate: + rasterizer.FlushAndInvalidateRegion(overlap_start, overlap_size); + break; } }; |