summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common/range_sets.h20
-rw-r--r--src/common/range_sets.inc63
-rw-r--r--src/core/hle/service/nvdrv/core/heap_mapper.cpp2
-rw-r--r--src/video_core/buffer_cache/buffer_cache_base.h2
4 files changed, 45 insertions, 42 deletions
diff --git a/src/common/range_sets.h b/src/common/range_sets.h
index f4ee00fec..f8fcee483 100644
--- a/src/common/range_sets.h
+++ b/src/common/range_sets.h
@@ -38,16 +38,16 @@ private:
38}; 38};
39 39
40template <typename AddressType> 40template <typename AddressType>
41class SplitRangeSet { 41class OverlapRangeSet {
42public: 42public:
43 SplitRangeSet(); 43 OverlapRangeSet();
44 ~SplitRangeSet(); 44 ~OverlapRangeSet();
45 45
46 SplitRangeSet(SplitRangeSet const&) = delete; 46 OverlapRangeSet(OverlapRangeSet const&) = delete;
47 SplitRangeSet& operator=(SplitRangeSet const&) = delete; 47 OverlapRangeSet& operator=(OverlapRangeSet const&) = delete;
48 48
49 SplitRangeSet(SplitRangeSet&& other); 49 OverlapRangeSet(OverlapRangeSet&& other);
50 SplitRangeSet& operator=(SplitRangeSet&& other); 50 OverlapRangeSet& operator=(OverlapRangeSet&& other);
51 51
52 void Add(AddressType base_address, size_t size); 52 void Add(AddressType base_address, size_t size);
53 void Subtract(AddressType base_address, size_t size); 53 void Subtract(AddressType base_address, size_t size);
@@ -66,8 +66,8 @@ public:
66 void ForEachInRange(AddressType device_addr, size_t size, Func&& func) const; 66 void ForEachInRange(AddressType device_addr, size_t size, Func&& func) const;
67 67
68private: 68private:
69 struct SplitRangeSetImpl; 69 struct OverlapRangeSetImpl;
70 std::unique_ptr<SplitRangeSetImpl> m_impl; 70 std::unique_ptr<OverlapRangeSetImpl> m_impl;
71}; 71};
72 72
73} // namespace Common \ No newline at end of file 73} // namespace Common
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
diff --git a/src/core/hle/service/nvdrv/core/heap_mapper.cpp b/src/core/hle/service/nvdrv/core/heap_mapper.cpp
index 542125a1c..af17e3e85 100644
--- a/src/core/hle/service/nvdrv/core/heap_mapper.cpp
+++ b/src/core/hle/service/nvdrv/core/heap_mapper.cpp
@@ -15,7 +15,7 @@ struct HeapMapper::HeapMapperInternal {
15 ~HeapMapperInternal() = default; 15 ~HeapMapperInternal() = default;
16 16
17 Common::RangeSet<VAddr> m_temporary_set; 17 Common::RangeSet<VAddr> m_temporary_set;
18 Common::SplitRangeSet<VAddr> m_mapped_ranges; 18 Common::OverlapRangeSet<VAddr> m_mapped_ranges;
19 Tegra::MaxwellDeviceMemoryManager& m_device_memory; 19 Tegra::MaxwellDeviceMemoryManager& m_device_memory;
20 std::mutex m_guard; 20 std::mutex m_guard;
21}; 21};
diff --git a/src/video_core/buffer_cache/buffer_cache_base.h b/src/video_core/buffer_cache/buffer_cache_base.h
index 448516651..240e9f015 100644
--- a/src/video_core/buffer_cache/buffer_cache_base.h
+++ b/src/video_core/buffer_cache/buffer_cache_base.h
@@ -460,7 +460,7 @@ private:
460 std::deque<Common::RangeSet<DAddr>> committed_gpu_modified_ranges; 460 std::deque<Common::RangeSet<DAddr>> committed_gpu_modified_ranges;
461 461
462 // Async Buffers 462 // Async Buffers
463 Common::SplitRangeSet<DAddr> async_downloads; 463 Common::OverlapRangeSet<DAddr> async_downloads;
464 std::deque<std::optional<Async_Buffer>> async_buffers; 464 std::deque<std::optional<Async_Buffer>> async_buffers;
465 std::deque<boost::container::small_vector<BufferCopy, 4>> pending_downloads; 465 std::deque<boost::container::small_vector<BufferCopy, 4>> pending_downloads;
466 std::optional<Async_Buffer> current_buffer; 466 std::optional<Async_Buffer> current_buffer;