diff options
Diffstat (limited to 'src/video_core/buffer_cache')
| -rw-r--r-- | src/video_core/buffer_cache/buffer_cache.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h index df4c0211e..d72df90ef 100644 --- a/src/video_core/buffer_cache/buffer_cache.h +++ b/src/video_core/buffer_cache/buffer_cache.h | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | #include "common/common_types.h" | 21 | #include "common/common_types.h" |
| 22 | #include "core/core.h" | 22 | #include "core/core.h" |
| 23 | #include "core/memory.h" | 23 | #include "core/memory.h" |
| 24 | #include "core/settings.h" | ||
| 24 | #include "video_core/buffer_cache/buffer_block.h" | 25 | #include "video_core/buffer_cache/buffer_block.h" |
| 25 | #include "video_core/buffer_cache/map_interval.h" | 26 | #include "video_core/buffer_cache/map_interval.h" |
| 26 | #include "video_core/memory_manager.h" | 27 | #include "video_core/memory_manager.h" |
| @@ -80,6 +81,9 @@ public: | |||
| 80 | auto map = MapAddress(block, gpu_addr, cpu_addr, size); | 81 | auto map = MapAddress(block, gpu_addr, cpu_addr, size); |
| 81 | if (is_written) { | 82 | if (is_written) { |
| 82 | map->MarkAsModified(true, GetModifiedTicks()); | 83 | map->MarkAsModified(true, GetModifiedTicks()); |
| 84 | if (Settings::IsGPULevelHigh() && Settings::values.use_asynchronous_gpu_emulation) { | ||
| 85 | AsyncFlushMap(map); | ||
| 86 | } | ||
| 83 | if (!map->IsWritten()) { | 87 | if (!map->IsWritten()) { |
| 84 | map->MarkAsWritten(true); | 88 | map->MarkAsWritten(true); |
| 85 | MarkRegionAsWritten(map->GetStart(), map->GetEnd() - 1); | 89 | MarkRegionAsWritten(map->GetStart(), map->GetEnd() - 1); |
| @@ -193,6 +197,39 @@ public: | |||
| 193 | marked_for_unregister.clear(); | 197 | marked_for_unregister.clear(); |
| 194 | } | 198 | } |
| 195 | 199 | ||
| 200 | void CommitAsyncFlushes() { | ||
| 201 | commited_flushes.push_back(uncommited_flushes); | ||
| 202 | uncommited_flushes.reset(); | ||
| 203 | } | ||
| 204 | |||
| 205 | bool ShouldWaitAsyncFlushes() { | ||
| 206 | if (commited_flushes.empty()) { | ||
| 207 | return false; | ||
| 208 | } | ||
| 209 | auto& flush_list = commited_flushes.front(); | ||
| 210 | if (!flush_list) { | ||
| 211 | return false; | ||
| 212 | } | ||
| 213 | return true; | ||
| 214 | } | ||
| 215 | |||
| 216 | void PopAsyncFlushes() { | ||
| 217 | if (commited_flushes.empty()) { | ||
| 218 | return; | ||
| 219 | } | ||
| 220 | auto& flush_list = commited_flushes.front(); | ||
| 221 | if (!flush_list) { | ||
| 222 | commited_flushes.pop_front(); | ||
| 223 | return; | ||
| 224 | } | ||
| 225 | for (MapInterval& map : *flush_list) { | ||
| 226 | if (map->IsRegistered()) { | ||
| 227 | FlushMap(map); | ||
| 228 | } | ||
| 229 | } | ||
| 230 | commited_flushes.pop_front(); | ||
| 231 | } | ||
| 232 | |||
| 196 | virtual BufferType GetEmptyBuffer(std::size_t size) = 0; | 233 | virtual BufferType GetEmptyBuffer(std::size_t size) = 0; |
| 197 | 234 | ||
| 198 | protected: | 235 | protected: |
| @@ -316,6 +353,9 @@ private: | |||
| 316 | MapInterval new_map = CreateMap(new_start, new_end, new_gpu_addr); | 353 | MapInterval new_map = CreateMap(new_start, new_end, new_gpu_addr); |
| 317 | if (modified_inheritance) { | 354 | if (modified_inheritance) { |
| 318 | new_map->MarkAsModified(true, GetModifiedTicks()); | 355 | new_map->MarkAsModified(true, GetModifiedTicks()); |
| 356 | if (Settings::IsGPULevelHigh() && Settings::values.use_asynchronous_gpu_emulation) { | ||
| 357 | AsyncFlushMap(new_map); | ||
| 358 | } | ||
| 319 | } | 359 | } |
| 320 | Register(new_map, write_inheritance); | 360 | Register(new_map, write_inheritance); |
| 321 | return new_map; | 361 | return new_map; |
| @@ -502,6 +542,13 @@ private: | |||
| 502 | return false; | 542 | return false; |
| 503 | } | 543 | } |
| 504 | 544 | ||
| 545 | void AsyncFlushMap(MapInterval& map) { | ||
| 546 | if (!uncommited_flushes) { | ||
| 547 | uncommited_flushes = std::make_shared<std::list<MapInterval>>(); | ||
| 548 | } | ||
| 549 | uncommited_flushes->push_back(map); | ||
| 550 | } | ||
| 551 | |||
| 505 | VideoCore::RasterizerInterface& rasterizer; | 552 | VideoCore::RasterizerInterface& rasterizer; |
| 506 | Core::System& system; | 553 | Core::System& system; |
| 507 | 554 | ||
| @@ -533,6 +580,9 @@ private: | |||
| 533 | std::vector<u8> staging_buffer; | 580 | std::vector<u8> staging_buffer; |
| 534 | std::list<MapInterval> marked_for_unregister; | 581 | std::list<MapInterval> marked_for_unregister; |
| 535 | 582 | ||
| 583 | std::shared_ptr<std::list<MapInterval>> uncommited_flushes{}; | ||
| 584 | std::list<std::shared_ptr<std::list<MapInterval>>> commited_flushes; | ||
| 585 | |||
| 536 | std::recursive_mutex mutex; | 586 | std::recursive_mutex mutex; |
| 537 | }; | 587 | }; |
| 538 | 588 | ||