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 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <unordered_set> | ||
| 8 | #include <utility> | ||
| 9 | |||
| 10 | #include "common/alignment.h" | ||
| 11 | #include "common/common_types.h" | 7 | #include "common/common_types.h" |
| 12 | #include "video_core/gpu.h" | ||
| 13 | 8 | ||
| 14 | namespace VideoCommon { | 9 | namespace VideoCommon { |
| 15 | 10 | ||
| 16 | class BufferBlock { | 11 | class BufferBlock { |
| 17 | public: | 12 | public: |
| 18 | bool Overlaps(VAddr start, VAddr end) const { | 13 | [[nodiscard]] bool Overlaps(VAddr start, VAddr end) const { |
| 19 | return (cpu_addr < end) && (cpu_addr_end > start); | 14 | return (cpu_addr < end) && (cpu_addr_end > start); |
| 20 | } | 15 | } |
| 21 | 16 | ||
| 22 | bool IsInside(VAddr other_start, VAddr other_end) const { | 17 | [[nodiscard]] bool IsInside(VAddr other_start, VAddr other_end) const { |
| 23 | return cpu_addr <= other_start && other_end <= cpu_addr_end; | 18 | return cpu_addr <= other_start && other_end <= cpu_addr_end; |
| 24 | } | 19 | } |
| 25 | 20 | ||
| 26 | std::size_t Offset(VAddr in_addr) const { | 21 | [[nodiscard]] std::size_t Offset(VAddr in_addr) const { |
| 27 | return static_cast<std::size_t>(in_addr - cpu_addr); | 22 | return static_cast<std::size_t>(in_addr - cpu_addr); |
| 28 | } | 23 | } |
| 29 | 24 | ||
| 30 | VAddr CpuAddr() const { | 25 | [[nodiscard]] VAddr CpuAddr() const { |
| 31 | return cpu_addr; | 26 | return cpu_addr; |
| 32 | } | 27 | } |
| 33 | 28 | ||
| 34 | VAddr CpuAddrEnd() const { | 29 | [[nodiscard]] VAddr CpuAddrEnd() const { |
| 35 | return cpu_addr_end; | 30 | return cpu_addr_end; |
| 36 | } | 31 | } |
| 37 | 32 | ||
| @@ -40,11 +35,11 @@ public: | |||
| 40 | cpu_addr_end = new_addr + size; | 35 | cpu_addr_end = new_addr + size; |
| 41 | } | 36 | } |
| 42 | 37 | ||
| 43 | std::size_t Size() const { | 38 | [[nodiscard]] std::size_t Size() const { |
| 44 | return size; | 39 | return size; |
| 45 | } | 40 | } |
| 46 | 41 | ||
| 47 | u64 Epoch() const { | 42 | [[nodiscard]] u64 Epoch() const { |
| 48 | return epoch; | 43 | return epoch; |
| 49 | } | 44 | } |
| 50 | 45 | ||
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: | |||
| 118 | /// Prepares the buffer cache for data uploading | 118 | /// Prepares the buffer cache for data uploading |
| 119 | /// @param max_size Maximum number of bytes that will be uploaded | 119 | /// @param max_size Maximum number of bytes that will be uploaded |
| 120 | /// @return True when a stream buffer invalidation was required, false otherwise | 120 | /// @return True when a stream buffer invalidation was required, false otherwise |
| 121 | bool Map(std::size_t max_size) { | 121 | void Map(std::size_t max_size) { |
| 122 | std::lock_guard lock{mutex}; | 122 | std::lock_guard lock{mutex}; |
| 123 | 123 | ||
| 124 | bool invalidated; | 124 | std::tie(buffer_ptr, buffer_offset_base) = stream_buffer.Map(max_size, 4); |
| 125 | std::tie(buffer_ptr, buffer_offset_base, invalidated) = stream_buffer->Map(max_size, 4); | ||
| 126 | buffer_offset = buffer_offset_base; | 125 | buffer_offset = buffer_offset_base; |
| 127 | |||
| 128 | return invalidated; | ||
| 129 | } | 126 | } |
| 130 | 127 | ||
| 131 | /// Finishes the upload stream | 128 | /// Finishes the upload stream |
| 132 | void Unmap() { | 129 | void Unmap() { |
| 133 | std::lock_guard lock{mutex}; | 130 | std::lock_guard lock{mutex}; |
| 134 | stream_buffer->Unmap(buffer_offset - buffer_offset_base); | 131 | stream_buffer.Unmap(buffer_offset - buffer_offset_base); |
| 135 | } | 132 | } |
| 136 | 133 | ||
| 137 | /// Function called at the end of each frame, inteded for deferred operations | 134 | /// Function called at the end of each frame, inteded for deferred operations |
| @@ -261,9 +258,9 @@ public: | |||
| 261 | protected: | 258 | protected: |
| 262 | explicit BufferCache(VideoCore::RasterizerInterface& rasterizer_, | 259 | explicit BufferCache(VideoCore::RasterizerInterface& rasterizer_, |
| 263 | Tegra::MemoryManager& gpu_memory_, Core::Memory::Memory& cpu_memory_, | 260 | Tegra::MemoryManager& gpu_memory_, Core::Memory::Memory& cpu_memory_, |
| 264 | std::unique_ptr<StreamBuffer> stream_buffer_) | 261 | StreamBuffer& stream_buffer_) |
| 265 | : rasterizer{rasterizer_}, gpu_memory{gpu_memory_}, cpu_memory{cpu_memory_}, | 262 | : rasterizer{rasterizer_}, gpu_memory{gpu_memory_}, cpu_memory{cpu_memory_}, |
| 266 | stream_buffer{std::move(stream_buffer_)}, stream_buffer_handle{stream_buffer->Handle()} {} | 263 | stream_buffer{stream_buffer_} {} |
| 267 | 264 | ||
| 268 | ~BufferCache() = default; | 265 | ~BufferCache() = default; |
| 269 | 266 | ||
| @@ -441,7 +438,7 @@ private: | |||
| 441 | 438 | ||
| 442 | buffer_ptr += size; | 439 | buffer_ptr += size; |
| 443 | buffer_offset += size; | 440 | buffer_offset += size; |
| 444 | return BufferInfo{stream_buffer->Handle(), uploaded_offset, stream_buffer->Address()}; | 441 | return BufferInfo{stream_buffer.Handle(), uploaded_offset, stream_buffer.Address()}; |
| 445 | } | 442 | } |
| 446 | 443 | ||
| 447 | void AlignBuffer(std::size_t alignment) { | 444 | void AlignBuffer(std::size_t alignment) { |
| @@ -545,7 +542,7 @@ private: | |||
| 545 | bool IsRegionWritten(VAddr start, VAddr end) const { | 542 | bool IsRegionWritten(VAddr start, VAddr end) const { |
| 546 | const u64 page_end = end >> WRITE_PAGE_BIT; | 543 | const u64 page_end = end >> WRITE_PAGE_BIT; |
| 547 | for (u64 page_start = start >> WRITE_PAGE_BIT; page_start <= page_end; ++page_start) { | 544 | for (u64 page_start = start >> WRITE_PAGE_BIT; page_start <= page_end; ++page_start) { |
| 548 | if (written_pages.count(page_start) > 0) { | 545 | if (written_pages.contains(page_start)) { |
| 549 | return true; | 546 | return true; |
| 550 | } | 547 | } |
| 551 | } | 548 | } |
| @@ -567,9 +564,7 @@ private: | |||
| 567 | VideoCore::RasterizerInterface& rasterizer; | 564 | VideoCore::RasterizerInterface& rasterizer; |
| 568 | Tegra::MemoryManager& gpu_memory; | 565 | Tegra::MemoryManager& gpu_memory; |
| 569 | Core::Memory::Memory& cpu_memory; | 566 | Core::Memory::Memory& cpu_memory; |
| 570 | 567 | StreamBuffer& stream_buffer; | |
| 571 | std::unique_ptr<StreamBuffer> stream_buffer; | ||
| 572 | BufferType stream_buffer_handle; | ||
| 573 | 568 | ||
| 574 | u8* buffer_ptr = nullptr; | 569 | u8* buffer_ptr = nullptr; |
| 575 | u64 buffer_offset = 0; | 570 | 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: | |||
| 84 | void FillFreeList(Chunk& chunk); | 84 | void FillFreeList(Chunk& chunk); |
| 85 | 85 | ||
| 86 | std::vector<MapInterval*> free_list; | 86 | std::vector<MapInterval*> free_list; |
| 87 | std::unique_ptr<Chunk>* new_chunk = &first_chunk.next; | ||
| 88 | 87 | ||
| 89 | Chunk first_chunk; | 88 | Chunk first_chunk; |
| 89 | |||
| 90 | std::unique_ptr<Chunk>* new_chunk = &first_chunk.next; | ||
| 90 | }; | 91 | }; |
| 91 | 92 | ||
| 92 | } // namespace VideoCommon | 93 | } // namespace VideoCommon |