diff options
| author | 2020-02-19 10:49:07 -0400 | |
|---|---|---|
| committer | 2020-04-22 11:36:15 -0400 | |
| commit | 96bb961a6485c2f5c8b7fb91aa0dd7eb24fa5e5d (patch) | |
| tree | 3f6730c2e37f083a5b0cb1632cb810873ec71e5e | |
| parent | FenceManager: Implement async buffer cache flushes on High settings (diff) | |
| download | yuzu-96bb961a6485c2f5c8b7fb91aa0dd7eb24fa5e5d.tar.gz yuzu-96bb961a6485c2f5c8b7fb91aa0dd7eb24fa5e5d.tar.xz yuzu-96bb961a6485c2f5c8b7fb91aa0dd7eb24fa5e5d.zip | |
BufferCache: Refactor async managing.
| -rw-r--r-- | src/video_core/buffer_cache/buffer_cache.h | 31 | ||||
| -rw-r--r-- | src/video_core/fence_manager.h | 6 |
2 files changed, 27 insertions, 10 deletions
diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h index d72df90ef..06fb931d7 100644 --- a/src/video_core/buffer_cache/buffer_cache.h +++ b/src/video_core/buffer_cache/buffer_cache.h | |||
| @@ -82,7 +82,7 @@ public: | |||
| 82 | if (is_written) { | 82 | if (is_written) { |
| 83 | map->MarkAsModified(true, GetModifiedTicks()); | 83 | map->MarkAsModified(true, GetModifiedTicks()); |
| 84 | if (Settings::IsGPULevelHigh() && Settings::values.use_asynchronous_gpu_emulation) { | 84 | if (Settings::IsGPULevelHigh() && Settings::values.use_asynchronous_gpu_emulation) { |
| 85 | AsyncFlushMap(map); | 85 | MarkForAsyncFlush(map); |
| 86 | } | 86 | } |
| 87 | if (!map->IsWritten()) { | 87 | if (!map->IsWritten()) { |
| 88 | map->MarkAsWritten(true); | 88 | map->MarkAsWritten(true); |
| @@ -198,7 +198,23 @@ public: | |||
| 198 | } | 198 | } |
| 199 | 199 | ||
| 200 | void CommitAsyncFlushes() { | 200 | void CommitAsyncFlushes() { |
| 201 | commited_flushes.push_back(uncommited_flushes); | 201 | if (uncommited_flushes) { |
| 202 | auto commit_list = std::make_shared<std::list<MapInterval>>(); | ||
| 203 | for (auto& map : *uncommited_flushes) { | ||
| 204 | if (map->IsRegistered() && map->IsModified()) { | ||
| 205 | // TODO(Blinkhawk): Implement backend asynchronous flushing | ||
| 206 | // AsyncFlushMap(map) | ||
| 207 | commit_list->push_back(map); | ||
| 208 | } | ||
| 209 | } | ||
| 210 | if (!commit_list->empty()) { | ||
| 211 | commited_flushes.push_back(commit_list); | ||
| 212 | } else { | ||
| 213 | commited_flushes.emplace_back(); | ||
| 214 | } | ||
| 215 | } else { | ||
| 216 | commited_flushes.emplace_back(); | ||
| 217 | } | ||
| 202 | uncommited_flushes.reset(); | 218 | uncommited_flushes.reset(); |
| 203 | } | 219 | } |
| 204 | 220 | ||
| @@ -224,6 +240,7 @@ public: | |||
| 224 | } | 240 | } |
| 225 | for (MapInterval& map : *flush_list) { | 241 | for (MapInterval& map : *flush_list) { |
| 226 | if (map->IsRegistered()) { | 242 | if (map->IsRegistered()) { |
| 243 | // TODO(Blinkhawk): Replace this for reading the asynchronous flush | ||
| 227 | FlushMap(map); | 244 | FlushMap(map); |
| 228 | } | 245 | } |
| 229 | } | 246 | } |
| @@ -354,7 +371,7 @@ private: | |||
| 354 | if (modified_inheritance) { | 371 | if (modified_inheritance) { |
| 355 | new_map->MarkAsModified(true, GetModifiedTicks()); | 372 | new_map->MarkAsModified(true, GetModifiedTicks()); |
| 356 | if (Settings::IsGPULevelHigh() && Settings::values.use_asynchronous_gpu_emulation) { | 373 | if (Settings::IsGPULevelHigh() && Settings::values.use_asynchronous_gpu_emulation) { |
| 357 | AsyncFlushMap(new_map); | 374 | MarkForAsyncFlush(new_map); |
| 358 | } | 375 | } |
| 359 | } | 376 | } |
| 360 | Register(new_map, write_inheritance); | 377 | Register(new_map, write_inheritance); |
| @@ -542,11 +559,11 @@ private: | |||
| 542 | return false; | 559 | return false; |
| 543 | } | 560 | } |
| 544 | 561 | ||
| 545 | void AsyncFlushMap(MapInterval& map) { | 562 | void MarkForAsyncFlush(MapInterval& map) { |
| 546 | if (!uncommited_flushes) { | 563 | if (!uncommited_flushes) { |
| 547 | uncommited_flushes = std::make_shared<std::list<MapInterval>>(); | 564 | uncommited_flushes = std::make_shared<std::unordered_set<MapInterval>>(); |
| 548 | } | 565 | } |
| 549 | uncommited_flushes->push_back(map); | 566 | uncommited_flushes->insert(map); |
| 550 | } | 567 | } |
| 551 | 568 | ||
| 552 | VideoCore::RasterizerInterface& rasterizer; | 569 | VideoCore::RasterizerInterface& rasterizer; |
| @@ -580,7 +597,7 @@ private: | |||
| 580 | std::vector<u8> staging_buffer; | 597 | std::vector<u8> staging_buffer; |
| 581 | std::list<MapInterval> marked_for_unregister; | 598 | std::list<MapInterval> marked_for_unregister; |
| 582 | 599 | ||
| 583 | std::shared_ptr<std::list<MapInterval>> uncommited_flushes{}; | 600 | std::shared_ptr<std::unordered_set<MapInterval>> uncommited_flushes{}; |
| 584 | std::list<std::shared_ptr<std::list<MapInterval>>> commited_flushes; | 601 | std::list<std::shared_ptr<std::list<MapInterval>>> commited_flushes; |
| 585 | 602 | ||
| 586 | std::recursive_mutex mutex; | 603 | std::recursive_mutex mutex; |
diff --git a/src/video_core/fence_manager.h b/src/video_core/fence_manager.h index c4b190503..72ee50955 100644 --- a/src/video_core/fence_manager.h +++ b/src/video_core/fence_manager.h | |||
| @@ -42,11 +42,11 @@ class FenceManager { | |||
| 42 | public: | 42 | public: |
| 43 | void SignalFence(GPUVAddr addr, u32 value) { | 43 | void SignalFence(GPUVAddr addr, u32 value) { |
| 44 | TryReleasePendingFences(); | 44 | TryReleasePendingFences(); |
| 45 | TFence new_fence = CreateFence(addr, value); | ||
| 46 | QueueFence(new_fence); | ||
| 47 | fences.push(new_fence); | ||
| 48 | texture_cache.CommitAsyncFlushes(); | 45 | texture_cache.CommitAsyncFlushes(); |
| 49 | buffer_cache.CommitAsyncFlushes(); | 46 | buffer_cache.CommitAsyncFlushes(); |
| 47 | TFence new_fence = CreateFence(addr, value); | ||
| 48 | fences.push(new_fence); | ||
| 49 | QueueFence(new_fence); | ||
| 50 | rasterizer.FlushCommands(); | 50 | rasterizer.FlushCommands(); |
| 51 | rasterizer.SyncGuestHost(); | 51 | rasterizer.SyncGuestHost(); |
| 52 | } | 52 | } |