2
1
Fork 0
mirror of https://github.com/yuzu-emu/yuzu.git synced 2024-07-04 23:31:19 +01:00

Common: Rename SplitRangeSet to OverlapRangeSet

This commit is contained in:
Fernando Sahmkow 2024-02-05 12:46:49 +01:00
parent 0d5a3abeae
commit fa47ac1c9f
4 changed files with 45 additions and 42 deletions

View file

@ -38,16 +38,16 @@ private:
}; };
template <typename AddressType> template <typename AddressType>
class SplitRangeSet { class OverlapRangeSet {
public: public:
SplitRangeSet(); OverlapRangeSet();
~SplitRangeSet(); ~OverlapRangeSet();
SplitRangeSet(SplitRangeSet const&) = delete; OverlapRangeSet(OverlapRangeSet const&) = delete;
SplitRangeSet& operator=(SplitRangeSet const&) = delete; OverlapRangeSet& operator=(OverlapRangeSet const&) = delete;
SplitRangeSet(SplitRangeSet&& other); OverlapRangeSet(OverlapRangeSet&& other);
SplitRangeSet& operator=(SplitRangeSet&& other); OverlapRangeSet& operator=(OverlapRangeSet&& other);
void Add(AddressType base_address, size_t size); void Add(AddressType base_address, size_t size);
void Subtract(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; void ForEachInRange(AddressType device_addr, size_t size, Func&& func) const;
private: private:
struct SplitRangeSetImpl; struct OverlapRangeSetImpl;
std::unique_ptr<SplitRangeSetImpl> m_impl; std::unique_ptr<OverlapRangeSetImpl> m_impl;
}; };
} // namespace Common } // namespace Common

View file

