buffer_cache.h 22 KB

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