summaryrefslogtreecommitdiffstats
path: root/src/video_core/buffer_cache/map_interval.cpp
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2020-05-21 06:06:40 +0200
committerReinUsesLisp <reinuseslisp@airmail.cc>2020-05-21 21:44:00 +0200
commita2dcc642c1737721bafe54605c7826fa08d18f47 (patch)
tree655b96d46815d93259b12dccc8acad293437db41 /src/video_core/buffer_cache/map_interval.cpp
parentbuffer_cache: Use boost::container::small_vector for maps in range (diff)
downloadyuzu-a2dcc642c1737721bafe54605c7826fa08d18f47.tar
yuzu-a2dcc642c1737721bafe54605c7826fa08d18f47.tar.gz
yuzu-a2dcc642c1737721bafe54605c7826fa08d18f47.tar.bz2
yuzu-a2dcc642c1737721bafe54605c7826fa08d18f47.tar.lz
yuzu-a2dcc642c1737721bafe54605c7826fa08d18f47.tar.xz
yuzu-a2dcc642c1737721bafe54605c7826fa08d18f47.tar.zst
yuzu-a2dcc642c1737721bafe54605c7826fa08d18f47.zip
Diffstat (limited to 'src/video_core/buffer_cache/map_interval.cpp')
-rw-r--r--src/video_core/buffer_cache/map_interval.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/video_core/buffer_cache/map_interval.cpp b/src/video_core/buffer_cache/map_interval.cpp
new file mode 100644
index 000000000..62587e18a
--- /dev/null
+++ b/src/video_core/buffer_cache/map_interval.cpp
@@ -0,0 +1,33 @@
+// Copyright 2020 yuzu Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#include <algorithm>
+#include <array>
+#include <cstddef>
+#include <memory>
+
+#include "video_core/buffer_cache/map_interval.h"
+
+namespace VideoCommon {
+
+MapIntervalAllocator::MapIntervalAllocator() {
+ FillFreeList(first_chunk);
+}
+
+MapIntervalAllocator::~MapIntervalAllocator() = default;
+
+void MapIntervalAllocator::AllocateNewChunk() {
+ *new_chunk = std::make_unique<Chunk>();
+ FillFreeList(**new_chunk);
+ new_chunk = &(*new_chunk)->next;
+}
+
+void MapIntervalAllocator::FillFreeList(Chunk& chunk) {
+ const std::size_t old_size = free_list.size();
+ free_list.resize(old_size + chunk.data.size());
+ std::transform(chunk.data.rbegin(), chunk.data.rend(), free_list.begin() + old_size,
+ [](MapInterval& interval) { return &interval; });
+}
+
+} // namespace VideoCommon