summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_opengl
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2018-08-31 02:08:43 +0200
committerbunnei <bunneidev@gmail.com>2018-08-31 19:07:28 +0200
commit123c065086106ba7d405c554ab27ca738941d872 (patch)
tree3d0a3977813e3698e558c87e5b8ace6a459c5bbb /src/video_core/renderer_opengl
parentrasterizer_cache: Use boost::interval_map for a more accurate cache. (diff)
downloadyuzu-123c065086106ba7d405c554ab27ca738941d872.tar
yuzu-123c065086106ba7d405c554ab27ca738941d872.tar.gz
yuzu-123c065086106ba7d405c554ab27ca738941d872.tar.bz2
yuzu-123c065086106ba7d405c554ab27ca738941d872.tar.lz
yuzu-123c065086106ba7d405c554ab27ca738941d872.tar.xz
yuzu-123c065086106ba7d405c554ab27ca738941d872.tar.zst
yuzu-123c065086106ba7d405c554ab27ca738941d872.zip
Diffstat (limited to 'src/video_core/renderer_opengl')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.cpp27
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.h15
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
}
}
- // Try to get a previously reserved surface
- surface = TryGetReservedSurface(params);
-
- // No surface found - create a new one
- if (!surface) {
- surface = std::make_shared<CachedSurface>(params);
- ReserveSurface(surface);
- Register(surface);
- }
+ // No cached surface found - get a new one
+ surface = GetUncachedSurface(params);
+ Register(surface);
// Only load surface from memory if we care about the contents
if (preserve_contents) {
@@ -798,13 +792,23 @@ Surface RasterizerCacheOpenGL::GetSurface(const SurfaceParams& params, bool pres
return surface;
}
+Surface RasterizerCacheOpenGL::GetUncachedSurface(const SurfaceParams& params) {
+ Surface surface{TryGetReservedSurface(params)};
+ if (!surface) {
+ // No reserved surface available, create a new one and reserve it
+ surface = std::make_shared<CachedSurface>(params);
+ ReserveSurface(surface);
+ }
+ return surface;
+}
+
Surface RasterizerCacheOpenGL::RecreateSurface(const Surface& surface,
const SurfaceParams& new_params) {
// Verify surface is compatible for blitting
const auto& params{surface->GetSurfaceParams()};
- // Create a new surface with the new parameters, and blit the previous surface to it
- Surface new_surface{std::make_shared<CachedSurface>(new_params)};
+ // Get a new surface with the new parameters, and blit the previous surface to it
+ Surface new_surface{GetUncachedSurface(new_params)};
// If format is unchanged, we can do a faster blit without reinterpreting pixel data
if (params.pixel_format == new_params.pixel_format) {
@@ -887,7 +891,6 @@ Surface RasterizerCacheOpenGL::TryGetReservedSurface(const SurfaceParams& params
const auto& surface_reserve_key{SurfaceReserveKey::Create(params)};
auto search{surface_reserve.find(surface_reserve_key)};
if (search != surface_reserve.end()) {
- Register(search->second);
return search->second;
}
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 {
Tegra::GPUVAddr zeta_address,
Tegra::DepthFormat format);
- bool operator==(const SurfaceParams& other) const {
- return std::tie(addr, is_tiled, block_height, pixel_format, component_type, type, width,
- height, unaligned_height, size_in_bytes) ==
- std::tie(other.addr, other.is_tiled, other.block_height, other.pixel_format,
- other.component_type, other.type, other.width, other.height,
- other.unaligned_height, other.size_in_bytes);
- }
-
- bool operator!=(const SurfaceParams& other) const {
- return !operator==(other);
- }
-
/// Checks if surfaces are compatible for caching
bool IsCompatibleSurface(const SurfaceParams& other) const {
return std::tie(pixel_format, type, cache_width, cache_height) ==
@@ -767,6 +755,9 @@ private:
void LoadSurface(const Surface& surface);
Surface GetSurface(const SurfaceParams& params, bool preserve_contents = true);
+ /// Gets an uncached surface, creating it if need be
+ Surface GetUncachedSurface(const SurfaceParams& params);
+
/// Recreates a surface with new parameters
Surface RecreateSurface(const Surface& surface, const SurfaceParams& new_params);