buffer_cache.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  1. // Copyright 2019 yuzu Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <list>
  6. #include <memory>
  7. #include <mutex>
  8. #include <unordered_map>
  9. #include <unordered_set>
  10. #include <utility>
  11. #include <vector>
  12. #include <boost/container/small_vector.hpp>
  13. #include <boost/icl/interval_set.hpp>
  14. #include <boost/intrusive/set.hpp>
  15. #include "common/alignment.h"
  16. #include "common/assert.h"
  17. #include "common/common_types.h"
  18. #include "common/logging/log.h"
  19. #include "core/core.h"
  20. #include "core/memory.h"
  21. #include "core/settings.h"
  22. #include "video_core/buffer_cache/buffer_block.h"
  23. #include "video_core/buffer_cache/map_interval.h"
  24. #include "video_core/memory_manager.h"
  25. #include "video_core/rasterizer_interface.h"
  26. namespace VideoCommon {
  27. template <typename OwnerBuffer, typename BufferType, typename StreamBuffer>
  28. class BufferCache {
  29. using IntervalSet = boost::icl::interval_set<VAddr>;
  30. using IntervalType = typename IntervalSet::interval_type;
  31. using VectorMapInterval = boost::container::small_vector<MapInterval*, 1>;
  32. public:
  33. using BufferInfo = std::pair<BufferType, u64>;
  34. BufferInfo UploadMemory(GPUVAddr gpu_addr, std::size_t size, std::size_t alignment = 4,
  35. bool is_written = false, bool use_fast_cbuf = false) {
  36. std::lock_guard lock{mutex};
  37. const auto& memory_manager = system.GPU().MemoryManager();
  38. const std::optional<VAddr> cpu_addr_opt = memory_manager.GpuToCpuAddress(gpu_addr);
  39. if (!cpu_addr_opt) {
  40. return {GetEmptyBuffer(size), 0};
  41. }
  42. const VAddr cpu_addr = *cpu_addr_opt;
  43. // Cache management is a big overhead, so only cache entries with a given size.
  44. // TODO: Figure out which size is the best for given games.
  45. constexpr std::size_t max_stream_size = 0x800;
  46. if (use_fast_cbuf || size < max_stream_size) {
  47. if (!is_written && !IsRegionWritten(cpu_addr, cpu_addr + size - 1)) {
  48. auto& memory_manager = system.GPU().MemoryManager();
  49. if (use_fast_cbuf) {
  50. if (memory_manager.IsGranularRange(gpu_addr, size)) {
  51. const auto host_ptr = memory_manager.GetPointer(gpu_addr);
  52. return ConstBufferUpload(host_ptr, size);
  53. } else {
  54. staging_buffer.resize(size);
  55. memory_manager.ReadBlockUnsafe(gpu_addr, staging_buffer.data(), size);
  56. return ConstBufferUpload(staging_buffer.data(), size);
  57. }
  58. } else {
  59. if (memory_manager.IsGranularRange(gpu_addr, size)) {
  60. const auto host_ptr = memory_manager.GetPointer(gpu_addr);
  61. return StreamBufferUpload(host_ptr, size, alignment);
  62. } else {
  63. staging_buffer.resize(size);
  64. memory_manager.ReadBlockUnsafe(gpu_addr, staging_buffer.data(), size);
  65. return StreamBufferUpload(staging_buffer.data(), size, alignment);
  66. }
  67. }
  68. }
  69. }
  70. OwnerBuffer block = GetBlock(cpu_addr, size);
  71. MapInterval* const map = MapAddress(block, gpu_addr, cpu_addr, size);
  72. if (!map) {
  73. return {GetEmptyBuffer(size), 0};
  74. }
  75. if (is_written) {
  76. map->MarkAsModified(true, GetModifiedTicks());
  77. if (Settings::IsGPULevelHigh() && Settings::values.use_asynchronous_gpu_emulation) {
  78. MarkForAsyncFlush(map);
  79. }
  80. if (!map->is_written) {
  81. map->is_written = true;
  82. MarkRegionAsWritten(map->start, map->end - 1);
  83. }
  84. }
  85. return {ToHandle(block), static_cast<u64>(block->GetOffset(cpu_addr))};
  86. }
  87. /// Uploads from a host memory. Returns the OpenGL buffer where it's located and its offset.
  88. BufferInfo UploadHostMemory(const void* raw_pointer, std::size_t size,
  89. std::size_t alignment = 4) {
  90. std::lock_guard lock{mutex};
  91. return StreamBufferUpload(raw_pointer, size, alignment);
  92. }
  93. void Map(std::size_t max_size) {
  94. std::lock_guard lock{mutex};
  95. std::tie(buffer_ptr, buffer_offset_base, invalidated) = stream_buffer->Map(max_size, 4);
  96. buffer_offset = buffer_offset_base;
  97. }
  98. /// Finishes the upload stream, returns true on bindings invalidation.
  99. bool Unmap() {
  100. std::lock_guard lock{mutex};
  101. stream_buffer->Unmap(buffer_offset - buffer_offset_base);
  102. return std::exchange(invalidated, false);
  103. }
  104. void TickFrame() {
  105. ++epoch;
  106. while (!pending_destruction.empty()) {
  107. // Delay at least 4 frames before destruction.
  108. // This is due to triple buffering happening on some drivers.
  109. static constexpr u64 epochs_to_destroy = 5;
  110. if (pending_destruction.front()->GetEpoch() + epochs_to_destroy > epoch) {
  111. break;
  112. }
  113. pending_destruction.pop_front();
  114. }
  115. }
  116. /// Write any cached resources overlapping the specified region back to memory
  117. void FlushRegion(VAddr addr, std::size_t size) {
  118. std::lock_guard lock{mutex};
  119. VectorMapInterval objects = GetMapsInRange(addr, size);
  120. std::sort(objects.begin(), objects.end(),
  121. [](MapInterval* lhs, MapInterval* rhs) { return lhs->ticks < rhs->ticks; });
  122. for (MapInterval* object : objects) {
  123. if (object->is_modified && object->is_registered) {
  124. mutex.unlock();
  125. FlushMap(object);
  126. mutex.lock();
  127. }
  128. }
  129. }
  130. bool MustFlushRegion(VAddr addr, std::size_t size) {
  131. std::lock_guard lock{mutex};
  132. const VectorMapInterval objects = GetMapsInRange(addr, size);
  133. return std::any_of(objects.cbegin(), objects.cend(), [](const MapInterval* map) {
  134. return map->is_modified && map->is_registered;
  135. });
  136. }
  137. /// Mark the specified region as being invalidated
  138. void InvalidateRegion(VAddr addr, u64 size) {
  139. std::lock_guard lock{mutex};
  140. for (auto& object : GetMapsInRange(addr, size)) {
  141. if (object->is_registered) {
  142. Unregister(object);
  143. }
  144. }
  145. }
  146. void OnCPUWrite(VAddr addr, std::size_t size) {
  147. std::lock_guard lock{mutex};
  148. for (MapInterval* object : GetMapsInRange(addr, size)) {
  149. if (object->is_memory_marked && object->is_registered) {
  150. UnmarkMemory(object);
  151. object->is_sync_pending = true;
  152. marked_for_unregister.emplace_back(object);
  153. }
  154. }
  155. }
  156. void SyncGuestHost() {
  157. std::lock_guard lock{mutex};
  158. for (auto& object : marked_for_unregister) {
  159. if (object->is_registered) {
  160. object->is_sync_pending = false;
  161. Unregister(object);
  162. }
  163. }
  164. marked_for_unregister.clear();
  165. }
  166. void CommitAsyncFlushes() {
  167. if (uncommitted_flushes) {
  168. auto commit_list = std::make_shared<std::list<MapInterval*>>();
  169. for (MapInterval* map : *uncommitted_flushes) {
  170. if (map->is_registered && map->is_modified) {
  171. // TODO(Blinkhawk): Implement backend asynchronous flushing
  172. // AsyncFlushMap(map)
  173. commit_list->push_back(map);
  174. }
  175. }
  176. if (!commit_list->empty()) {
  177. committed_flushes.push_back(commit_list);
  178. } else {
  179. committed_flushes.emplace_back();
  180. }
  181. } else {
  182. committed_flushes.emplace_back();
  183. }
  184. uncommitted_flushes.reset();
  185. }
  186. bool ShouldWaitAsyncFlushes() const {
  187. return !committed_flushes.empty() && committed_flushes.front() != nullptr;
  188. }
  189. bool HasUncommittedFlushes() const {
  190. return uncommitted_flushes != nullptr;
  191. }
  192. void PopAsyncFlushes() {
  193. if (committed_flushes.empty()) {
  194. return;
  195. }
  196. auto& flush_list = committed_flushes.front();
  197. if (!flush_list) {
  198. committed_flushes.pop_front();
  199. return;
  200. }
  201. for (MapInterval* map : *flush_list) {
  202. if (map->is_registered) {
  203. // TODO(Blinkhawk): Replace this for reading the asynchronous flush
  204. FlushMap(map);
  205. }
  206. }
  207. committed_flushes.pop_front();
  208. }
  209. virtual BufferType GetEmptyBuffer(std::size_t size) = 0;
  210. protected:
  211. explicit BufferCache(VideoCore::RasterizerInterface& rasterizer, Core::System& system,
  212. std::unique_ptr<StreamBuffer> stream_buffer)
  213. : rasterizer{rasterizer}, system{system}, stream_buffer{std::move(stream_buffer)},
  214. stream_buffer_handle{this->stream_buffer->GetHandle()} {}
  215. ~BufferCache() = default;
  216. virtual BufferType ToHandle(const OwnerBuffer& storage) = 0;
  217. virtual OwnerBuffer CreateBlock(VAddr cpu_addr, std::size_t size) = 0;
  218. virtual void UploadBlockData(const OwnerBuffer& buffer, std::size_t offset, std::size_t size,
  219. const u8* data) = 0;
  220. virtual void DownloadBlockData(const OwnerBuffer& buffer, std::size_t offset, std::size_t size,
  221. u8* data) = 0;
  222. virtual void CopyBlock(const OwnerBuffer& src, const OwnerBuffer& dst, std::size_t src_offset,
  223. std::size_t dst_offset, std::size_t size) = 0;
  224. virtual BufferInfo ConstBufferUpload(const void* raw_pointer, std::size_t size) {
  225. return {};
  226. }
  227. /// Register an object into the cache
  228. MapInterval* Register(MapInterval new_map, bool inherit_written = false) {
  229. const VAddr cpu_addr = new_map.start;
  230. if (!cpu_addr) {
  231. LOG_CRITICAL(HW_GPU, "Failed to register buffer with unmapped gpu_address 0x{:016x}",
  232. new_map.gpu_addr);
  233. return nullptr;
  234. }
  235. const std::size_t size = new_map.end - new_map.start;
  236. new_map.is_registered = true;
  237. rasterizer.UpdatePagesCachedCount(cpu_addr, size, 1);
  238. new_map.is_memory_marked = true;
  239. if (inherit_written) {
  240. MarkRegionAsWritten(new_map.start, new_map.end - 1);
  241. new_map.is_written = true;
  242. }
  243. MapInterval* const storage = mapped_addresses_allocator.Allocate();
  244. *storage = new_map;
  245. mapped_addresses.insert(*storage);
  246. return storage;
  247. }
  248. void UnmarkMemory(MapInterval* map) {
  249. if (!map->is_memory_marked) {
  250. return;
  251. }
  252. const std::size_t size = map->end - map->start;
  253. rasterizer.UpdatePagesCachedCount(map->start, size, -1);
  254. map->is_memory_marked = false;
  255. }
  256. /// Unregisters an object from the cache
  257. void Unregister(MapInterval* map) {
  258. UnmarkMemory(map);
  259. map->is_registered = false;
  260. if (map->is_sync_pending) {
  261. map->is_sync_pending = false;
  262. marked_for_unregister.remove(map);
  263. }
  264. if (map->is_written) {
  265. UnmarkRegionAsWritten(map->start, map->end - 1);
  266. }
  267. const auto it = mapped_addresses.find(*map);
  268. ASSERT(it != mapped_addresses.end());
  269. mapped_addresses.erase(it);
  270. mapped_addresses_allocator.Release(map);
  271. }
  272. private:
  273. MapInterval* MapAddress(const OwnerBuffer& block, GPUVAddr gpu_addr, VAddr cpu_addr,
  274. std::size_t size) {
  275. const VectorMapInterval overlaps = GetMapsInRange(cpu_addr, size);
  276. if (overlaps.empty()) {
  277. auto& memory_manager = system.GPU().MemoryManager();
  278. const VAddr cpu_addr_end = cpu_addr + size;
  279. if (memory_manager.IsGranularRange(gpu_addr, size)) {
  280. u8* host_ptr = memory_manager.GetPointer(gpu_addr);
  281. UploadBlockData(block, block->GetOffset(cpu_addr), size, host_ptr);
  282. } else {
  283. staging_buffer.resize(size);
  284. memory_manager.ReadBlockUnsafe(gpu_addr, staging_buffer.data(), size);
  285. UploadBlockData(block, block->GetOffset(cpu_addr), size, staging_buffer.data());
  286. }
  287. return Register(MapInterval(cpu_addr, cpu_addr_end, gpu_addr));
  288. }
  289. const VAddr cpu_addr_end = cpu_addr + size;
  290. if (overlaps.size() == 1) {
  291. MapInterval* const current_map = overlaps[0];
  292. if (current_map->IsInside(cpu_addr, cpu_addr_end)) {
  293. return current_map;
  294. }
  295. }
  296. VAddr new_start = cpu_addr;
  297. VAddr new_end = cpu_addr_end;
  298. bool write_inheritance = false;
  299. bool modified_inheritance = false;
  300. // Calculate new buffer parameters
  301. for (MapInterval* overlap : overlaps) {
  302. new_start = std::min(overlap->start, new_start);
  303. new_end = std::max(overlap->end, new_end);
  304. write_inheritance |= overlap->is_written;
  305. modified_inheritance |= overlap->is_modified;
  306. }
  307. GPUVAddr new_gpu_addr = gpu_addr + new_start - cpu_addr;
  308. for (auto& overlap : overlaps) {
  309. Unregister(overlap);
  310. }
  311. UpdateBlock(block, new_start, new_end, overlaps);
  312. const MapInterval new_map{new_start, new_end, new_gpu_addr};
  313. MapInterval* const map = Register(new_map, write_inheritance);
  314. if (!map) {
  315. return nullptr;
  316. }
  317. if (modified_inheritance) {
  318. map->MarkAsModified(true, GetModifiedTicks());
  319. if (Settings::IsGPULevelHigh() && Settings::values.use_asynchronous_gpu_emulation) {
  320. MarkForAsyncFlush(map);
  321. }
  322. }
  323. return map;
  324. }
  325. void UpdateBlock(const OwnerBuffer& block, VAddr start, VAddr end,
  326. const VectorMapInterval& overlaps) {
  327. const IntervalType base_interval{start, end};
  328. IntervalSet interval_set{};
  329. interval_set.add(base_interval);
  330. for (auto& overlap : overlaps) {
  331. const IntervalType subtract{overlap->start, overlap->end};
  332. interval_set.subtract(subtract);
  333. }
  334. for (auto& interval : interval_set) {
  335. std::size_t size = interval.upper() - interval.lower();
  336. if (size > 0) {
  337. staging_buffer.resize(size);
  338. system.Memory().ReadBlockUnsafe(interval.lower(), staging_buffer.data(), size);
  339. UploadBlockData(block, block->GetOffset(interval.lower()), size,
  340. staging_buffer.data());
  341. }
  342. }
  343. }
  344. VectorMapInterval GetMapsInRange(VAddr addr, std::size_t size) {
  345. VectorMapInterval result;
  346. if (size == 0) {
  347. return result;
  348. }
  349. const VAddr addr_end = addr + size;
  350. auto it = mapped_addresses.lower_bound(addr);
  351. if (it != mapped_addresses.begin()) {
  352. --it;
  353. }
  354. while (it != mapped_addresses.end() && it->start < addr_end) {
  355. if (it->Overlaps(addr, addr_end)) {
  356. result.push_back(&*it);
  357. }
  358. ++it;
  359. }
  360. return result;
  361. }
  362. /// Returns a ticks counter used for tracking when cached objects were last modified
  363. u64 GetModifiedTicks() {
  364. return ++modified_ticks;
  365. }
  366. void FlushMap(MapInterval* map) {
  367. const std::size_t size = map->end - map->start;
  368. OwnerBuffer block = blocks[map->start >> block_page_bits];
  369. staging_buffer.resize(size);
  370. DownloadBlockData(block, block->GetOffset(map->start), size, staging_buffer.data());
  371. system.Memory().WriteBlockUnsafe(map->start, staging_buffer.data(), size);
  372. map->MarkAsModified(false, 0);
  373. }
  374. BufferInfo StreamBufferUpload(const void* raw_pointer, std::size_t size,
  375. std::size_t alignment) {
  376. AlignBuffer(alignment);
  377. const std::size_t uploaded_offset = buffer_offset;
  378. std::memcpy(buffer_ptr, raw_pointer, size);
  379. buffer_ptr += size;
  380. buffer_offset += size;
  381. return {stream_buffer_handle, uploaded_offset};
  382. }
  383. void AlignBuffer(std::size_t alignment) {
  384. // Align the offset, not the mapped pointer
  385. const std::size_t offset_aligned = Common::AlignUp(buffer_offset, alignment);
  386. buffer_ptr += offset_aligned - buffer_offset;
  387. buffer_offset = offset_aligned;
  388. }
  389. OwnerBuffer EnlargeBlock(OwnerBuffer buffer) {
  390. const std::size_t old_size = buffer->GetSize();
  391. const std::size_t new_size = old_size + block_page_size;
  392. const VAddr cpu_addr = buffer->GetCpuAddr();
  393. OwnerBuffer new_buffer = CreateBlock(cpu_addr, new_size);
  394. CopyBlock(buffer, new_buffer, 0, 0, old_size);
  395. buffer->SetEpoch(epoch);
  396. pending_destruction.push_back(buffer);
  397. const VAddr cpu_addr_end = cpu_addr + new_size - 1;
  398. u64 page_start = cpu_addr >> block_page_bits;
  399. const u64 page_end = cpu_addr_end >> block_page_bits;
  400. while (page_start <= page_end) {
  401. blocks[page_start] = new_buffer;
  402. ++page_start;
  403. }
  404. return new_buffer;
  405. }
  406. OwnerBuffer MergeBlocks(OwnerBuffer first, OwnerBuffer second) {
  407. const std::size_t size_1 = first->GetSize();
  408. const std::size_t size_2 = second->GetSize();
  409. const VAddr first_addr = first->GetCpuAddr();
  410. const VAddr second_addr = second->GetCpuAddr();
  411. const VAddr new_addr = std::min(first_addr, second_addr);
  412. const std::size_t new_size = size_1 + size_2;
  413. OwnerBuffer new_buffer = CreateBlock(new_addr, new_size);
  414. CopyBlock(first, new_buffer, 0, new_buffer->GetOffset(first_addr), size_1);
  415. CopyBlock(second, new_buffer, 0, new_buffer->GetOffset(second_addr), size_2);
  416. first->SetEpoch(epoch);
  417. second->SetEpoch(epoch);
  418. pending_destruction.push_back(first);
  419. pending_destruction.push_back(second);
  420. const VAddr cpu_addr_end = new_addr + new_size - 1;
  421. u64 page_start = new_addr >> block_page_bits;
  422. const u64 page_end = cpu_addr_end >> block_page_bits;
  423. while (page_start <= page_end) {
  424. blocks[page_start] = new_buffer;
  425. ++page_start;
  426. }
  427. return new_buffer;
  428. }
  429. OwnerBuffer GetBlock(const VAddr cpu_addr, const std::size_t size) {
  430. OwnerBuffer found;
  431. const VAddr cpu_addr_end = cpu_addr + size - 1;
  432. u64 page_start = cpu_addr >> block_page_bits;
  433. const u64 page_end = cpu_addr_end >> block_page_bits;
  434. while (page_start <= page_end) {
  435. auto it = blocks.find(page_start);
  436. if (it == blocks.end()) {
  437. if (found) {
  438. found = EnlargeBlock(found);
  439. } else {
  440. const VAddr start_addr = (page_start << block_page_bits);
  441. found = CreateBlock(start_addr, block_page_size);
  442. blocks[page_start] = found;
  443. }
  444. } else {
  445. if (found) {
  446. if (found == it->second) {
  447. ++page_start;
  448. continue;
  449. }
  450. found = MergeBlocks(found, it->second);
  451. } else {
  452. found = it->second;
  453. }
  454. }
  455. ++page_start;
  456. }
  457. return found;
  458. }
  459. void MarkRegionAsWritten(const VAddr start, const VAddr end) {
  460. u64 page_start = start >> write_page_bit;
  461. const u64 page_end = end >> write_page_bit;
  462. while (page_start <= page_end) {
  463. auto it = written_pages.find(page_start);
  464. if (it != written_pages.end()) {
  465. it->second = it->second + 1;
  466. } else {
  467. written_pages[page_start] = 1;
  468. }
  469. ++page_start;
  470. }
  471. }
  472. void UnmarkRegionAsWritten(const VAddr start, const VAddr end) {
  473. u64 page_start = start >> write_page_bit;
  474. const u64 page_end = end >> write_page_bit;
  475. while (page_start <= page_end) {
  476. auto it = written_pages.find(page_start);
  477. if (it != written_pages.end()) {
  478. if (it->second > 1) {
  479. it->second = it->second - 1;
  480. } else {
  481. written_pages.erase(it);
  482. }
  483. }
  484. ++page_start;
  485. }
  486. }
  487. bool IsRegionWritten(const VAddr start, const VAddr end) const {
  488. u64 page_start = start >> write_page_bit;
  489. const u64 page_end = end >> write_page_bit;
  490. while (page_start <= page_end) {
  491. if (written_pages.count(page_start) > 0) {
  492. return true;
  493. }
  494. ++page_start;
  495. }
  496. return false;
  497. }
  498. void MarkForAsyncFlush(MapInterval* map) {
  499. if (!uncommitted_flushes) {
  500. uncommitted_flushes = std::make_shared<std::unordered_set<MapInterval*>>();
  501. }
  502. uncommitted_flushes->insert(map);
  503. }
  504. VideoCore::RasterizerInterface& rasterizer;
  505. Core::System& system;
  506. std::unique_ptr<StreamBuffer> stream_buffer;
  507. BufferType stream_buffer_handle{};
  508. bool invalidated = false;
  509. u8* buffer_ptr = nullptr;
  510. u64 buffer_offset = 0;
  511. u64 buffer_offset_base = 0;
  512. MapIntervalAllocator mapped_addresses_allocator;
  513. boost::intrusive::set<MapInterval, boost::intrusive::compare<MapIntervalCompare>>
  514. mapped_addresses;
  515. static constexpr u64 write_page_bit = 11;
  516. std::unordered_map<u64, u32> written_pages;
  517. static constexpr u64 block_page_bits = 21;
  518. static constexpr u64 block_page_size = 1ULL << block_page_bits;
  519. std::unordered_map<u64, OwnerBuffer> blocks;
  520. std::list<OwnerBuffer> pending_destruction;
  521. u64 epoch = 0;
  522. u64 modified_ticks = 0;
  523. std::vector<u8> staging_buffer;
  524. std::list<MapInterval*> marked_for_unregister;
  525. std::shared_ptr<std::unordered_set<MapInterval*>> uncommitted_flushes;
  526. std::list<std::shared_ptr<std::list<MapInterval*>>> committed_flushes;
  527. std::recursive_mutex mutex;
  528. };
  529. } // namespace VideoCommon