From 862bec001b7ada13ba0e97f95d6ad108ae8a8d0c Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Fri, 19 Jul 2019 10:50:40 -0400 Subject: Video_Core: Implement a new Buffer Cache --- src/video_core/buffer_cache/map_interval.h | 48 ++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/video_core/buffer_cache/map_interval.h (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 new file mode 100644 index 000000000..652a35dcd --- /dev/null +++ b/src/video_core/buffer_cache/map_interval.h @@ -0,0 +1,48 @@ +// Copyright 2019 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include +#include "common/common_types.h" +#include "video_core/gpu.h" + +namespace VideoCommon { + +struct MapInterval { + MapInterval(const CacheAddr start, const CacheAddr end) : start{start}, end{end} {} + CacheAddr start; + CacheAddr end; + bool IsInside(const CacheAddr other_start, const CacheAddr other_end) { + return (start <= other_start && other_end <= end); + } + + bool operator==(const MapInterval& rhs) const { + return std::tie(start, end) == std::tie(rhs.start, rhs.end); + } + + bool operator!=(const MapInterval& rhs) const { + return !operator==(rhs); + } +}; + +struct MapInfo { + GPUVAddr gpu_addr; + VAddr cpu_addr; +}; + +} // namespace VideoCommon + +namespace std { + +template <> +struct hash { + std::size_t operator()(const VideoCommon::MapInterval& k) const noexcept { + std::size_t a = std::hash()(k.start); + boost::hash_combine(a, std::hash()(k.end)); + return a; + } +}; + +} // namespace std -- cgit v1.2.3