diff options
| author | 2018-11-13 18:58:12 -0800 | |
|---|---|---|
| committer | 2018-11-13 18:58:12 -0800 | |
| commit | 3bd503d59c971035ebfdb1077206aeb0a4e26fe1 (patch) | |
| tree | a5d05b562b280f0a8770760da0e113c5f0a3a0dd /src | |
| parent | Merge pull request #1686 from DarkLordZach/move-open-yuzu-folder (diff) | |
| parent | gl_rasterizer_cache: Remove unnecessary memory allocation and copy in CopySur... (diff) | |
| download | yuzu-3bd503d59c971035ebfdb1077206aeb0a4e26fe1.tar.gz yuzu-3bd503d59c971035ebfdb1077206aeb0a4e26fe1.tar.xz yuzu-3bd503d59c971035ebfdb1077206aeb0a4e26fe1.zip | |
Merge pull request #1662 from FreddyFunk/CopySurface-Optimization
gl_rasterizer_cache: CopySurface optimization
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 864f426f7..26711e6f7 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | |||
| @@ -715,18 +715,18 @@ static void FastCopySurface(const Surface& src_surface, const Surface& dst_surfa | |||
| 715 | 715 | ||
| 716 | MICROPROFILE_DEFINE(OpenGL_CopySurface, "OpenGL", "CopySurface", MP_RGB(128, 192, 64)); | 716 | MICROPROFILE_DEFINE(OpenGL_CopySurface, "OpenGL", "CopySurface", MP_RGB(128, 192, 64)); |
| 717 | static void CopySurface(const Surface& src_surface, const Surface& dst_surface, | 717 | static void CopySurface(const Surface& src_surface, const Surface& dst_surface, |
| 718 | GLuint copy_pbo_handle, GLenum src_attachment = 0, | 718 | const GLuint copy_pbo_handle, const GLenum src_attachment = 0, |
| 719 | GLenum dst_attachment = 0, std::size_t cubemap_face = 0) { | 719 | const GLenum dst_attachment = 0, const std::size_t cubemap_face = 0) { |
| 720 | MICROPROFILE_SCOPE(OpenGL_CopySurface); | 720 | MICROPROFILE_SCOPE(OpenGL_CopySurface); |
| 721 | ASSERT_MSG(dst_attachment == 0, "Unimplemented"); | 721 | ASSERT_MSG(dst_attachment == 0, "Unimplemented"); |
| 722 | 722 | ||
| 723 | const auto& src_params{src_surface->GetSurfaceParams()}; | 723 | const auto& src_params{src_surface->GetSurfaceParams()}; |
| 724 | const auto& dst_params{dst_surface->GetSurfaceParams()}; | 724 | const auto& dst_params{dst_surface->GetSurfaceParams()}; |
| 725 | 725 | ||
| 726 | auto source_format = GetFormatTuple(src_params.pixel_format, src_params.component_type); | 726 | const auto source_format = GetFormatTuple(src_params.pixel_format, src_params.component_type); |
| 727 | auto dest_format = GetFormatTuple(dst_params.pixel_format, dst_params.component_type); | 727 | const auto dest_format = GetFormatTuple(dst_params.pixel_format, dst_params.component_type); |
| 728 | 728 | ||
| 729 | std::size_t buffer_size = std::max(src_params.size_in_bytes, dst_params.size_in_bytes); | 729 | const std::size_t buffer_size = std::max(src_params.size_in_bytes, dst_params.size_in_bytes); |
| 730 | 730 | ||
| 731 | glBindBuffer(GL_PIXEL_PACK_BUFFER, copy_pbo_handle); | 731 | glBindBuffer(GL_PIXEL_PACK_BUFFER, copy_pbo_handle); |
| 732 | glBufferData(GL_PIXEL_PACK_BUFFER, buffer_size, nullptr, GL_STREAM_DRAW_ARB); | 732 | glBufferData(GL_PIXEL_PACK_BUFFER, buffer_size, nullptr, GL_STREAM_DRAW_ARB); |
| @@ -750,13 +750,10 @@ static void CopySurface(const Surface& src_surface, const Surface& dst_surface, | |||
| 750 | LOG_DEBUG(HW_GPU, "Trying to upload extra texture data from the CPU during " | 750 | LOG_DEBUG(HW_GPU, "Trying to upload extra texture data from the CPU during " |
| 751 | "reinterpretation but the texture is tiled."); | 751 | "reinterpretation but the texture is tiled."); |
| 752 | } | 752 | } |
| 753 | std::size_t remaining_size = dst_params.size_in_bytes - src_params.size_in_bytes; | 753 | const std::size_t remaining_size = dst_params.size_in_bytes - src_params.size_in_bytes; |
| 754 | std::vector<u8> data(remaining_size); | ||
| 755 | std::memcpy(data.data(), Memory::GetPointer(dst_params.addr + src_params.size_in_bytes), | ||
| 756 | data.size()); | ||
| 757 | 754 | ||
| 758 | glBufferSubData(GL_PIXEL_PACK_BUFFER, src_params.size_in_bytes, remaining_size, | 755 | glBufferSubData(GL_PIXEL_PACK_BUFFER, src_params.size_in_bytes, remaining_size, |
| 759 | data.data()); | 756 | Memory::GetPointer(dst_params.addr + src_params.size_in_bytes)); |
| 760 | } | 757 | } |
| 761 | 758 | ||
| 762 | glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); | 759 | glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); |