From 891236124caaed34cdefac61cf90896a5b66b267 Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Sun, 17 May 2020 16:56:08 -0300 Subject: buffer_cache: Use boost::intrusive::set for caching Instead of using boost::icl::interval_map for caching, use boost::intrusive::set. interval_map is intended as a container where the keys can overlap with one another; we don't need this for caching buffers and a std::set-like data structure that allows us to search with lower_bound is enough. --- src/video_core/buffer_cache/map_interval.h | 32 +++++++++++++++++------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'src/video_core/buffer_cache/map_interval.h') diff --git a/src/video_core/buffer_cache/map_interval.h b/src/video_core/buffer_cache/map_interval.h index ad4db0135..45705cccf 100644 --- a/src/video_core/buffer_cache/map_interval.h +++ b/src/video_core/buffer_cache/map_interval.h @@ -4,38 +4,36 @@ #pragma once +#include + #include "common/common_types.h" #include "video_core/gpu.h" namespace VideoCommon { -struct MapInterval { - constexpr explicit MapInterval() noexcept = default; - - constexpr explicit MapInterval(VAddr start, VAddr end, GPUVAddr gpu_addr) noexcept - : start{start}, end{end}, gpu_addr{gpu_addr} {} +struct MapInterval : public boost::intrusive::set_base_hook> { + /*implicit*/ MapInterval(VAddr start_) noexcept : start{start_} {} - constexpr bool IsInside(VAddr other_start, VAddr other_end) const noexcept { - return (start <= other_start && other_end <= end); - } + explicit MapInterval(VAddr start_, VAddr end_, GPUVAddr gpu_addr_) noexcept + : start{start_}, end{end_}, gpu_addr{gpu_addr_} {} - constexpr bool operator==(const MapInterval& rhs) const noexcept { - return start == rhs.start && end == rhs.end; + bool IsInside(VAddr other_start, VAddr other_end) const noexcept { + return start <= other_start && other_end <= end; } - constexpr bool operator!=(const MapInterval& rhs) const noexcept { - return !operator==(rhs); + bool Overlaps(VAddr other_start, VAddr other_end) const noexcept { + return start < other_end && other_start < end; } - constexpr void MarkAsModified(bool is_modified_, u64 ticks_) noexcept { + void MarkAsModified(bool is_modified_, u64 ticks_) noexcept { is_modified = is_modified_; ticks = ticks_; } + boost::intrusive::set_member_hook<> member_hook_; VAddr start = 0; VAddr end = 0; GPUVAddr gpu_addr = 0; - VAddr cpu_addr = 0; u64 ticks = 0; bool is_written = false; bool is_modified = false; @@ -44,4 +42,10 @@ struct MapInterval { bool is_sync_pending = false; }; +struct MapIntervalCompare { + constexpr bool operator()(const MapInterval& lhs, const MapInterval& rhs) const noexcept { + return lhs.start < rhs.start; + } +}; + } // namespace VideoCommon -- cgit v1.2.3