summaryrefslogtreecommitdiff
path: root/src/video_core/buffer_cache
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2020-04-16 12:29:53 -0400
committerGravatar Fernando Sahmkow2020-04-22 11:36:24 -0400
commitf616dc0b591b783b3fb75ca89633f1c26cce05a9 (patch)
tree43a9c2052c5ceaad8cf6a69173b0817e54cc8f42 /src/video_core/buffer_cache
parentFix GCC error. (diff)
downloadyuzu-f616dc0b591b783b3fb75ca89633f1c26cce05a9.tar.gz
yuzu-f616dc0b591b783b3fb75ca89633f1c26cce05a9.tar.xz
yuzu-f616dc0b591b783b3fb75ca89633f1c26cce05a9.zip
Address Feedback.
Diffstat (limited to 'src/video_core/buffer_cache')
-rw-r--r--src/video_core/buffer_cache/buffer_cache.h56
1 files changed, 23 insertions, 33 deletions
diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h
index 372545080..f3aa35295 100644
--- a/src/video_core/buffer_cache/buffer_cache.h
+++ b/src/video_core/buffer_cache/buffer_cache.h
@@ -154,12 +154,9 @@ public:
154 std::lock_guard lock{mutex}; 154 std::lock_guard lock{mutex};
155 155
156 std::vector<MapInterval> objects = GetMapsInRange(addr, size); 156 std::vector<MapInterval> objects = GetMapsInRange(addr, size);
157 for (auto& object : objects) { 157 return std::any_of(objects.begin(), objects.end(), [](const MapInterval& map) {
158 if (object->IsModified() && object->IsRegistered()) { 158 return map->IsModified() && map->IsRegistered();
159 return true; 159 });
160 }
161 }
162 return false;
163 } 160 }
164 161
165 /// Mark the specified region as being invalidated 162 /// Mark the specified region as being invalidated
@@ -199,9 +196,9 @@ public:
199 } 196 }
200 197
201 void CommitAsyncFlushes() { 198 void CommitAsyncFlushes() {
202 if (uncommited_flushes) { 199 if (uncommitted_flushes) {
203 auto commit_list = std::make_shared<std::list<MapInterval>>(); 200 auto commit_list = std::make_shared<std::list<MapInterval>>();
204 for (auto& map : *uncommited_flushes) { 201 for (auto& map : *uncommitted_flushes) {
205 if (map->IsRegistered() && map->IsModified()) { 202 if (map->IsRegistered() && map->IsModified()) {
206 // TODO(Blinkhawk): Implement backend asynchronous flushing 203 // TODO(Blinkhawk): Implement backend asynchronous flushing
207 // AsyncFlushMap(map) 204 // AsyncFlushMap(map)
@@ -209,41 +206,34 @@ public:
209 } 206 }
210 } 207 }
211 if (!commit_list->empty()) { 208 if (!commit_list->empty()) {
212 commited_flushes.push_back(commit_list); 209 committed_flushes.push_back(commit_list);
213 } else { 210 } else {
214 commited_flushes.emplace_back(); 211 committed_flushes.emplace_back();
215 } 212 }
216 } else { 213 } else {
217 commited_flushes.emplace_back(); 214 committed_flushes.emplace_back();
218 } 215 }
219 uncommited_flushes.reset(); 216 uncommitted_flushes.reset();
220 } 217 }
221 218
222 bool ShouldWaitAsyncFlushes() { 219 bool ShouldWaitAsyncFlushes() const {
223 if (commited_flushes.empty()) { 220 if (committed_flushes.empty()) {
224 return false;
225 }
226 auto& flush_list = commited_flushes.front();
227 if (!flush_list) {
228 return false; 221 return false;
229 } 222 }
230 return true; 223 return committed_flushes.front() != nullptr;
231 } 224 }
232 225
233 bool HasUncommitedFlushes() { 226 bool HasUncommittedFlushes() const {
234 if (uncommited_flushes) { 227 return uncommitted_flushes != nullptr;
235 return true;
236 }
237 return false;
238 } 228 }
239 229
240 void PopAsyncFlushes() { 230 void PopAsyncFlushes() {
241 if (commited_flushes.empty()) { 231 if (committed_flushes.empty()) {
242 return; 232 return;
243 } 233 }
244 auto& flush_list = commited_flushes.front(); 234 auto& flush_list = committed_flushes.front();
245 if (!flush_list) { 235 if (!flush_list) {
246 commited_flushes.pop_front(); 236 committed_flushes.pop_front();
247 return; 237 return;
248 } 238 }
249 for (MapInterval& map : *flush_list) { 239 for (MapInterval& map : *flush_list) {
@@ -252,7 +242,7 @@ public:
252 FlushMap(map); 242 FlushMap(map);
253 } 243 }
254 } 244 }
255 commited_flushes.pop_front(); 245 committed_flushes.pop_front();
256 } 246 }
257 247
258 virtual BufferType GetEmptyBuffer(std::size_t size) = 0; 248 virtual BufferType GetEmptyBuffer(std::size_t size) = 0;
@@ -568,10 +558,10 @@ private:
568 } 558 }
569 559
570 void MarkForAsyncFlush(MapInterval& map) { 560 void MarkForAsyncFlush(MapInterval& map) {
571 if (!uncommited_flushes) { 561 if (!uncommitted_flushes) {
572 uncommited_flushes = std::make_shared<std::unordered_set<MapInterval>>(); 562 uncommitted_flushes = std::make_shared<std::unordered_set<MapInterval>>();
573 } 563 }
574 uncommited_flushes->insert(map); 564 uncommitted_flushes->insert(map);
575 } 565 }
576 566
577 VideoCore::RasterizerInterface& rasterizer; 567 VideoCore::RasterizerInterface& rasterizer;
@@ -605,8 +595,8 @@ private:
605 std::vector<u8> staging_buffer; 595 std::vector<u8> staging_buffer;
606 std::list<MapInterval> marked_for_unregister; 596 std::list<MapInterval> marked_for_unregister;
607 597
608 std::shared_ptr<std::unordered_set<MapInterval>> uncommited_flushes{}; 598 std::shared_ptr<std::unordered_set<MapInterval>> uncommitted_flushes{};
609 std::list<std::shared_ptr<std::list<MapInterval>>> commited_flushes; 599 std::list<std::shared_ptr<std::list<MapInterval>>> committed_flushes;
610 600
611 std::recursive_mutex mutex; 601 std::recursive_mutex mutex;
612}; 602};