@ -19,14 +19,18 @@
namespace Common { namespace Common {
namespace {
template <class T>
using RangeSetsAllocator =
boost::fast_pool_allocator<T, boost::default_user_allocator_new_delete,
boost::details::pool::default_mutex, 1024, 2048>;
}
template <typename AddressType> template <typename AddressType>
struct RangeSet<AddressType>::RangeSetImpl { struct RangeSet<AddressType>::RangeSetImpl {
template <class T>
using MyAllocator = boost::fast_pool_allocator<T, boost::default_user_allocator_new_delete,
boost::details::pool::default_mutex, 1024, 2048>;
using IntervalSet = boost::icl::interval_set< using IntervalSet = boost::icl::interval_set<
AddressType, std::less, ICL_INTERVAL_INSTANCE(ICL_INTERVAL_DEFAULT, AddressType, std::less), AddressType, std::less, ICL_INTERVAL_INSTANCE(ICL_INTERVAL_DEFAULT, AddressType, std::less),
MyAllocator>; RangeSetsAllocator>;
using IntervalType = typename IntervalSet::interval_type; using IntervalType = typename IntervalSet::interval_type;
RangeSetImpl() = default; RangeSetImpl() = default;
@ -88,18 +92,15 @@ struct RangeSet<AddressType>::RangeSetImpl {
}; };
template <typename AddressType> template <typename AddressType>
struct SplitRangeSet<AddressType>::SplitRangeSetImpl { struct OverlapRangeSet<AddressType>::OverlapRangeSetImpl {
template <class T>
using MyAllocator = boost::fast_pool_allocator<T, boost::default_user_allocator_new_delete,
boost::details::pool::default_mutex, 1024, 2048>;
using IntervalSet = boost::icl::split_interval_map< using IntervalSet = boost::icl::split_interval_map<
AddressType, s32, boost::icl::partial_enricher, std::less, boost::icl::inplace_plus, AddressType, s32, boost::icl::partial_enricher, std::less, boost::icl::inplace_plus,
boost::icl::inter_section, 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; using IntervalType = typename IntervalSet::interval_type;
SplitRangeSetImpl() = default; OverlapRangeSetImpl() = default;
~SplitRangeSetImpl() = default; ~OverlapRangeSetImpl() = default;
void Add(AddressType base_address, size_t size) { void Add(AddressType base_address, size_t size) {
AddressType end_address = base_address + static_cast<AddressType>(size); AddressType end_address = base_address + static_cast<AddressType>(size);
@ -160,7 +161,7 @@ struct SplitRangeSet<AddressType>::SplitRangeSetImpl {
} }
const AddressType start_address = base_address; const AddressType start_address = base_address;
const AddressType end_address = start_address + size; 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); auto it = m_split_ranges_set.lower_bound(search_interval);
if (it == m_split_ranges_set.end()) { if (it == m_split_ranges_set.end()) {
return; return;
@ -230,70 +231,72 @@ void RangeSet<AddressType>::ForEach(Func&& func) const {
template <typename AddressType> template <typename AddressType>
template <typename Func> template <typename Func>
void RangeSet<AddressType>::ForEachInRange(AddressType base_address, size_t size, Func&& func) const { void RangeSet<AddressType>::ForEachInRange(AddressType base_address, size_t size,
Func&& func) const {
m_impl->ForEachInRange(base_address, size, std::move(func)); m_impl->ForEachInRange(base_address, size, std::move(func));
} }
template <typename AddressType> template <typename AddressType>
SplitRangeSet<AddressType>::SplitRangeSet() { OverlapRangeSet<AddressType>::OverlapRangeSet() {
m_impl = std::make_unique<SplitRangeSet<AddressType>::SplitRangeSetImpl>(); m_impl = std::make_unique<OverlapRangeSet<AddressType>::OverlapRangeSetImpl>();
} }
template <typename AddressType> template <typename AddressType>
SplitRangeSet<AddressType>::~SplitRangeSet() = default; OverlapRangeSet<AddressType>::~OverlapRangeSet() = default;
template <typename AddressType> template <typename AddressType>
SplitRangeSet<AddressType>::SplitRangeSet(SplitRangeSet&& other) { OverlapRangeSet<AddressType>::OverlapRangeSet(OverlapRangeSet&& other) {
m_impl = std::make_unique<SplitRangeSet<AddressType>::SplitRangeSetImpl>(); m_impl = std::make_unique<OverlapRangeSet<AddressType>::OverlapRangeSetImpl>();
m_impl->m_split_ranges_set = std::move(other.m_impl->m_split_ranges_set); m_impl->m_split_ranges_set = std::move(other.m_impl->m_split_ranges_set);
} }
template <typename AddressType> template <typename AddressType>
SplitRangeSet<AddressType>& SplitRangeSet<AddressType>::operator=(SplitRangeSet&& other) { OverlapRangeSet<AddressType>& OverlapRangeSet<AddressType>::operator=(OverlapRangeSet&& other) {
m_impl->m_split_ranges_set = std::move(other.m_impl->m_split_ranges_set); m_impl->m_split_ranges_set = std::move(other.m_impl->m_split_ranges_set);
} }
template <typename AddressType> template <typename AddressType>
void SplitRangeSet<AddressType>::Add(AddressType base_address, size_t size) { void OverlapRangeSet<AddressType>::Add(AddressType base_address, size_t size) {
m_impl->Add(base_address, size); m_impl->Add(base_address, size);
} }
template <typename AddressType> template <typename AddressType>
void SplitRangeSet<AddressType>::Subtract(AddressType base_address, size_t size) { void OverlapRangeSet<AddressType>::Subtract(AddressType base_address, size_t size) {
m_impl->template Subtract<false>(base_address, size, 1, [](AddressType, AddressType) {}); m_impl->template Subtract<false>(base_address, size, 1, [](AddressType, AddressType) {});
} }
template <typename AddressType> template <typename AddressType>
template <typename Func> template <typename Func>
void SplitRangeSet<AddressType>::Subtract(AddressType base_address, size_t size, Func&& on_delete) { void OverlapRangeSet<AddressType>::Subtract(AddressType base_address, size_t size,
Func&& on_delete) {
m_impl->template Subtract<true, Func>(base_address, size, 1, std::move(on_delete)); m_impl->template Subtract<true, Func>(base_address, size, 1, std::move(on_delete));
} }
template <typename AddressType> template <typename AddressType>
void SplitRangeSet<AddressType>::DeleteAll(AddressType base_address, size_t size) { void OverlapRangeSet<AddressType>::DeleteAll(AddressType base_address, size_t size) {
m_impl->template Subtract<false>(base_address, size, std::numeric_limits<s32>::max(), m_impl->template Subtract<false>(base_address, size, std::numeric_limits<s32>::max(),
[](AddressType, AddressType) {}); [](AddressType, AddressType) {});
} }
template <typename AddressType> template <typename AddressType>
void SplitRangeSet<AddressType>::Clear() { void OverlapRangeSet<AddressType>::Clear() {
m_impl->m_split_ranges_set.clear(); m_impl->m_split_ranges_set.clear();
} }
template <typename AddressType> template <typename AddressType>
bool SplitRangeSet<AddressType>::Empty() const { bool OverlapRangeSet<AddressType>::Empty() const {
return m_impl->m_split_ranges_set.empty(); return m_impl->m_split_ranges_set.empty();
} }
template <typename AddressType> template <typename AddressType>
template <typename Func> template <typename Func>
void SplitRangeSet<AddressType>::ForEach(Func&& func) const { void OverlapRangeSet<AddressType>::ForEach(Func&& func) const {
m_impl->ForEach(func); m_impl->ForEach(func);
} }
template <typename AddressType> template <typename AddressType>
template <typename Func> template <typename Func>
void SplitRangeSet<AddressType>::ForEachInRange(AddressType base_address, size_t size, void OverlapRangeSet<AddressType>::ForEachInRange(AddressType base_address, size_t size,
Func&& func) const { Func&& func) const {
m_impl->ForEachInRange(base_address, size, std::move(func)); m_impl->ForEachInRange(base_address, size, std::move(func));
} }

View file

@ -15,7 +15,7 @@ struct HeapMapper::HeapMapperInternal {
~HeapMapperInternal() = default; ~HeapMapperInternal() = default;
Common::RangeSet<VAddr> m_temporary_set; Common::RangeSet<VAddr> m_temporary_set;
Common::SplitRangeSet<VAddr> m_mapped_ranges; Common::OverlapRangeSet<VAddr> m_mapped_ranges;
Tegra::MaxwellDeviceMemoryManager& m_device_memory; Tegra::MaxwellDeviceMemoryManager& m_device_memory;
std::mutex m_guard; std::mutex m_guard;
}; };

View file

@ -460,7 +460,7 @@ private:
std::deque<Common::RangeSet<DAddr>> committed_gpu_modified_ranges; std::deque<Common::RangeSet<DAddr>> committed_gpu_modified_ranges;
// Async Buffers // Async Buffers
Common::SplitRangeSet<DAddr> async_downloads; Common::OverlapRangeSet<DAddr> async_downloads;
std::deque<std::optional<Async_Buffer>> async_buffers; std::deque<std::optional<Async_Buffer>> async_buffers;
std::deque<boost::container::small_vector<BufferCopy, 4>> pending_downloads; std::deque<boost::container::small_vector<BufferCopy, 4>> pending_downloads;
std::optional<Async_Buffer> current_buffer; std::optional<Async_Buffer> current_buffer;