diff options
author | bunnei <bunneidev@gmail.com> | 2018-08-29 00:43:08 +0200 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2018-08-31 19:07:27 +0200 |
commit | 16d65182f99ed1066c8e88a774d0a3637f97ae01 (patch) | |
tree | 3c10dfc449c7ebeaf40b9c249a9b483a714ecf3e /src/video_core/renderer_opengl/gl_rasterizer.cpp | |
parent | Implement BC6H_UF16 & BC6H_SF16 (#1092) (diff) | |
download | yuzu-16d65182f99ed1066c8e88a774d0a3637f97ae01.tar yuzu-16d65182f99ed1066c8e88a774d0a3637f97ae01.tar.gz yuzu-16d65182f99ed1066c8e88a774d0a3637f97ae01.tar.bz2 yuzu-16d65182f99ed1066c8e88a774d0a3637f97ae01.tar.lz yuzu-16d65182f99ed1066c8e88a774d0a3637f97ae01.tar.xz yuzu-16d65182f99ed1066c8e88a774d0a3637f97ae01.tar.zst yuzu-16d65182f99ed1066c8e88a774d0a3637f97ae01.zip |
Diffstat (limited to 'src/video_core/renderer_opengl/gl_rasterizer.cpp')
-rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index f014183b8..e70e22ba2 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -274,6 +274,44 @@ bool RasterizerOpenGL::AccelerateDrawBatch(bool is_indexed) { return true; } +template <typename Map, typename Interval> +static constexpr auto RangeFromInterval(Map& map, const Interval& interval) { + return boost::make_iterator_range(map.equal_range(interval)); +} + +void RasterizerOpenGL::UpdatePagesCachedCount(Tegra::GPUVAddr addr, u64 size, int delta) { + const u64 page_start{addr >> Tegra::MemoryManager::PAGE_BITS}; + const u64 page_end{(addr + size + Tegra::MemoryManager::PAGE_SIZE - 1) >> + Tegra::MemoryManager::PAGE_BITS}; + + // Interval maps will erase segments if count reaches 0, so if delta is negative we have to + // subtract after iterating + const auto pages_interval = CachedPageMap::interval_type::right_open(page_start, page_end); + if (delta > 0) + cached_pages.add({pages_interval, delta}); + + for (const auto& pair : RangeFromInterval(cached_pages, pages_interval)) { + const auto interval = pair.first & pages_interval; + const int count = pair.second; + + const Tegra::GPUVAddr interval_start_addr = boost::icl::first(interval) + << Tegra::MemoryManager::PAGE_BITS; + const Tegra::GPUVAddr interval_end_addr = boost::icl::last_next(interval) + << Tegra::MemoryManager::PAGE_BITS; + const u64 interval_size = interval_end_addr - interval_start_addr; + + if (delta > 0 && count == delta) + Memory::RasterizerMarkRegionCached(interval_start_addr, interval_size, true); + else if (delta < 0 && count == -delta) + Memory::RasterizerMarkRegionCached(interval_start_addr, interval_size, false); + else + ASSERT(count >= 0); + } + + if (delta < 0) + cached_pages.add({pages_interval, delta}); +} + std::pair<Surface, Surface> RasterizerOpenGL::ConfigureFramebuffers(bool using_color_fb, bool using_depth_fb, bool preserve_contents) { |