From b8fbf6969c33a72c7facfd23e7a850e718afac43 Mon Sep 17 00:00:00 2001 From: comex Date: Sat, 14 Nov 2020 18:33:40 -0500 Subject: map_interval: Change field order to address uninitialized field warning Clang complains about `new_chunk`'s constructor using the then-uninitialized `first_chunk` (even though it's just to get a pointer into it). --- src/video_core/buffer_cache/map_interval.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/video_core/buffer_cache') 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 free_list; - std::unique_ptr* new_chunk = &first_chunk.next; Chunk first_chunk; + + std::unique_ptr* new_chunk = &first_chunk.next; }; } // namespace VideoCommon -- cgit v1.2.3 From 3954f14c6d7043804a85f2cbbad1b7e335162276 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 7 Dec 2020 01:52:13 -0500 Subject: buffer_block: Remove unnecessary includes Reduces the amount of dependencies the header pulls in. --- src/video_core/buffer_cache/buffer_block.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src/video_core/buffer_cache') diff --git a/src/video_core/buffer_cache/buffer_block.h b/src/video_core/buffer_cache/buffer_block.h index e64170e66..eee6908b1 100644 --- a/src/video_core/buffer_cache/buffer_block.h +++ b/src/video_core/buffer_cache/buffer_block.h @@ -4,12 +4,7 @@ #pragma once -#include -#include - -#include "common/alignment.h" #include "common/common_types.h" -#include "video_core/gpu.h" namespace VideoCommon { -- cgit v1.2.3 From 5d2f18fbcdca61b3bf140e92bf1c7d5b163aa580 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 7 Dec 2020 01:53:37 -0500 Subject: buffer_block: Mark interface as nodiscard where applicable Prevents logic errors from occurring from unused values. --- src/video_core/buffer_cache/buffer_block.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/video_core/buffer_cache') diff --git a/src/video_core/buffer_cache/buffer_block.h b/src/video_core/buffer_cache/buffer_block.h index eee6908b1..e9306194a 100644 --- a/src/video_core/buffer_cache/buffer_block.h +++ b/src/video_core/buffer_cache/buffer_block.h @@ -10,23 +10,23 @@ 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(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; } @@ -35,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; } -- cgit v1.2.3 From 09fa1d6a739b18f6a8f3d83065ff9aebd6e4bc8d Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 7 Dec 2020 16:30:36 -0500 Subject: video_core: Make use of ordered container contains() where applicable With C++20, we can use the more concise contains() member function instead of comparing the result of the find() call with the end iterator. --- src/video_core/buffer_cache/buffer_cache.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/video_core/buffer_cache') diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h index e7edd733f..38961f3fd 100644 --- a/src/video_core/buffer_cache/buffer_cache.h +++ b/src/video_core/buffer_cache/buffer_cache.h @@ -545,7 +545,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; } } -- cgit v1.2.3 From 9764c13d6d2977903f407761b27d847c0056e1c4 Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Wed, 30 Dec 2020 02:25:23 -0300 Subject: video_core: Rewrite the texture cache The current texture cache has several points that hurt maintainability and performance. It's easy to break unrelated parts of the cache when doing minor changes. The cache can easily forget valuable information about the cached textures by CPU writes or simply by its normal usage.The current texture cache has several points that hurt maintainability and performance. It's easy to break unrelated parts of the cache when doing minor changes. The cache can easily forget valuable information about the cached textures by CPU writes or simply by its normal usage. This commit aims to address those issues. --- src/video_core/buffer_cache/buffer_cache.h | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'src/video_core/buffer_cache') diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h index 38961f3fd..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 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) { @@ -567,9 +564,7 @@ private: VideoCore::RasterizerInterface& rasterizer; Tegra::MemoryManager& gpu_memory; Core::Memory::Memory& cpu_memory; - - std::unique_ptr stream_buffer; - BufferType stream_buffer_handle; + StreamBuffer& stream_buffer; u8* buffer_ptr = nullptr; u64 buffer_offset = 0; -- cgit v1.2.3