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 From 86d8563314c615d60c7b59748467ffb71904b0c4 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Fri, 19 Jul 2019 13:22:27 -0400 Subject: Buffer_Cache: Fixes and optimizations. --- src/video_core/buffer_cache/map_interval.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 652a35dcd..c1cd52ca4 100644 --- a/src/video_core/buffer_cache/map_interval.h +++ b/src/video_core/buffer_cache/map_interval.h @@ -14,7 +14,7 @@ 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) { + bool IsInside(const CacheAddr other_start, const CacheAddr other_end) const { return (start <= other_start && other_end <= end); } -- cgit v1.2.3 From 5f4b746a1ee27d2e5e532f4f13f660ff08453474 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Fri, 19 Jul 2019 21:07:28 -0400 Subject: BufferCache: Rework mapping caching. --- src/video_core/buffer_cache/map_interval.h | 62 ++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 21 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 c1cd52ca4..a01eddf49 100644 --- a/src/video_core/buffer_cache/map_interval.h +++ b/src/video_core/buffer_cache/map_interval.h @@ -4,45 +4,65 @@ #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; +class MapIntervalBase { +public: + MapIntervalBase(const CacheAddr start, const CacheAddr end, const GPUVAddr gpu_addr) + : start{start}, end{end}, gpu_addr{gpu_addr} {} + + void SetCpuAddress(VAddr new_cpu_addr) { + cpu_addr = new_cpu_addr; + } + + VAddr GetCpuAddress() const { + return cpu_addr; + } + + GPUVAddr GetGpuAddress() const { + return gpu_addr; + } + bool IsInside(const CacheAddr other_start, const CacheAddr other_end) const { return (start <= other_start && other_end <= end); } - bool operator==(const MapInterval& rhs) const { + bool operator==(const MapIntervalBase& rhs) const { return std::tie(start, end) == std::tie(rhs.start, rhs.end); } - bool operator!=(const MapInterval& rhs) const { + bool operator!=(const MapIntervalBase& rhs) const { return !operator==(rhs); } -}; -struct MapInfo { - GPUVAddr gpu_addr; - VAddr cpu_addr; -}; + void MarkAsRegistered(const bool registered) { + is_registered = registered; + } -} // namespace VideoCommon + bool IsRegistered() const { + return is_registered; + } -namespace std { + CacheAddr GetStart() const { + return start; + } -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; + CacheAddr GetEnd() const { + return end; } + +private: + CacheAddr start; + CacheAddr end; + GPUVAddr gpu_addr; + VAddr cpu_addr{}; + bool is_write{}; + bool is_modified{}; + bool is_registered{}; + u64 ticks{}; }; -} // namespace std +} // namespace VideoCommon -- cgit v1.2.3 From 286f4c446ae2396da41ca09173070ae5beb10e8e Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Sat, 20 Jul 2019 11:42:53 -0400 Subject: Buffer_Cache: Optimize and track written areas. --- src/video_core/buffer_cache/map_interval.h | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (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 a01eddf49..3a104d5cd 100644 --- a/src/video_core/buffer_cache/map_interval.h +++ b/src/video_core/buffer_cache/map_interval.h @@ -54,12 +54,33 @@ public: return end; } + void MarkAsModified(const bool is_modified_, const u64 tick) { + is_modified = is_modified_; + ticks = tick; + } + + bool IsModified() const { + return is_modified; + } + + u64 GetModificationTick() const { + return ticks; + } + + void MarkAsWritten(const bool is_written_) { + is_written = is_written_; + } + + bool IsWritten() const { + return is_written; + } + private: CacheAddr start; CacheAddr end; GPUVAddr gpu_addr; VAddr cpu_addr{}; - bool is_write{}; + bool is_written{}; bool is_modified{}; bool is_registered{}; u64 ticks{}; -- cgit v1.2.3