summaryrefslogtreecommitdiff
path: root/src/video_core/rasterizer_cache.h
diff options
context:
space:
mode:
authorGravatar Lioncash2018-11-08 06:08:00 -0500
committerGravatar Lioncash2018-11-08 06:16:38 -0500
commit9046f764bfb0097b827c585514f284124a61effd (patch)
tree4c287a55151114f70b2104e4df1e90af1d52073f /src/video_core/rasterizer_cache.h
parentgl_resource_manager: Amend clang-format discrepancies (diff)
downloadyuzu-9046f764bfb0097b827c585514f284124a61effd.tar.gz
yuzu-9046f764bfb0097b827c585514f284124a61effd.tar.xz
yuzu-9046f764bfb0097b827c585514f284124a61effd.zip
rasterizer_cache: Remove reliance on the System singleton
Rather than have a transparent dependency, we can make it explicit in the interface. This also gets rid of the need to put the core include in a header.
Diffstat (limited to 'src/video_core/rasterizer_cache.h')
-rw-r--r--src/video_core/rasterizer_cache.h7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/video_core/rasterizer_cache.h b/src/video_core/rasterizer_cache.h
index 0a3b3951e..81918feb3 100644
--- a/src/video_core/rasterizer_cache.h
+++ b/src/video_core/rasterizer_cache.h
@@ -10,10 +10,8 @@
10#include <boost/range/iterator_range_core.hpp> 10#include <boost/range/iterator_range_core.hpp>
11 11
12#include "common/common_types.h" 12#include "common/common_types.h"
13#include "core/core.h"
14#include "core/settings.h" 13#include "core/settings.h"
15#include "video_core/rasterizer_interface.h" 14#include "video_core/rasterizer_interface.h"
16#include "video_core/renderer_base.h"
17 15
18class RasterizerCacheObject { 16class RasterizerCacheObject {
19public: 17public:
@@ -64,6 +62,8 @@ class RasterizerCache : NonCopyable {
64 friend class RasterizerCacheObject; 62 friend class RasterizerCacheObject;
65 63
66public: 64public:
65 explicit RasterizerCache(VideoCore::RasterizerInterface& rasterizer) : rasterizer{rasterizer} {}
66
67 /// Write any cached resources overlapping the specified region back to memory 67 /// Write any cached resources overlapping the specified region back to memory
68 void FlushRegion(Tegra::GPUVAddr addr, size_t size) { 68 void FlushRegion(Tegra::GPUVAddr addr, size_t size) {
69 const auto& objects{GetSortedObjectsFromRegion(addr, size)}; 69 const auto& objects{GetSortedObjectsFromRegion(addr, size)};
@@ -109,14 +109,12 @@ protected:
109 void Register(const T& object) { 109 void Register(const T& object) {
110 object->SetIsRegistered(true); 110 object->SetIsRegistered(true);
111 object_cache.add({GetInterval(object), ObjectSet{object}}); 111 object_cache.add({GetInterval(object), ObjectSet{object}});
112 auto& rasterizer = Core::System::GetInstance().Renderer().Rasterizer();
113 rasterizer.UpdatePagesCachedCount(object->GetAddr(), object->GetSizeInBytes(), 1); 112 rasterizer.UpdatePagesCachedCount(object->GetAddr(), object->GetSizeInBytes(), 1);
114 } 113 }
115 114
116 /// Unregisters an object from the cache 115 /// Unregisters an object from the cache
117 void Unregister(const T& object) { 116 void Unregister(const T& object) {
118 object->SetIsRegistered(false); 117 object->SetIsRegistered(false);
119 auto& rasterizer = Core::System::GetInstance().Renderer().Rasterizer();
120 rasterizer.UpdatePagesCachedCount(object->GetAddr(), object->GetSizeInBytes(), -1); 118 rasterizer.UpdatePagesCachedCount(object->GetAddr(), object->GetSizeInBytes(), -1);
121 119
122 // Only flush if use_accurate_gpu_emulation is enabled, as it incurs a performance hit 120 // Only flush if use_accurate_gpu_emulation is enabled, as it incurs a performance hit
@@ -177,4 +175,5 @@ private:
177 175
178 ObjectCache object_cache; ///< Cache of objects 176 ObjectCache object_cache; ///< Cache of objects
179 u64 modified_ticks{}; ///< Counter of cache state ticks, used for in-order flushing 177 u64 modified_ticks{}; ///< Counter of cache state ticks, used for in-order flushing
178 VideoCore::RasterizerInterface& rasterizer;
180}; 179};