diff options
Diffstat (limited to 'src/video_core/buffer_cache')
-rw-r--r-- | src/video_core/buffer_cache/buffer_block.h | 19 | ||||
-rw-r--r-- | src/video_core/buffer_cache/buffer_cache.h | 21 | ||||
-rw-r--r-- | src/video_core/buffer_cache/map_interval.h | 3 |
3 files changed, 17 insertions, 26 deletions
diff --git a/src/video_core/buffer_cache/buffer_block.h b/src/video_core/buffer_cache/buffer_block.h index e64170e66..e9306194a 100644 --- a/src/video_core/buffer_cache/buffer_block.h +++ b/src/video_core/buffer_cache/buffer_block.h @@ -4,34 +4,29 @@ #pragma once -#include <unordered_set> -#include <utility> - -#include "common/alignment.h" #include "common/common_types.h" -#include "video_core/gpu.h" namespace VideoCommon { class BufferBlock { public: - bool Overlaps(VAddr start, VAddr end) const { + [[nodiscard]] bool Overlaps(VAddr start, VAddr end) const { return (cpu_addr < end) && (cpu_addr_end > start); } - bool IsInside(VAddr other_start, VAddr other_end) const { + [[nodiscard]] bool IsInside(VAddr other_start, VAddr other_end) const { return cpu_addr <= other_start && other_end <= cpu_addr_end; } - std::size_t Offset(VAddr in_addr) const { + [[nodiscard]] std::size_t Offset(VAddr in_addr) const { return static_cast<std::size_t>(in_addr - cpu_addr); } - VAddr CpuAddr() const { + [[nodiscard]] VAddr CpuAddr() const { return cpu_addr; } - VAddr CpuAddrEnd() const { + [[nodiscard]] VAddr CpuAddrEnd() const { return cpu_addr_end; } @@ -40,11 +35,11 @@ public: cpu_addr_end = new_addr + size; } - std::size_t Size() const { + [[nodiscard]] std::size_t Size() const { return size; } - u64 Epoch() const { + [[nodiscard]] u64 Epoch() const { return epoch; } diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h index e7edd733f..83b9ee871 100644 --- a/src/video_core/buffer_cache/buffer_cache.h +++ b/src/video_core/buffer_cache/buffer_cache.h @@ -118,20 +118,17 @@ public: /// Prepares the buffer cache for data uploading /// @param max_size Maximum number of bytes that will be uploaded /// @return True when a stream buffer invalidation was required, false otherwise - bool Map(std::size_t max_size) { + void Map(std::size_t max_size) { std::lock_guard lock{mutex}; - bool invalidated; - std::tie(buffer_ptr, buffer_offset_base, invalidated) = stream_buffer->Map(max_size, 4); + std::tie(buffer_ptr, buffer_offset_base) = stream_buffer.Map(max_size, 4); buffer_offset = buffer_offset_base; - - return invalidated; } /// Finishes the upload stream void Unmap() { std::lock_guard lock{mutex}; - stream_buffer->Unmap(buffer_offset - buffer_offset_base); + stream_buffer.Unmap(buffer_offset - buffer_offset_base); } /// Function called at the end of each frame, inteded for deferred operations @@ -261,9 +258,9 @@ public: protected: explicit BufferCache(VideoCore::RasterizerInterface& rasterizer_, Tegra::MemoryManager& gpu_memory_, Core::Memory::Memory& cpu_memory_, - std::unique_ptr<StreamBuffer> stream_buffer_) + StreamBuffer& stream_buffer_) : rasterizer{rasterizer_}, gpu_memory{gpu_memory_}, cpu_memory{cpu_memory_}, - stream_buffer{std::move(stream_buffer_)}, stream_buffer_handle{stream_buffer->Handle()} {} + stream_buffer{stream_buffer_} {} ~BufferCache() = default; @@ -441,7 +438,7 @@ private: buffer_ptr += size; buffer_offset += size; - return BufferInfo{stream_buffer->Handle(), uploaded_offset, stream_buffer->Address()}; + return BufferInfo{stream_buffer.Handle(), uploaded_offset, stream_buffer.Address()}; } void AlignBuffer(std::size_t alignment) { @@ -545,7 +542,7 @@ private: bool IsRegionWritten(VAddr start, VAddr end) const { const u64 page_end = end >> WRITE_PAGE_BIT; for (u64 page_start = start >> WRITE_PAGE_BIT; page_start <= page_end; ++page_start) { - if (written_pages.count(page_start) > 0) { + if (written_pages.contains(page_start)) { return true; } } @@ -567,9 +564,7 @@ private: VideoCore::RasterizerInterface& rasterizer; Tegra::MemoryManager& gpu_memory; Core::Memory::Memory& cpu_memory; - - std::unique_ptr<StreamBuffer> stream_buffer; - BufferType stream_buffer_handle; + StreamBuffer& stream_buffer; u8* buffer_ptr = nullptr; u64 buffer_offset = 0; diff --git a/src/video_core/buffer_cache/map_interval.h b/src/video_core/buffer_cache/map_interval.h index fe0bcd1d8..ef974b08a 100644 --- a/src/video_core/buffer_cache/map_interval.h +++ b/src/video_core/buffer_cache/map_interval.h @@ -84,9 +84,10 @@ private: void FillFreeList(Chunk& chunk); std::vector<MapInterval*> free_list; - std::unique_ptr<Chunk>* new_chunk = &first_chunk.next; Chunk first_chunk; + + std::unique_ptr<Chunk>* new_chunk = &first_chunk.next; }; } // namespace VideoCommon |