diff options
| author | 2023-03-12 21:43:31 +0100 | |
|---|---|---|
| committer | 2023-04-29 00:18:21 +0200 | |
| commit | 3fbee093b2bf3b4c15dbc5bb48a3bc768ecedbc9 (patch) | |
| tree | 3910e8dad8f813ec61643f4d6c30097b548e60a1 /src/video_core/renderer_opengl | |
| parent | Merge pull request #10051 from liamwhite/surface-capabilities (diff) | |
| download | yuzu-3fbee093b2bf3b4c15dbc5bb48a3bc768ecedbc9.tar.gz yuzu-3fbee093b2bf3b4c15dbc5bb48a3bc768ecedbc9.tar.xz yuzu-3fbee093b2bf3b4c15dbc5bb48a3bc768ecedbc9.zip | |
TextureCache: refactor DMA downloads to allow multiple buffers.
Diffstat (limited to 'src/video_core/renderer_opengl')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 2 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_texture_cache.cpp | 41 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_texture_cache.h | 3 |
3 files changed, 26 insertions, 20 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 90e35e307..2de533584 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -1299,7 +1299,7 @@ bool AccelerateDMA::DmaBufferImageCopy(const Tegra::DMA::ImageCopy& copy_info, | |||
| 1299 | if constexpr (IS_IMAGE_UPLOAD) { | 1299 | if constexpr (IS_IMAGE_UPLOAD) { |
| 1300 | image->UploadMemory(buffer->Handle(), offset, copy_span); | 1300 | image->UploadMemory(buffer->Handle(), offset, copy_span); |
| 1301 | } else { | 1301 | } else { |
| 1302 | image->DownloadMemory(buffer->Handle(), offset, copy_span); | 1302 | texture_cache.DownloadImageIntoBuffer(image, buffer->Handle(), offset, copy_span); |
| 1303 | } | 1303 | } |
| 1304 | return true; | 1304 | return true; |
| 1305 | } | 1305 | } |
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cpp index 0b9c4a904..670d8cafd 100644 --- a/src/video_core/renderer_opengl/gl_texture_cache.cpp +++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp | |||
| @@ -801,32 +801,34 @@ 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(GLuint buffer_handle, size_t buffer_offset, | 804 | void Image::DownloadMemory(std::span<GLuint> buffer_handles, size_t buffer_offset, |
| 805 | std::span<const VideoCommon::BufferImageCopy> copies) { | 805 | std::span<const VideoCommon::BufferImageCopy> copies) { |
| 806 | const bool is_rescaled = True(flags & ImageFlagBits::Rescaled); | 806 | const bool is_rescaled = True(flags & ImageFlagBits::Rescaled); |
| 807 | if (is_rescaled) { | 807 | if (is_rescaled) { |
| 808 | ScaleDown(); | 808 | ScaleDown(); |
| 809 | } | 809 | } |
| 810 | glMemoryBarrier(GL_PIXEL_BUFFER_BARRIER_BIT); // TODO: Move this to its own API | 810 | glMemoryBarrier(GL_PIXEL_BUFFER_BARRIER_BIT); // TODO: Move this to its own API |
| 811 | glBindBuffer(GL_PIXEL_PACK_BUFFER, buffer_handle); | 811 | for (auto buffer_handle : buffer_handles) { |
| 812 | glPixelStorei(GL_PACK_ALIGNMENT, 1); | 812 | glBindBuffer(GL_PIXEL_PACK_BUFFER, buffer_handle); |
| 813 | glPixelStorei(GL_PACK_ALIGNMENT, 1); | ||
| 813 | 814 | ||
| 814 | u32 current_row_length = std::numeric_limits<u32>::max(); | 815 | u32 current_row_length = std::numeric_limits<u32>::max(); |
| 815 | u32 current_image_height = std::numeric_limits<u32>::max(); | 816 | u32 current_image_height = std::numeric_limits<u32>::max(); |
| 816 | 817 | ||
| 817 | for (const VideoCommon::BufferImageCopy& copy : copies) { | 818 | for (const VideoCommon::BufferImageCopy& copy : copies) { |
| 818 | if (copy.image_subresource.base_level >= gl_num_levels) { | 819 | if (copy.image_subresource.base_level >= gl_num_levels) { |
| 819 | continue; | 820 | continue; |
| 820 | } | 821 | } |
| 821 | if (current_row_length != copy.buffer_row_length) { | 822 | if (current_row_length != copy.buffer_row_length) { |
| 822 | current_row_length = copy.buffer_row_length; | 823 | current_row_length = copy.buffer_row_length; |
| 823 | glPixelStorei(GL_PACK_ROW_LENGTH, current_row_length); | 824 | glPixelStorei(GL_PACK_ROW_LENGTH, current_row_length); |
| 824 | } | 825 | } |
| 825 | if (current_image_height != copy.buffer_image_height) { | 826 | if (current_image_height != copy.buffer_image_height) { |
| 826 | current_image_height = copy.buffer_image_height; | 827 | current_image_height = copy.buffer_image_height; |
| 827 | glPixelStorei(GL_PACK_IMAGE_HEIGHT, current_image_height); | 828 | glPixelStorei(GL_PACK_IMAGE_HEIGHT, current_image_height); |
| 829 | } | ||
| 830 | CopyImageToBuffer(copy, buffer_offset); | ||
| 828 | } | 831 | } |
| 829 | CopyImageToBuffer(copy, buffer_offset); | ||
| 830 | } | 832 | } |
| 831 | if (is_rescaled) { | 833 | if (is_rescaled) { |
| 832 | ScaleUp(true); | 834 | ScaleUp(true); |
| @@ -835,7 +837,10 @@ void Image::DownloadMemory(GLuint buffer_handle, size_t buffer_offset, | |||
| 835 | 837 | ||
| 836 | void Image::DownloadMemory(ImageBufferMap& map, | 838 | void Image::DownloadMemory(ImageBufferMap& map, |
| 837 | std::span<const VideoCommon::BufferImageCopy> copies) { | 839 | std::span<const VideoCommon::BufferImageCopy> copies) { |
| 838 | DownloadMemory(map.buffer, map.offset, copies); | 840 | std::array buffers{ |
| 841 | map.buffer, | ||
| 842 | }; | ||
| 843 | DownloadMemory(buffers, map.offset, copies); | ||
| 839 | } | 844 | } |
| 840 | 845 | ||
| 841 | GLuint Image::StorageHandle() noexcept { | 846 | 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 911e4607a..67d6910b4 100644 --- a/src/video_core/renderer_opengl/gl_texture_cache.h +++ b/src/video_core/renderer_opengl/gl_texture_cache.h | |||
| @@ -212,7 +212,7 @@ 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(GLuint buffer_handle, size_t buffer_offset, | 215 | void DownloadMemory(std::span<GLuint> buffer_handle, size_t buffer_offset, |
| 216 | std::span<const VideoCommon::BufferImageCopy> copies); | 216 | std::span<const VideoCommon::BufferImageCopy> copies); |
| 217 | 217 | ||
| 218 | void DownloadMemory(ImageBufferMap& map, std::span<const VideoCommon::BufferImageCopy> copies); | 218 | void DownloadMemory(ImageBufferMap& map, std::span<const VideoCommon::BufferImageCopy> copies); |
| @@ -376,6 +376,7 @@ struct TextureCacheParams { | |||
| 376 | using Sampler = OpenGL::Sampler; | 376 | using Sampler = OpenGL::Sampler; |
| 377 | using Framebuffer = OpenGL::Framebuffer; | 377 | using Framebuffer = OpenGL::Framebuffer; |
| 378 | using AsyncBuffer = u32; | 378 | using AsyncBuffer = u32; |
| 379 | using BufferType = GLuint; | ||
| 379 | }; | 380 | }; |
| 380 | 381 | ||
| 381 | using TextureCache = VideoCommon::TextureCache<TextureCacheParams>; | 382 | using TextureCache = VideoCommon::TextureCache<TextureCacheParams>; |