summaryrefslogtreecommitdiff
path: root/src/common/range_sets.inc
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2024-02-05 12:46:49 +0100
committerGravatar Fernando Sahmkow2024-02-05 23:01:17 +0100
commitfa47ac1c9f8b117d556c7c18ac9dcb062af5cefc (patch)
treee39eeaccfaa2c404f5c585b71606a421268254d0 /src/common/range_sets.inc
parentBuffer Cache: Refactor to use Range sets instead (diff)
downloadyuzu-fa47ac1c9f8b117d556c7c18ac9dcb062af5cefc.tar.gz
yuzu-fa47ac1c9f8b117d556c7c18ac9dcb062af5cefc.tar.xz
yuzu-fa47ac1c9f8b117d556c7c18ac9dcb062af5cefc.zip
Common: Rename SplitRangeSet to OverlapRangeSet
Diffstat (limited to '')
-rw-r--r--src/common/range_sets.inc63
1 files changed, 33 insertions, 30 deletions
diff --git a/src/common/range_sets.inc b/src/common/range_sets.inc
index 705ebd4a1..b83eceb7b 100644
--- a/src/common/range_sets.inc
+++ b/src/common/range_sets.inc
@@ -19,14 +19,18 @@
19 19
20namespace Common { 20namespace Common {
21 21
22namespace {
23template <class T>
24using RangeSetsAllocator =
25 boost::fast_pool_allocator<T, boost::default_user_allocator_new_delete,
26 boost::details::pool::default_mutex, 1024, 2048>;
27}
28
22template <typename AddressType> 29template <typename AddressType>
23struct RangeSet<AddressType>::RangeSetImpl { 30struct RangeSet<AddressType>::RangeSetImpl {
24 template <class T>
25 using MyAllocator = boost::fast_pool_allocator<T, boost::default_user_allocator_new_delete,
26 boost::details::pool::default_mutex, 1024, 2048>;
27 using IntervalSet = boost::icl::interval_set< 31 using IntervalSet = boost::icl::interval_set<
28 AddressType, std::less, ICL_INTERVAL_INSTANCE(ICL_INTERVAL_DEFAULT, AddressType, std::less), 32 AddressType, std::less, ICL_INTERVAL_INSTANCE(ICL_INTERVAL_DEFAULT, AddressType, std::less),
29 MyAllocator>; 33 RangeSetsAllocator>;
30 using IntervalType = typename IntervalSet::interval_type; 34 using IntervalType = typename IntervalSet::interval_type;
31 35
32 RangeSetImpl() = default; 36 RangeSetImpl() = default;
@@ -88,18 +92,15 @@ struct RangeSet<AddressType>::RangeSetImpl {
88}; 92};
89 93
90template <typename AddressType> 94template <typename AddressType>
91struct SplitRangeSet<AddressType>::SplitRangeSetImpl { 95struct OverlapRangeSet<AddressType>::OverlapRangeSetImpl {
92 template <class T>
93 using MyAllocator = boost::fast_pool_allocator<T, boost::default_user_allocator_new_delete,
94 boost::details::pool::default_mutex, 1024, 2048>;
95 using IntervalSet = boost::icl::split_interval_map< 96 using IntervalSet = boost::icl::split_interval_map<
96 AddressType, s32, boost::icl::partial_enricher, std::less, boost::icl::inplace_plus, 97 AddressType, s32, boost::icl::partial_enricher, std::less, boost::icl::inplace_plus,
97 boost::icl::inter_section, 98 boost::icl::inter_section,
98 ICL_INTERVAL_INSTANCE(ICL_INTERVAL_DEFAULT, AddressType, std::less), MyAllocator>; 99 ICL_INTERVAL_INSTANCE(ICL_INTERVAL_DEFAULT, AddressType, std::less), RangeSetsAllocator>;
99 using IntervalType = typename IntervalSet::interval_type; 100 using IntervalType = typename IntervalSet::interval_type;
100 101
101 SplitRangeSetImpl() = default; 102 OverlapRangeSetImpl() = default;
102 ~SplitRangeSetImpl() = default; 103 ~OverlapRangeSetImpl() = default;
103 104
104 void Add(AddressType base_address, size_t size) { 105 void Add(AddressType base_address, size_t size) {
105 AddressType end_address = base_address + static_cast<AddressType>(size); 106 AddressType end_address = base_address + static_cast<AddressType>(size);
@@ -160,7 +161,7 @@ struct SplitRangeSet<AddressType>::SplitRangeSetImpl {
160 } 161 }
161 const AddressType start_address = base_address; 162 const AddressType start_address = base_address;
162 const AddressType end_address = start_address + size; 163 const AddressType end_address = start_address + size;
163 const SplitRangeSetImpl::IntervalType search_interval{start_address, end_address}; 164 const OverlapRangeSetImpl::IntervalType search_interval{start_address, end_address};
164 auto it = m_split_ranges_set.lower_bound(search_interval); 165 auto it = m_split_ranges_set.lower_bound(search_interval);
165 if (it == m_split_ranges_set.end()) { 166 if (it == m_split_ranges_set.end()) {
166 return; 167 return;
@@ -230,72 +231,74 @@ void RangeSet<AddressType>::ForEach(Func&& func) const {
230 231
231template <typename AddressType> 232template <typename AddressType>
232template <typename Func> 233template <typename Func>
233void RangeSet<AddressType>::ForEachInRange(AddressType base_address, size_t size, Func&& func) const { 234void RangeSet<AddressType>::ForEachInRange(AddressType base_address, size_t size,
235 Func&& func) const {
234 m_impl->ForEachInRange(base_address, size, std::move(func)); 236 m_impl->ForEachInRange(base_address, size, std::move(func));
235} 237}
236 238
237template <typename AddressType> 239template <typename AddressType>
238SplitRangeSet<AddressType>::SplitRangeSet() { 240OverlapRangeSet<AddressType>::OverlapRangeSet() {
239 m_impl = std::make_unique<SplitRangeSet<AddressType>::SplitRangeSetImpl>(); 241 m_impl = std::make_unique<OverlapRangeSet<AddressType>::OverlapRangeSetImpl>();
240} 242}
241 243
242template <typename AddressType> 244template <typename AddressType>
243SplitRangeSet<AddressType>::~SplitRangeSet() = default; 245OverlapRangeSet<AddressType>::~OverlapRangeSet() = default;
244 246
245template <typename AddressType> 247template <typename AddressType>
246SplitRangeSet<AddressType>::SplitRangeSet(SplitRangeSet&& other) { 248OverlapRangeSet<AddressType>::OverlapRangeSet(OverlapRangeSet&& other) {
247 m_impl = std::make_unique<SplitRangeSet<AddressType>::SplitRangeSetImpl>(); 249 m_impl = std::make_unique<OverlapRangeSet<AddressType>::OverlapRangeSetImpl>();
248 m_impl->m_split_ranges_set = std::move(other.m_impl->m_split_ranges_set); 250 m_impl->m_split_ranges_set = std::move(other.m_impl->m_split_ranges_set);
249} 251}
250 252
251template <typename AddressType> 253template <typename AddressType>
252SplitRangeSet<AddressType>& SplitRangeSet<AddressType>::operator=(SplitRangeSet&& other) { 254OverlapRangeSet<AddressType>& OverlapRangeSet<AddressType>::operator=(OverlapRangeSet&& other) {
253 m_impl->m_split_ranges_set = std::move(other.m_impl->m_split_ranges_set); 255 m_impl->m_split_ranges_set = std::move(other.m_impl->m_split_ranges_set);
254} 256}
255 257
256template <typename AddressType> 258template <typename AddressType>
257void SplitRangeSet<AddressType>::Add(AddressType base_address, size_t size) { 259void OverlapRangeSet<AddressType>::Add(AddressType base_address, size_t size) {
258 m_impl->Add(base_address, size); 260 m_impl->Add(base_address, size);
259} 261}
260 262
261template <typename AddressType> 263template <typename AddressType>
262void SplitRangeSet<AddressType>::Subtract(AddressType base_address, size_t size) { 264void OverlapRangeSet<AddressType>::Subtract(AddressType base_address, size_t size) {
263 m_impl->template Subtract<false>(base_address, size, 1, [](AddressType, AddressType) {}); 265 m_impl->template Subtract<false>(base_address, size, 1, [](AddressType, AddressType) {});
264} 266}
265 267
266template <typename AddressType> 268template <typename AddressType>
267template <typename Func> 269template <typename Func>
268void SplitRangeSet<AddressType>::Subtract(AddressType base_address, size_t size, Func&& on_delete) { 270void OverlapRangeSet<AddressType>::Subtract(AddressType base_address, size_t size,
271 Func&& on_delete) {
269 m_impl->template Subtract<true, Func>(base_address, size, 1, std::move(on_delete)); 272 m_impl->template Subtract<true, Func>(base_address, size, 1, std::move(on_delete));
270} 273}
271 274
272template <typename AddressType> 275template <typename AddressType>
273void SplitRangeSet<AddressType>::DeleteAll(AddressType base_address, size_t size) { 276void OverlapRangeSet<AddressType>::DeleteAll(AddressType base_address, size_t size) {
274 m_impl->template Subtract<false>(base_address, size, std::numeric_limits<s32>::max(), 277 m_impl->template Subtract<false>(base_address, size, std::numeric_limits<s32>::max(),
275 [](AddressType, AddressType) {}); 278 [](AddressType, AddressType) {});
276} 279}
277 280
278template <typename AddressType> 281template <typename AddressType>
279void SplitRangeSet<AddressType>::Clear() { 282void OverlapRangeSet<AddressType>::Clear() {
280 m_impl->m_split_ranges_set.clear(); 283 m_impl->m_split_ranges_set.clear();
281} 284}
282 285
283template <typename AddressType> 286template <typename AddressType>
284bool SplitRangeSet<AddressType>::Empty() const { 287bool OverlapRangeSet<AddressType>::Empty() const {
285 return m_impl->m_split_ranges_set.empty(); 288 return m_impl->m_split_ranges_set.empty();
286} 289}
287 290
288template <typename AddressType> 291template <typename AddressType>
289template <typename Func> 292template <typename Func>
290void SplitRangeSet<AddressType>::ForEach(Func&& func) const { 293void OverlapRangeSet<AddressType>::ForEach(Func&& func) const {
291 m_impl->ForEach(func); 294 m_impl->ForEach(func);
292} 295}
293 296
294template <typename AddressType> 297template <typename AddressType>
295template <typename Func> 298template <typename Func>
296void SplitRangeSet<AddressType>::ForEachInRange(AddressType base_address, size_t size, 299void OverlapRangeSet<AddressType>::ForEachInRange(AddressType base_address, size_t size,
297 Func&& func) const { 300 Func&& func) const {
298 m_impl->ForEachInRange(base_address, size, std::move(func)); 301 m_impl->ForEachInRange(base_address, size, std::move(func));
299} 302}
300 303
301} // namespace Common \ No newline at end of file 304} // namespace Common