diff options
| author | 2018-08-30 20:08:43 -0400 | |
|---|---|---|
| committer | 2018-08-31 13:07:28 -0400 | |
| commit | 123c065086106ba7d405c554ab27ca738941d872 (patch) | |
| tree | 3d0a3977813e3698e558c87e5b8ace6a459c5bbb /src | |
| parent | rasterizer_cache: Use boost::interval_map for a more accurate cache. (diff) | |
| download | yuzu-123c065086106ba7d405c554ab27ca738941d872.tar.gz yuzu-123c065086106ba7d405c554ab27ca738941d872.tar.xz yuzu-123c065086106ba7d405c554ab27ca738941d872.zip | |
gl_rasterizer_cache: Also use reserve cache for RecreateSurface.
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 27 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.h | 15 |
2 files changed, 18 insertions, 24 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 8cd4c2956..b13fbd144 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | |||
| @@ -780,15 +780,9 @@ Surface RasterizerCacheOpenGL::GetSurface(const SurfaceParams& params, bool pres | |||
| 780 | } | 780 | } |
| 781 | } | 781 | } |
| 782 | 782 | ||
| 783 | // Try to get a previously reserved surface | 783 | // No cached surface found - get a new one |
| 784 | surface = TryGetReservedSurface(params); | 784 | surface = GetUncachedSurface(params); |
| 785 | 785 | Register(surface); | |
| 786 | // No surface found - create a new one | ||
| 787 | if (!surface) { | ||
| 788 | surface = std::make_shared<CachedSurface>(params); | ||
| 789 | ReserveSurface(surface); | ||
| 790 | Register(surface); | ||
| 791 | } | ||
| 792 | 786 | ||
| 793 | // Only load surface from memory if we care about the contents | 787 | // Only load surface from memory if we care about the contents |
| 794 | if (preserve_contents) { | 788 | if (preserve_contents) { |
| @@ -798,13 +792,23 @@ Surface RasterizerCacheOpenGL::GetSurface(const SurfaceParams& params, bool pres | |||
| 798 | return surface; | 792 | return surface; |
| 799 | } | 793 | } |
| 800 | 794 | ||
| 795 | Surface RasterizerCacheOpenGL::GetUncachedSurface(const SurfaceParams& params) { | ||
| 796 | Surface surface{TryGetReservedSurface(params)}; | ||
| 797 | if (!surface) { | ||
| 798 | // No reserved surface available, create a new one and reserve it | ||
| 799 | surface = std::make_shared<CachedSurface>(params); | ||
| 800 | ReserveSurface(surface); | ||
| 801 | } | ||
| 802 | return surface; | ||
| 803 | } | ||
| 804 | |||
| 801 | Surface RasterizerCacheOpenGL::RecreateSurface(const Surface& surface, | 805 | Surface RasterizerCacheOpenGL::RecreateSurface(const Surface& surface, |
| 802 | const SurfaceParams& new_params) { | 806 | const SurfaceParams& new_params) { |
| 803 | // Verify surface is compatible for blitting | 807 | // Verify surface is compatible for blitting |
| 804 | const auto& params{surface->GetSurfaceParams()}; | 808 | const auto& params{surface->GetSurfaceParams()}; |
| 805 | 809 | ||
| 806 | // Create a new surface with the new parameters, and blit the previous surface to it | 810 | // Get a new surface with the new parameters, and blit the previous surface to it |
| 807 | Surface new_surface{std::make_shared<CachedSurface>(new_params)}; | 811 | Surface new_surface{GetUncachedSurface(new_params)}; |
| 808 | 812 | ||
| 809 | // If format is unchanged, we can do a faster blit without reinterpreting pixel data | 813 | // If format is unchanged, we can do a faster blit without reinterpreting pixel data |
| 810 | if (params.pixel_format == new_params.pixel_format) { | 814 | if (params.pixel_format == new_params.pixel_format) { |
| @@ -887,7 +891,6 @@ Surface RasterizerCacheOpenGL::TryGetReservedSurface(const SurfaceParams& params | |||
| 887 | const auto& surface_reserve_key{SurfaceReserveKey::Create(params)}; | 891 | const auto& surface_reserve_key{SurfaceReserveKey::Create(params)}; |
| 888 | auto search{surface_reserve.find(surface_reserve_key)}; | 892 | auto search{surface_reserve.find(surface_reserve_key)}; |
| 889 | if (search != surface_reserve.end()) { | 893 | if (search != surface_reserve.end()) { |
| 890 | Register(search->second); | ||
| 891 | return search->second; | 894 | return search->second; |
| 892 | } | 895 | } |
| 893 | return {}; | 896 | return {}; |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h index f381e735f..aad75f200 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h | |||
| @@ -650,18 +650,6 @@ struct SurfaceParams { | |||
| 650 | Tegra::GPUVAddr zeta_address, | 650 | Tegra::GPUVAddr zeta_address, |
| 651 | Tegra::DepthFormat format); | 651 | Tegra::DepthFormat format); |
| 652 | 652 | ||
| 653 | bool operator==(const SurfaceParams& other) const { | ||
| 654 | return std::tie(addr, is_tiled, block_height, pixel_format, component_type, type, width, | ||
| 655 | height, unaligned_height, size_in_bytes) == | ||
| 656 | std::tie(other.addr, other.is_tiled, other.block_height, other.pixel_format, | ||
| 657 | other.component_type, other.type, other.width, other.height, | ||
| 658 | other.unaligned_height, other.size_in_bytes); | ||
| 659 | } | ||
| 660 | |||
| 661 | bool operator!=(const SurfaceParams& other) const { | ||
| 662 | return !operator==(other); | ||
| 663 | } | ||
| 664 | |||
| 665 | /// Checks if surfaces are compatible for caching | 653 | /// Checks if surfaces are compatible for caching |
| 666 | bool IsCompatibleSurface(const SurfaceParams& other) const { | 654 | bool IsCompatibleSurface(const SurfaceParams& other) const { |
| 667 | return std::tie(pixel_format, type, cache_width, cache_height) == | 655 | return std::tie(pixel_format, type, cache_width, cache_height) == |
| @@ -767,6 +755,9 @@ private: | |||
| 767 | void LoadSurface(const Surface& surface); | 755 | void LoadSurface(const Surface& surface); |
| 768 | Surface GetSurface(const SurfaceParams& params, bool preserve_contents = true); | 756 | Surface GetSurface(const SurfaceParams& params, bool preserve_contents = true); |
| 769 | 757 | ||
| 758 | /// Gets an uncached surface, creating it if need be | ||
| 759 | Surface GetUncachedSurface(const SurfaceParams& params); | ||
| 760 | |||
| 770 | /// Recreates a surface with new parameters | 761 | /// Recreates a surface with new parameters |
| 771 | Surface RecreateSurface(const Surface& surface, const SurfaceParams& new_params); | 762 | Surface RecreateSurface(const Surface& surface, const SurfaceParams& new_params); |
| 772 | 763 | ||