summaryrefslogtreecommitdiffstats
path: root/src/video_core/buffer_cache/buffer_base.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core/buffer_cache/buffer_base.h')
-rw-r--r--src/video_core/buffer_cache/buffer_base.h99
1 files changed, 7 insertions, 92 deletions
diff --git a/src/video_core/buffer_cache/buffer_base.h b/src/video_core/buffer_cache/buffer_base.h
index 095f79387..9cbd95c4b 100644
--- a/src/video_core/buffer_cache/buffer_base.h
+++ b/src/video_core/buffer_cache/buffer_base.h
@@ -38,10 +38,8 @@ public:
static constexpr u64 BASE_PAGE_BITS = 16;
static constexpr u64 BASE_PAGE_SIZE = 1ULL << BASE_PAGE_BITS;
- explicit BufferBase(RasterizerInterface& rasterizer_, VAddr cpu_addr_, u64 size_bytes)
- : cpu_addr{Common::AlignDown(cpu_addr_, BASE_PAGE_SIZE)},
- word_manager(cpu_addr, rasterizer_,
- Common::AlignUp(size_bytes + (cpu_addr_ - cpu_addr), BASE_PAGE_SIZE)) {}
+ explicit BufferBase(RasterizerInterface& rasterizer_, VAddr cpu_addr_, u64 size_bytes_)
+ : cpu_addr{cpu_addr_}, size_bytes{size_bytes_} {}
explicit BufferBase(NullBufferParams) {}
@@ -51,88 +49,6 @@ public:
BufferBase& operator=(BufferBase&&) = default;
BufferBase(BufferBase&&) = default;
- /// Returns the inclusive CPU modified range in a begin end pair
- [[nodiscard]] std::pair<u64, u64> ModifiedCpuRegion(VAddr query_cpu_addr,
- u64 query_size) const noexcept {
- const u64 offset = query_cpu_addr - cpu_addr;
- return word_manager.template ModifiedRegion<Type::CPU>(offset, query_size);
- }
-
- /// Returns the inclusive GPU modified range in a begin end pair
- [[nodiscard]] std::pair<u64, u64> ModifiedGpuRegion(VAddr query_cpu_addr,
- u64 query_size) const noexcept {
- const u64 offset = query_cpu_addr - cpu_addr;
- return word_manager.template ModifiedRegion<Type::GPU>(offset, query_size);
- }
-
- /// Returns true if a region has been modified from the CPU
- [[nodiscard]] bool IsRegionCpuModified(VAddr query_cpu_addr, u64 query_size) const noexcept {
- const u64 offset = query_cpu_addr - cpu_addr;
- return word_manager.template IsRegionModified<Type::CPU>(offset, query_size);
- }
-
- /// Returns true if a region has been modified from the GPU
- [[nodiscard]] bool IsRegionGpuModified(VAddr query_cpu_addr, u64 query_size) const noexcept {
- const u64 offset = query_cpu_addr - cpu_addr;
- return word_manager.template IsRegionModified<Type::GPU>(offset, query_size);
- }
-
- /// Mark region as CPU modified, notifying the rasterizer about this change
- void MarkRegionAsCpuModified(VAddr dirty_cpu_addr, u64 size) {
- word_manager.template ChangeRegionState<Type::CPU, true>(dirty_cpu_addr, size);
- }
-
- /// Unmark region as CPU modified, notifying the rasterizer about this change
- void UnmarkRegionAsCpuModified(VAddr dirty_cpu_addr, u64 size) {
- word_manager.template ChangeRegionState<Type::CPU, false>(dirty_cpu_addr, size);
- }
-
- /// Mark region as modified from the host GPU
- void MarkRegionAsGpuModified(VAddr dirty_cpu_addr, u64 size) noexcept {
- word_manager.template ChangeRegionState<Type::GPU, true>(dirty_cpu_addr, size);
- }
-
- /// Unmark region as modified from the host GPU
- void UnmarkRegionAsGpuModified(VAddr dirty_cpu_addr, u64 size) noexcept {
- word_manager.template ChangeRegionState<Type::GPU, false>(dirty_cpu_addr, size);
- }
-
- /// Mark region as modified from the CPU
- /// but don't mark it as modified until FlusHCachedWrites is called.
- void CachedCpuWrite(VAddr dirty_cpu_addr, u64 size) {
- flags |= BufferFlagBits::CachedWrites;
- word_manager.template ChangeRegionState<Type::CachedCPU, true>(dirty_cpu_addr, size);
- }
-
- /// Flushes cached CPU writes, and notify the rasterizer about the deltas
- void FlushCachedWrites() noexcept {
- flags &= ~BufferFlagBits::CachedWrites;
- word_manager.FlushCachedWrites();
- }
-
- /// Call 'func' for each CPU modified range and unmark those pages as CPU modified
- template <typename Func>
- void ForEachUploadRange(VAddr query_cpu_range, u64 size, Func&& func) {
- word_manager.template ForEachModifiedRange<Type::CPU>(query_cpu_range, size, true, func);
- }
-
- /// Call 'func' for each GPU modified range and unmark those pages as GPU modified
- template <typename Func>
- void ForEachDownloadRange(VAddr query_cpu_range, u64 size, bool clear, Func&& func) {
- word_manager.template ForEachModifiedRange<Type::GPU>(query_cpu_range, size, clear, func);
- }
-
- template <typename Func>
- void ForEachDownloadRangeAndClear(VAddr query_cpu_range, u64 size, Func&& func) {
- word_manager.template ForEachModifiedRange<Type::GPU>(query_cpu_range, size, true, func);
- }
-
- /// Call 'func' for each GPU modified range and unmark those pages as GPU modified
- template <typename Func>
- void ForEachDownloadRange(Func&& func) {
- word_manager.template ForEachModifiedRange<Type::GPU>(cpu_addr, SizeBytes(), true, func);
- }
-
/// Mark buffer as picked
void Pick() noexcept {
flags |= BufferFlagBits::Picked;
@@ -179,11 +95,6 @@ public:
return static_cast<u32>(other_cpu_addr - cpu_addr);
}
- /// Returns the size in bytes of the buffer
- [[nodiscard]] u64 SizeBytes() const noexcept {
- return word_manager.SizeBytes();
- }
-
size_t getLRUID() const noexcept {
return lru_id;
}
@@ -192,12 +103,16 @@ public:
lru_id = lru_id_;
}
+ size_t SizeBytes() const {
+ return size_bytes;
+ }
+
private:
VAddr cpu_addr = 0;
- WordManager<RasterizerInterface> word_manager;
BufferFlagBits flags{};
int stream_score = 0;
size_t lru_id = SIZE_MAX;
+ size_t size_bytes = 0;
};
} // namespace VideoCommon