diff --git a/src/common/range_sets.h b/src/common/range_sets.h index f4ee00fec7..f8fcee4837 100644 --- a/src/common/range_sets.h +++ b/src/common/range_sets.h @@ -38,16 +38,16 @@ private: }; template -class SplitRangeSet { +class OverlapRangeSet { public: - SplitRangeSet(); - ~SplitRangeSet(); + OverlapRangeSet(); + ~OverlapRangeSet(); - SplitRangeSet(SplitRangeSet const&) = delete; - SplitRangeSet& operator=(SplitRangeSet const&) = delete; + OverlapRangeSet(OverlapRangeSet const&) = delete; + OverlapRangeSet& operator=(OverlapRangeSet const&) = delete; - SplitRangeSet(SplitRangeSet&& other); - SplitRangeSet& operator=(SplitRangeSet&& other); + OverlapRangeSet(OverlapRangeSet&& other); + OverlapRangeSet& operator=(OverlapRangeSet&& other); void Add(AddressType base_address, size_t size); void Subtract(AddressType base_address, size_t size); @@ -66,8 +66,8 @@ public: void ForEachInRange(AddressType device_addr, size_t size, Func&& func) const; private: - struct SplitRangeSetImpl; - std::unique_ptr m_impl; + struct OverlapRangeSetImpl; + std::unique_ptr m_impl; }; -} // namespace Common \ No newline at end of file +} // namespace Common diff --git a/src/common/range_sets.inc b/src/common/range_sets.inc index 705ebd4a18..b83eceb7b0 100644 --- a/src/common/range_sets.inc +++ b/src/common/range_sets.inc @@ -19,14 +19,18 @@ namespace Common { +namespace { +template +using RangeSetsAllocator = + boost::fast_pool_allocator; +} + template struct RangeSet::RangeSetImpl { - template - using MyAllocator = boost::fast_pool_allocator; using IntervalSet = boost::icl::interval_set< AddressType, std::less, ICL_INTERVAL_INSTANCE(ICL_INTERVAL_DEFAULT, AddressType, std::less), - MyAllocator>; + RangeSetsAllocator>; using IntervalType = typename IntervalSet::interval_type; RangeSetImpl() = default; @@ -88,18 +92,15 @@ struct RangeSet::RangeSetImpl { }; template -struct SplitRangeSet::SplitRangeSetImpl { - template - using MyAllocator = boost::fast_pool_allocator; +struct OverlapRangeSet::OverlapRangeSetImpl { using IntervalSet = boost::icl::split_interval_map< AddressType, s32, boost::icl::partial_enricher, std::less, boost::icl::inplace_plus, boost::icl::inter_section, - ICL_INTERVAL_INSTANCE(ICL_INTERVAL_DEFAULT, AddressType, std::less), MyAllocator>; + ICL_INTERVAL_INSTANCE(ICL_INTERVAL_DEFAULT, AddressType, std::less), RangeSetsAllocator>; using IntervalType = typename IntervalSet::interval_type; - SplitRangeSetImpl() = default; - ~SplitRangeSetImpl() = default; + OverlapRangeSetImpl() = default; + ~OverlapRangeSetImpl() = default; void Add(AddressType base_address, size_t size) { AddressType end_address = base_address + static_cast(size); @@ -160,7 +161,7 @@ struct SplitRangeSet::SplitRangeSetImpl { } const AddressType start_address = base_address; const AddressType end_address = start_address + size; - const SplitRangeSetImpl::IntervalType search_interval{start_address, end_address}; + const OverlapRangeSetImpl::IntervalType search_interval{start_address, end_address}; auto it = m_split_ranges_set.lower_bound(search_interval); if (it == m_split_ranges_set.end()) { return; @@ -230,72 +231,74 @@ void RangeSet::ForEach(Func&& func) const { template template -void RangeSet::ForEachInRange(AddressType base_address, size_t size, Func&& func) const { +void RangeSet::ForEachInRange(AddressType base_address, size_t size, + Func&& func) const { m_impl->ForEachInRange(base_address, size, std::move(func)); } template -SplitRangeSet::SplitRangeSet() { - m_impl = std::make_unique::SplitRangeSetImpl>(); +OverlapRangeSet::OverlapRangeSet() { + m_impl = std::make_unique::OverlapRangeSetImpl>(); } template -SplitRangeSet::~SplitRangeSet() = default; +OverlapRangeSet::~OverlapRangeSet() = default; template -SplitRangeSet::SplitRangeSet(SplitRangeSet&& other) { - m_impl = std::make_unique::SplitRangeSetImpl>(); +OverlapRangeSet::OverlapRangeSet(OverlapRangeSet&& other) { + m_impl = std::make_unique::OverlapRangeSetImpl>(); m_impl->m_split_ranges_set = std::move(other.m_impl->m_split_ranges_set); } template -SplitRangeSet& SplitRangeSet::operator=(SplitRangeSet&& other) { +OverlapRangeSet& OverlapRangeSet::operator=(OverlapRangeSet&& other) { m_impl->m_split_ranges_set = std::move(other.m_impl->m_split_ranges_set); } template -void SplitRangeSet::Add(AddressType base_address, size_t size) { +void OverlapRangeSet::Add(AddressType base_address, size_t size) { m_impl->Add(base_address, size); } template -void SplitRangeSet::Subtract(AddressType base_address, size_t size) { +void OverlapRangeSet::Subtract(AddressType base_address, size_t size) { m_impl->template Subtract(base_address, size, 1, [](AddressType, AddressType) {}); } template template -void SplitRangeSet::Subtract(AddressType base_address, size_t size, Func&& on_delete) { +void OverlapRangeSet::Subtract(AddressType base_address, size_t size, + Func&& on_delete) { m_impl->template Subtract(base_address, size, 1, std::move(on_delete)); } template -void SplitRangeSet::DeleteAll(AddressType base_address, size_t size) { +void OverlapRangeSet::DeleteAll(AddressType base_address, size_t size) { m_impl->template Subtract(base_address, size, std::numeric_limits::max(), - [](AddressType, AddressType) {}); + [](AddressType, AddressType) {}); } template -void SplitRangeSet::Clear() { +void OverlapRangeSet::Clear() { m_impl->m_split_ranges_set.clear(); } template -bool SplitRangeSet::Empty() const { +bool OverlapRangeSet::Empty() const { return m_impl->m_split_ranges_set.empty(); } template template -void SplitRangeSet::ForEach(Func&& func) const { +void OverlapRangeSet::ForEach(Func&& func) const { m_impl->ForEach(func); } template template -void SplitRangeSet::ForEachInRange(AddressType base_address, size_t size, - Func&& func) const { +void OverlapRangeSet::ForEachInRange(AddressType base_address, size_t size, + Func&& func) const { m_impl->ForEachInRange(base_address, size, std::move(func)); } -} // namespace Common \ No newline at end of file +} // 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 542125a1c5..af17e3e85c 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 { ~HeapMapperInternal() = default; Common::RangeSet m_temporary_set; - Common::SplitRangeSet m_mapped_ranges; + Common::OverlapRangeSet m_mapped_ranges; Tegra::MaxwellDeviceMemoryManager& m_device_memory; std::mutex m_guard; }; diff --git a/src/video_core/buffer_cache/buffer_cache_base.h b/src/video_core/buffer_cache/buffer_cache_base.h index 4485166518..240e9f0150 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: std::deque> committed_gpu_modified_ranges; // Async Buffers - Common::SplitRangeSet async_downloads; + Common::OverlapRangeSet async_downloads; std::deque> async_buffers; std::deque> pending_downloads; std::optional current_buffer;