diff options
| author | 2024-02-05 12:46:49 +0100 | |
|---|---|---|
| committer | 2024-02-05 23:01:17 +0100 | |
| commit | fa47ac1c9f8b117d556c7c18ac9dcb062af5cefc (patch) | |
| tree | e39eeaccfaa2c404f5c585b71606a421268254d0 | |
| parent | Buffer Cache: Refactor to use Range sets instead (diff) | |
| download | yuzu-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.h | 20 | ||||
| -rw-r--r-- | src/common/range_sets.inc | 63 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/core/heap_mapper.cpp | 2 | ||||
| -rw-r--r-- | src/video_core/buffer_cache/buffer_cache_base.h | 2 |
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 | ||
| 40 | template <typename AddressType> | 40 | template <typename AddressType> |
| 41 | class SplitRangeSet { | 41 | class OverlapRangeSet { |
| 42 | public: | 42 | public: |
| 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 | ||
| 68 | private: | 68 | private: |
| 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 | ||
| 20 | namespace Common { | 20 | namespace Common { |
| 21 | 21 | ||
| 22 | namespace { | ||
| 23 | template <class T> | ||
| 24 | using RangeSetsAllocator = | ||
| 25 | boost::fast_pool_allocator<T, boost::default_user_allocator_new_delete, | ||
| 26 | boost::details::pool::default_mutex, 1024, 2048>; | ||
| 27 | } | ||
| 28 | |||
| 22 | template <typename AddressType> | 29 | template <typename AddressType> |
| 23 | struct RangeSet<AddressType>::RangeSetImpl { | 30 | struct 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 | ||
| 90 | template <typename AddressType> | 94 | template <typename AddressType> |
| 91 | struct SplitRangeSet<AddressType>::SplitRangeSetImpl { | 95 | struct 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 | ||
| 231 | template <typename AddressType> | 232 | template <typename AddressType> |
| 232 | template <typename Func> | 233 | template <typename Func> |
| 233 | void RangeSet<AddressType>::ForEachInRange(AddressType base_address, size_t size, Func&& func) const { | 234 | void 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 | ||
| 237 | template <typename AddressType> | 239 | template <typename AddressType> |
| 238 | SplitRangeSet<AddressType>::SplitRangeSet() { | 240 | OverlapRangeSet<AddressType>::OverlapRangeSet() { |
| 239 | m_impl = std::make_unique<SplitRangeSet<AddressType>::SplitRangeSetImpl>(); | 241 | m_impl = std::make_unique<OverlapRangeSet<AddressType>::OverlapRangeSetImpl>(); |
| 240 | } | 242 | } |
| 241 | 243 | ||
| 242 | template <typename AddressType> | 244 | template <typename AddressType> |
| 243 | SplitRangeSet<AddressType>::~SplitRangeSet() = default; | 245 | OverlapRangeSet<AddressType>::~OverlapRangeSet() = default; |
| 244 | 246 | ||
| 245 | template <typename AddressType> | 247 | template <typename AddressType> |
| 246 | SplitRangeSet<AddressType>::SplitRangeSet(SplitRangeSet&& other) { | 248 | OverlapRangeSet<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 | ||
| 251 | template <typename AddressType> | 253 | template <typename AddressType> |
| 252 | SplitRangeSet<AddressType>& SplitRangeSet<AddressType>::operator=(SplitRangeSet&& other) { | 254 | OverlapRangeSet<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 | ||
| 256 | template <typename AddressType> | 258 | template <typename AddressType> |
| 257 | void SplitRangeSet<AddressType>::Add(AddressType base_address, size_t size) { | 259 | void 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 | ||
| 261 | template <typename AddressType> | 263 | template <typename AddressType> |
| 262 | void SplitRangeSet<AddressType>::Subtract(AddressType base_address, size_t size) { | 264 | void 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 | ||
| 266 | template <typename AddressType> | 268 | template <typename AddressType> |
| 267 | template <typename Func> | 269 | template <typename Func> |
| 268 | void SplitRangeSet<AddressType>::Subtract(AddressType base_address, size_t size, Func&& on_delete) { | 270 | void 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 | ||
| 272 | template <typename AddressType> | 275 | template <typename AddressType> |
| 273 | void SplitRangeSet<AddressType>::DeleteAll(AddressType base_address, size_t size) { | 276 | void 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 | ||
| 278 | template <typename AddressType> | 281 | template <typename AddressType> |
| 279 | void SplitRangeSet<AddressType>::Clear() { | 282 | void OverlapRangeSet<AddressType>::Clear() { |
| 280 | m_impl->m_split_ranges_set.clear(); | 283 | m_impl->m_split_ranges_set.clear(); |
| 281 | } | 284 | } |
| 282 | 285 | ||
| 283 | template <typename AddressType> | 286 | template <typename AddressType> |
| 284 | bool SplitRangeSet<AddressType>::Empty() const { | 287 | bool 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 | ||
| 288 | template <typename AddressType> | 291 | template <typename AddressType> |
| 289 | template <typename Func> | 292 | template <typename Func> |
| 290 | void SplitRangeSet<AddressType>::ForEach(Func&& func) const { | 293 | void OverlapRangeSet<AddressType>::ForEach(Func&& func) const { |
| 291 | m_impl->ForEach(func); | 294 | m_impl->ForEach(func); |
| 292 | } | 295 | } |
| 293 | 296 | ||
| 294 | template <typename AddressType> | 297 | template <typename AddressType> |
| 295 | template <typename Func> | 298 | template <typename Func> |
| 296 | void SplitRangeSet<AddressType>::ForEachInRange(AddressType base_address, size_t size, | 299 | void 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; |