diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_texture_cache.cpp | 19 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_texture_cache.h | 5 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_texture_cache.cpp | 13 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_texture_cache.h | 5 | ||||
| -rw-r--r-- | src/video_core/texture_cache/texture_cache.h | 22 | ||||
| -rw-r--r-- | src/video_core/texture_cache/texture_cache_base.h | 1 |
6 files changed, 46 insertions, 19 deletions
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cpp index 670d8cafd..032a8ebc5 100644 --- a/src/video_core/renderer_opengl/gl_texture_cache.cpp +++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp | |||
| @@ -801,14 +801,22 @@ void Image::UploadMemory(const ImageBufferMap& map, | |||
| 801 | UploadMemory(map.buffer, map.offset, copies); | 801 | UploadMemory(map.buffer, map.offset, copies); |
| 802 | } | 802 | } |
| 803 | 803 | ||
| 804 | void Image::DownloadMemory(std::span<GLuint> buffer_handles, size_t buffer_offset, | 804 | void Image::DownloadMemory(GLuint buffer_handle, size_t buffer_offset, |
| 805 | std::span<const VideoCommon::BufferImageCopy> copies) { | ||
| 806 | std::array buffer_handles{buffer_handle}; | ||
| 807 | std::array buffer_offsets{buffer_offset}; | ||
| 808 | DownloadMemory(buffer_handles, buffer_offsets, copies); | ||
| 809 | } | ||
| 810 | |||
| 811 | void Image::DownloadMemory(std::span<GLuint> buffer_handles, std::span<size_t> buffer_offsets, | ||
| 805 | std::span<const VideoCommon::BufferImageCopy> copies) { | 812 | std::span<const VideoCommon::BufferImageCopy> copies) { |
| 806 | const bool is_rescaled = True(flags & ImageFlagBits::Rescaled); | 813 | const bool is_rescaled = True(flags & ImageFlagBits::Rescaled); |
| 807 | if (is_rescaled) { | 814 | if (is_rescaled) { |
| 808 | ScaleDown(); | 815 | ScaleDown(); |
| 809 | } | 816 | } |
| 810 | glMemoryBarrier(GL_PIXEL_BUFFER_BARRIER_BIT); // TODO: Move this to its own API | 817 | glMemoryBarrier(GL_PIXEL_BUFFER_BARRIER_BIT); // TODO: Move this to its own API |
| 811 | for (auto buffer_handle : buffer_handles) { | 818 | for (size_t i = 0; i < buffer_handles.size(); i++) { |
| 819 | auto& buffer_handle = buffer_handles[i]; | ||
| 812 | glBindBuffer(GL_PIXEL_PACK_BUFFER, buffer_handle); | 820 | glBindBuffer(GL_PIXEL_PACK_BUFFER, buffer_handle); |
| 813 | glPixelStorei(GL_PACK_ALIGNMENT, 1); | 821 | glPixelStorei(GL_PACK_ALIGNMENT, 1); |
| 814 | 822 | ||
| @@ -827,7 +835,7 @@ void Image::DownloadMemory(std::span<GLuint> buffer_handles, size_t buffer_offse | |||
| 827 | current_image_height = copy.buffer_image_height; | 835 | current_image_height = copy.buffer_image_height; |
| 828 | glPixelStorei(GL_PACK_IMAGE_HEIGHT, current_image_height); | 836 | glPixelStorei(GL_PACK_IMAGE_HEIGHT, current_image_height); |
| 829 | } | 837 | } |
| 830 | CopyImageToBuffer(copy, buffer_offset); | 838 | CopyImageToBuffer(copy, buffer_offsets[i]); |
| 831 | } | 839 | } |
| 832 | } | 840 | } |
| 833 | if (is_rescaled) { | 841 | if (is_rescaled) { |
| @@ -837,10 +845,7 @@ void Image::DownloadMemory(std::span<GLuint> buffer_handles, size_t buffer_offse | |||
| 837 | 845 | ||
| 838 | void Image::DownloadMemory(ImageBufferMap& map, | 846 | void Image::DownloadMemory(ImageBufferMap& map, |
| 839 | std::span<const VideoCommon::BufferImageCopy> copies) { | 847 | std::span<const VideoCommon::BufferImageCopy> copies) { |
| 840 | std::array buffers{ | 848 | DownloadMemory(map.buffer, map.offset, copies); |
| 841 | map.buffer, | ||
| 842 | }; | ||
| 843 | DownloadMemory(buffers, map.offset, copies); | ||
| 844 | } | 849 | } |
| 845 | 850 | ||
| 846 | GLuint Image::StorageHandle() noexcept { | 851 | GLuint Image::StorageHandle() noexcept { |
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.h b/src/video_core/renderer_opengl/gl_texture_cache.h index 67d6910b4..0dd039ed2 100644 --- a/src/video_core/renderer_opengl/gl_texture_cache.h +++ b/src/video_core/renderer_opengl/gl_texture_cache.h | |||
| @@ -212,7 +212,10 @@ public: | |||
| 212 | void UploadMemory(const ImageBufferMap& map, | 212 | void UploadMemory(const ImageBufferMap& map, |
| 213 | std::span<const VideoCommon::BufferImageCopy> copies); | 213 | std::span<const VideoCommon::BufferImageCopy> copies); |
| 214 | 214 | ||
| 215 | void DownloadMemory(std::span<GLuint> buffer_handle, size_t buffer_offset, | 215 | void DownloadMemory(GLuint buffer_handle, size_t buffer_offset, |
| 216 | std::span<const VideoCommon::BufferImageCopy> copies); | ||
| 217 | |||
| 218 | void DownloadMemory(std::span<GLuint> buffer_handle, std::span<size_t> buffer_offset, | ||
| 216 | std::span<const VideoCommon::BufferImageCopy> copies); | 219 | std::span<const VideoCommon::BufferImageCopy> copies); |
| 217 | 220 | ||
| 218 | void DownloadMemory(ImageBufferMap& map, std::span<const VideoCommon::BufferImageCopy> copies); | 221 | void DownloadMemory(ImageBufferMap& map, std::span<const VideoCommon::BufferImageCopy> copies); |
diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp index da3841bb3..d0a7d8f35 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-3.0-or-later | 2 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 3 | 3 | ||
| 4 | #include <algorithm> | 4 | #include <algorithm> |
| @@ -1342,6 +1342,17 @@ void Image::UploadMemory(const StagingBufferRef& map, std::span<const BufferImag | |||
| 1342 | UploadMemory(map.buffer, map.offset, copies); | 1342 | UploadMemory(map.buffer, map.offset, copies); |
| 1343 | } | 1343 | } |
| 1344 | 1344 | ||
| 1345 | void Image::DownloadMemory(VkBuffer buffer, VkDeviceSize offset, | ||
| 1346 | std::span<const VideoCommon::BufferImageCopy> copies) { | ||
| 1347 | std::array buffer_handles{ | ||
| 1348 | buffer, | ||
| 1349 | }; | ||
| 1350 | std::array buffer_offsets{ | ||
| 1351 | offset, | ||
| 1352 | }; | ||
| 1353 | DownloadMemory(buffer_handles, buffer_offsets, copies); | ||
| 1354 | } | ||
| 1355 | |||
| 1345 | void Image::DownloadMemory(std::span<VkBuffer> buffers_span, std::span<VkDeviceSize> offsets_span, | 1356 | void Image::DownloadMemory(std::span<VkBuffer> buffers_span, std::span<VkDeviceSize> offsets_span, |
| 1346 | std::span<const VideoCommon::BufferImageCopy> copies) { | 1357 | std::span<const VideoCommon::BufferImageCopy> copies) { |
| 1347 | const bool is_rescaled = True(flags & ImageFlagBits::Rescaled); | 1358 | const bool is_rescaled = True(flags & ImageFlagBits::Rescaled); |
diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.h b/src/video_core/renderer_vulkan/vk_texture_cache.h index bdaf43ba4..c656c5386 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.h +++ b/src/video_core/renderer_vulkan/vk_texture_cache.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-3.0-or-later | 2 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| @@ -138,6 +138,9 @@ public: | |||
| 138 | void UploadMemory(const StagingBufferRef& map, | 138 | void UploadMemory(const StagingBufferRef& map, |
| 139 | std::span<const VideoCommon::BufferImageCopy> copies); | 139 | std::span<const VideoCommon::BufferImageCopy> copies); |
| 140 | 140 | ||
| 141 | void DownloadMemory(VkBuffer buffer, VkDeviceSize offset, | ||
| 142 | std::span<const VideoCommon::BufferImageCopy> copies); | ||
| 143 | |||
| 141 | void DownloadMemory(std::span<VkBuffer> buffers, std::span<VkDeviceSize> offsets, | 144 | void DownloadMemory(std::span<VkBuffer> buffers, std::span<VkDeviceSize> offsets, |
| 142 | std::span<const VideoCommon::BufferImageCopy> copies); | 145 | std::span<const VideoCommon::BufferImageCopy> copies); |
| 143 | 146 | ||
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index 543ceb5aa..e601f8446 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h | |||
| @@ -139,6 +139,13 @@ void TextureCache<P>::TickFrame() { | |||
| 139 | runtime.TickFrame(); | 139 | runtime.TickFrame(); |
| 140 | critical_gc = 0; | 140 | critical_gc = 0; |
| 141 | ++frame_tick; | 141 | ++frame_tick; |
| 142 | |||
| 143 | if constexpr (IMPLEMENTS_ASYNC_DOWNLOADS) { | ||
| 144 | for (auto& buffer : async_buffers_death_ring) { | ||
| 145 | runtime.FreeDeferredStagingBuffer(buffer); | ||
| 146 | } | ||
| 147 | async_buffers_death_ring.clear(); | ||
| 148 | } | ||
| 142 | } | 149 | } |
| 143 | 150 | ||
| 144 | template <class P> | 151 | template <class P> |
| @@ -688,10 +695,10 @@ void TextureCache<P>::CommitAsyncFlushes() { | |||
| 688 | } | 695 | } |
| 689 | uncommitted_async_buffers.emplace_back(download_map); | 696 | uncommitted_async_buffers.emplace_back(download_map); |
| 690 | } | 697 | } |
| 698 | async_buffers.emplace_back(std::move(uncommitted_async_buffers)); | ||
| 699 | uncommitted_async_buffers.clear(); | ||
| 691 | } | 700 | } |
| 692 | committed_downloads.emplace_back(std::move(uncommitted_downloads)); | 701 | committed_downloads.emplace_back(std::move(uncommitted_downloads)); |
| 693 | async_buffers.emplace_back(std::move(uncommitted_async_buffers)); | ||
| 694 | uncommitted_async_buffers.clear(); | ||
| 695 | uncommitted_downloads.clear(); | 702 | uncommitted_downloads.clear(); |
| 696 | } | 703 | } |
| 697 | 704 | ||
| @@ -729,7 +736,7 @@ void TextureCache<P>::PopAsyncFlushes() { | |||
| 729 | } | 736 | } |
| 730 | } | 737 | } |
| 731 | for (auto& download_buffer : download_map) { | 738 | for (auto& download_buffer : download_map) { |
| 732 | runtime.FreeDeferredStagingBuffer(download_buffer); | 739 | async_buffers_death_ring.emplace_back(download_buffer); |
| 733 | } | 740 | } |
| 734 | committed_downloads.pop_front(); | 741 | committed_downloads.pop_front(); |
| 735 | async_buffers.pop_front(); | 742 | async_buffers.pop_front(); |
| @@ -748,7 +755,7 @@ void TextureCache<P>::PopAsyncFlushes() { | |||
| 748 | auto download_map = runtime.DownloadStagingBuffer(total_size_bytes); | 755 | auto download_map = runtime.DownloadStagingBuffer(total_size_bytes); |
| 749 | const size_t original_offset = download_map.offset; | 756 | const size_t original_offset = download_map.offset; |
| 750 | for (const PendingDownload& download_info : download_ids) { | 757 | for (const PendingDownload& download_info : download_ids) { |
| 751 | if (download_info.is_swizzle) { | 758 | if (!download_info.is_swizzle) { |
| 752 | continue; | 759 | continue; |
| 753 | } | 760 | } |
| 754 | Image& image = slot_images[download_info.object_id]; | 761 | Image& image = slot_images[download_info.object_id]; |
| @@ -761,7 +768,7 @@ void TextureCache<P>::PopAsyncFlushes() { | |||
| 761 | download_map.offset = original_offset; | 768 | download_map.offset = original_offset; |
| 762 | std::span<u8> download_span = download_map.mapped_span; | 769 | std::span<u8> download_span = download_map.mapped_span; |
| 763 | for (const PendingDownload& download_info : download_ids) { | 770 | for (const PendingDownload& download_info : download_ids) { |
| 764 | if (download_info.is_swizzle) { | 771 | if (!download_info.is_swizzle) { |
| 765 | continue; | 772 | continue; |
| 766 | } | 773 | } |
| 767 | const ImageBase& image = slot_images[download_info.object_id]; | 774 | const ImageBase& image = slot_images[download_info.object_id]; |
| @@ -887,10 +894,7 @@ void TextureCache<P>::DownloadImageIntoBuffer(typename TextureCache<P>::Image* i | |||
| 887 | }; | 894 | }; |
| 888 | image->DownloadMemory(buffers, buffer_offsets, copies); | 895 | image->DownloadMemory(buffers, buffer_offsets, copies); |
| 889 | } else { | 896 | } else { |
| 890 | std::array buffers{ | 897 | image->DownloadMemory(buffer, buffer_offset, copies); |
| 891 | buffer, | ||
| 892 | }; | ||
| 893 | image->DownloadMemory(buffers, buffer_offset, copies); | ||
| 894 | } | 898 | } |
| 895 | } | 899 | } |
| 896 | 900 | ||
diff --git a/src/video_core/texture_cache/texture_cache_base.h b/src/video_core/texture_cache/texture_cache_base.h index bb9ddb70e..758b7e212 100644 --- a/src/video_core/texture_cache/texture_cache_base.h +++ b/src/video_core/texture_cache/texture_cache_base.h | |||
| @@ -449,6 +449,7 @@ private: | |||
| 449 | std::deque<std::vector<PendingDownload>> committed_downloads; | 449 | std::deque<std::vector<PendingDownload>> committed_downloads; |
| 450 | std::vector<AsyncBuffer> uncommitted_async_buffers; | 450 | std::vector<AsyncBuffer> uncommitted_async_buffers; |
| 451 | std::deque<std::vector<AsyncBuffer>> async_buffers; | 451 | std::deque<std::vector<AsyncBuffer>> async_buffers; |
| 452 | std::deque<AsyncBuffer> async_buffers_death_ring; | ||
| 452 | 453 | ||
| 453 | struct LRUItemParams { | 454 | struct LRUItemParams { |
| 454 | using ObjectType = ImageId; | 455 | using ObjectType = ImageId; |