diff options
| author | 2018-03-24 22:24:45 -0400 | |
|---|---|---|
| committer | 2018-03-26 21:16:58 -0400 | |
| commit | c1ccbf332fdb00151d02907b84106304736fc39a (patch) | |
| tree | 162b949efb3089a7fca55d18cc7af9927c7ab3cb | |
| parent | memory: Add RasterizerMarkRegionCached code and cleanup. (diff) | |
| download | yuzu-c1ccbf332fdb00151d02907b84106304736fc39a.tar.gz yuzu-c1ccbf332fdb00151d02907b84106304736fc39a.tar.xz yuzu-c1ccbf332fdb00151d02907b84106304736fc39a.zip | |
gl_rasterizer_cache: Implement UpdatePagesCachedCount.
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 43 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.h | 2 |
2 files changed, 37 insertions, 8 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 42d3730ee..2ffbd3bab 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | |||
| @@ -250,8 +250,8 @@ static bool BlitTextures(GLuint src_tex, const MathUtil::Rectangle<u32>& src_rec | |||
| 250 | 250 | ||
| 251 | static bool FillSurface(const Surface& surface, const u8* fill_data, | 251 | static bool FillSurface(const Surface& surface, const u8* fill_data, |
| 252 | const MathUtil::Rectangle<u32>& fill_rect, GLuint draw_fb_handle) { | 252 | const MathUtil::Rectangle<u32>& fill_rect, GLuint draw_fb_handle) { |
| 253 | ASSERT_MSG(false, "Unimplemented"); | 253 | UNREACHABLE(); |
| 254 | return true; | 254 | return {}; |
| 255 | } | 255 | } |
| 256 | 256 | ||
| 257 | SurfaceParams SurfaceParams::FromInterval(SurfaceInterval interval) const { | 257 | SurfaceParams SurfaceParams::FromInterval(SurfaceInterval interval) const { |
| @@ -490,8 +490,9 @@ MICROPROFILE_DEFINE(OpenGL_SurfaceLoad, "OpenGL", "Surface Load", MP_RGB(128, 64 | |||
| 490 | void CachedSurface::LoadGLBuffer(VAddr load_start, VAddr load_end) { | 490 | void CachedSurface::LoadGLBuffer(VAddr load_start, VAddr load_end) { |
| 491 | ASSERT(type != SurfaceType::Fill); | 491 | ASSERT(type != SurfaceType::Fill); |
| 492 | 492 | ||
| 493 | u8* texture_src_data = Memory::GetPointer(addr); | 493 | u8* const texture_src_data = Memory::GetPointer(addr); |
| 494 | ASSERT(texture_src_data); | 494 | if (texture_src_data == nullptr) |
| 495 | return; | ||
| 495 | 496 | ||
| 496 | if (gl_buffer == nullptr) { | 497 | if (gl_buffer == nullptr) { |
| 497 | gl_buffer_size = width * height * GetGLBytesPerPixel(pixel_format); | 498 | gl_buffer_size = width * height * GetGLBytesPerPixel(pixel_format); |
| @@ -1056,7 +1057,7 @@ SurfaceRect_Tuple RasterizerCacheOpenGL::GetSurfaceSubRect(const SurfaceParams& | |||
| 1056 | } | 1057 | } |
| 1057 | 1058 | ||
| 1058 | Surface RasterizerCacheOpenGL::GetTextureSurface(const void* config) { | 1059 | Surface RasterizerCacheOpenGL::GetTextureSurface(const void* config) { |
| 1059 | ASSERT_MSG(false, "Unimplemented"); | 1060 | UNREACHABLE(); |
| 1060 | return {}; | 1061 | return {}; |
| 1061 | } | 1062 | } |
| 1062 | 1063 | ||
| @@ -1155,7 +1156,7 @@ SurfaceSurfaceRect_Tuple RasterizerCacheOpenGL::GetFramebufferSurfaces( | |||
| 1155 | } | 1156 | } |
| 1156 | 1157 | ||
| 1157 | Surface RasterizerCacheOpenGL::GetFillSurface(const void* config) { | 1158 | Surface RasterizerCacheOpenGL::GetFillSurface(const void* config) { |
| 1158 | ASSERT_MSG(false, "Unimplemented"); | 1159 | UNREACHABLE(); |
| 1159 | return {}; | 1160 | return {}; |
| 1160 | } | 1161 | } |
| 1161 | 1162 | ||
| @@ -1399,5 +1400,33 @@ void RasterizerCacheOpenGL::UnregisterSurface(const Surface& surface) { | |||
| 1399 | } | 1400 | } |
| 1400 | 1401 | ||
| 1401 | void RasterizerCacheOpenGL::UpdatePagesCachedCount(VAddr addr, u64 size, int delta) { | 1402 | void RasterizerCacheOpenGL::UpdatePagesCachedCount(VAddr addr, u64 size, int delta) { |
| 1402 | // ASSERT_MSG(false, "Unimplemented"); | 1403 | const u64 num_pages = |
| 1404 | ((addr + size - 1) >> Memory::PAGE_BITS) - (addr >> Memory::PAGE_BITS) + 1; | ||
| 1405 | const u64 page_start = addr >> Memory::PAGE_BITS; | ||
| 1406 | const u64 page_end = page_start + num_pages; | ||
| 1407 | |||
| 1408 | // Interval maps will erase segments if count reaches 0, so if delta is negative we have to | ||
| 1409 | // subtract after iterating | ||
| 1410 | const auto pages_interval = PageMap::interval_type::right_open(page_start, page_end); | ||
| 1411 | if (delta > 0) | ||
| 1412 | cached_pages.add({pages_interval, delta}); | ||
| 1413 | |||
| 1414 | for (const auto& pair : RangeFromInterval(cached_pages, pages_interval)) { | ||
| 1415 | const auto interval = pair.first & pages_interval; | ||
| 1416 | const int count = pair.second; | ||
| 1417 | |||
| 1418 | const VAddr interval_start_addr = boost::icl::first(interval) << Memory::PAGE_BITS; | ||
| 1419 | const VAddr interval_end_addr = boost::icl::last_next(interval) << Memory::PAGE_BITS; | ||
| 1420 | const u64 interval_size = interval_end_addr - interval_start_addr; | ||
| 1421 | |||
| 1422 | if (delta > 0 && count == delta) | ||
| 1423 | Memory::RasterizerMarkRegionCached(interval_start_addr, interval_size, true); | ||
| 1424 | else if (delta < 0 && count == -delta) | ||
| 1425 | Memory::RasterizerMarkRegionCached(interval_start_addr, interval_size, false); | ||
| 1426 | else | ||
| 1427 | ASSERT(count >= 0); | ||
| 1428 | } | ||
| 1429 | |||
| 1430 | if (delta < 0) | ||
| 1431 | cached_pages.add({pages_interval, delta}); | ||
| 1403 | } | 1432 | } |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h index 0e1c481d7..1f660d30c 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h | |||
| @@ -41,7 +41,7 @@ static_assert(std::is_same<SurfaceRegions::interval_type, SurfaceCache::interval | |||
| 41 | using SurfaceRect_Tuple = std::tuple<Surface, MathUtil::Rectangle<u32>>; | 41 | using SurfaceRect_Tuple = std::tuple<Surface, MathUtil::Rectangle<u32>>; |
| 42 | using SurfaceSurfaceRect_Tuple = std::tuple<Surface, Surface, MathUtil::Rectangle<u32>>; | 42 | using SurfaceSurfaceRect_Tuple = std::tuple<Surface, Surface, MathUtil::Rectangle<u32>>; |
| 43 | 43 | ||
| 44 | using PageMap = boost::icl::interval_map<u32, int>; | 44 | using PageMap = boost::icl::interval_map<u64, int>; |
| 45 | 45 | ||
| 46 | enum class ScaleMatch { | 46 | enum class ScaleMatch { |
| 47 | Exact, // only accept same res scale | 47 | Exact, // only accept same res scale |