summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2018-08-05 23:30:18 -0400
committerGravatar bunnei2018-08-05 23:40:03 -0400
commit57eb936200415ea3178445f7252bb0b0584cd557 (patch)
treef313b79a75250a01394e2f9eaa2b0b2da44b0efc /src
parentMerge pull request #932 from lioncash/func (diff)
downloadyuzu-57eb936200415ea3178445f7252bb0b0584cd557.tar.gz
yuzu-57eb936200415ea3178445f7252bb0b0584cd557.tar.xz
yuzu-57eb936200415ea3178445f7252bb0b0584cd557.zip
gl_rasterizer_cache: Avoid superfluous surface copies.
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.cpp14
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.h11
2 files changed, 21 insertions, 4 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
index c8f0c4e28..257aa9571 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
@@ -46,6 +46,8 @@ struct FormatTuple {
46 params.height = Common::AlignUp(config.tic.Height(), GetCompressionFactor(params.pixel_format)); 46 params.height = Common::AlignUp(config.tic.Height(), GetCompressionFactor(params.pixel_format));
47 params.unaligned_height = config.tic.Height(); 47 params.unaligned_height = config.tic.Height();
48 params.size_in_bytes = params.SizeInBytes(); 48 params.size_in_bytes = params.SizeInBytes();
49 params.cache_width = Common::AlignUp(params.width, 16);
50 params.cache_height = Common::AlignUp(params.height, 16);
49 return params; 51 return params;
50} 52}
51 53
@@ -63,6 +65,8 @@ struct FormatTuple {
63 params.height = config.height; 65 params.height = config.height;
64 params.unaligned_height = config.height; 66 params.unaligned_height = config.height;
65 params.size_in_bytes = params.SizeInBytes(); 67 params.size_in_bytes = params.SizeInBytes();
68 params.cache_width = Common::AlignUp(params.width, 16);
69 params.cache_height = Common::AlignUp(params.height, 16);
66 return params; 70 return params;
67} 71}
68 72
@@ -82,6 +86,8 @@ struct FormatTuple {
82 params.height = zeta_height; 86 params.height = zeta_height;
83 params.unaligned_height = zeta_height; 87 params.unaligned_height = zeta_height;
84 params.size_in_bytes = params.SizeInBytes(); 88 params.size_in_bytes = params.SizeInBytes();
89 params.cache_width = Common::AlignUp(params.width, 16);
90 params.cache_height = Common::AlignUp(params.height, 16);
85 return params; 91 return params;
86} 92}
87 93
@@ -680,12 +686,12 @@ Surface RasterizerCacheOpenGL::GetSurface(const SurfaceParams& params) {
680 // If use_accurate_framebuffers is enabled, always load from memory 686 // If use_accurate_framebuffers is enabled, always load from memory
681 FlushSurface(surface); 687 FlushSurface(surface);
682 UnregisterSurface(surface); 688 UnregisterSurface(surface);
683 } else if (surface->GetSurfaceParams() != params) { 689 } else if (surface->GetSurfaceParams().IsCompatibleSurface(params)) {
684 // If surface parameters changed, recreate the surface from the old one
685 return RecreateSurface(surface, params);
686 } else {
687 // Use the cached surface as-is 690 // Use the cached surface as-is
688 return surface; 691 return surface;
692 } else {
693 // If surface parameters changed, recreate the surface from the old one
694 return RecreateSurface(surface, params);
689 } 695 }
690 } 696 }
691 697
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
index 4e1e18d9c..39fcf22b4 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
@@ -9,6 +9,7 @@
9#include <memory> 9#include <memory>
10#include <vector> 10#include <vector>
11#include <boost/icl/interval_map.hpp> 11#include <boost/icl/interval_map.hpp>
12
12#include "common/common_types.h" 13#include "common/common_types.h"
13#include "common/math_util.h" 14#include "common/math_util.h"
14#include "video_core/engines/maxwell_3d.h" 15#include "video_core/engines/maxwell_3d.h"
@@ -546,6 +547,12 @@ struct SurfaceParams {
546 return !operator==(other); 547 return !operator==(other);
547 } 548 }
548 549
550 /// Checks if surfaces are compatible for caching
551 bool IsCompatibleSurface(const SurfaceParams& other) const {
552 return std::tie(pixel_format, type, cache_width, cache_height) ==
553 std::tie(other.pixel_format, other.type, other.cache_width, other.cache_height);
554 }
555
549 Tegra::GPUVAddr addr; 556 Tegra::GPUVAddr addr;
550 bool is_tiled; 557 bool is_tiled;
551 u32 block_height; 558 u32 block_height;
@@ -556,6 +563,10 @@ struct SurfaceParams {
556 u32 height; 563 u32 height;
557 u32 unaligned_height; 564 u32 unaligned_height;
558 size_t size_in_bytes; 565 size_t size_in_bytes;
566
567 // Parameters used for caching only
568 u32 cache_width;
569 u32 cache_height;
559}; 570};
560 571
561class CachedSurface final { 572class CachedSurface final {