diff options
| author | 2018-11-08 13:58:53 +0100 | |
|---|---|---|
| committer | 2018-11-08 16:50:09 +0100 | |
| commit | e2bf581e3a0caa8af3e6a312bf68e56366ba0fb0 (patch) | |
| tree | d873e98ba6b2b9ed4288f40d6f91e7fb29a44388 /src | |
| parent | Merge pull request #1630 from bunnei/fix-mapbufferex (diff) | |
| download | yuzu-e2bf581e3a0caa8af3e6a312bf68e56366ba0fb0.tar.gz yuzu-e2bf581e3a0caa8af3e6a312bf68e56366ba0fb0.tar.xz yuzu-e2bf581e3a0caa8af3e6a312bf68e56366ba0fb0.zip | |
gl_rasterizer_cache: Remove unnecessary memory allocation and copy in CopySurface
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 49d63e6f3..ada2e3859 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | |||
| @@ -708,18 +708,18 @@ static void FastCopySurface(const Surface& src_surface, const Surface& dst_surfa | |||
| 708 | 708 | ||
| 709 | MICROPROFILE_DEFINE(OpenGL_CopySurface, "OpenGL", "CopySurface", MP_RGB(128, 192, 64)); | 709 | MICROPROFILE_DEFINE(OpenGL_CopySurface, "OpenGL", "CopySurface", MP_RGB(128, 192, 64)); |
| 710 | static void CopySurface(const Surface& src_surface, const Surface& dst_surface, | 710 | static void CopySurface(const Surface& src_surface, const Surface& dst_surface, |
| 711 | GLuint copy_pbo_handle, GLenum src_attachment = 0, | 711 | const GLuint copy_pbo_handle, const GLenum src_attachment = 0, |
| 712 | GLenum dst_attachment = 0, std::size_t cubemap_face = 0) { | 712 | const GLenum dst_attachment = 0, const std::size_t cubemap_face = 0) { |
| 713 | MICROPROFILE_SCOPE(OpenGL_CopySurface); | 713 | MICROPROFILE_SCOPE(OpenGL_CopySurface); |
| 714 | ASSERT_MSG(dst_attachment == 0, "Unimplemented"); | 714 | ASSERT_MSG(dst_attachment == 0, "Unimplemented"); |
| 715 | 715 | ||
| 716 | const auto& src_params{src_surface->GetSurfaceParams()}; | 716 | const auto& src_params{src_surface->GetSurfaceParams()}; |
| 717 | const auto& dst_params{dst_surface->GetSurfaceParams()}; | 717 | const auto& dst_params{dst_surface->GetSurfaceParams()}; |
| 718 | 718 | ||
| 719 | auto source_format = GetFormatTuple(src_params.pixel_format, src_params.component_type); | 719 | const auto source_format = GetFormatTuple(src_params.pixel_format, src_params.component_type); |
| 720 | auto dest_format = GetFormatTuple(dst_params.pixel_format, dst_params.component_type); | 720 | const auto dest_format = GetFormatTuple(dst_params.pixel_format, dst_params.component_type); |
| 721 | 721 | ||
| 722 | std::size_t buffer_size = std::max(src_params.size_in_bytes, dst_params.size_in_bytes); | 722 | const std::size_t buffer_size = std::max(src_params.size_in_bytes, dst_params.size_in_bytes); |
| 723 | 723 | ||
| 724 | glBindBuffer(GL_PIXEL_PACK_BUFFER, copy_pbo_handle); | 724 | glBindBuffer(GL_PIXEL_PACK_BUFFER, copy_pbo_handle); |
| 725 | glBufferData(GL_PIXEL_PACK_BUFFER, buffer_size, nullptr, GL_STREAM_DRAW_ARB); | 725 | glBufferData(GL_PIXEL_PACK_BUFFER, buffer_size, nullptr, GL_STREAM_DRAW_ARB); |
| @@ -743,13 +743,10 @@ static void CopySurface(const Surface& src_surface, const Surface& dst_surface, | |||
| 743 | LOG_DEBUG(HW_GPU, "Trying to upload extra texture data from the CPU during " | 743 | LOG_DEBUG(HW_GPU, "Trying to upload extra texture data from the CPU during " |
| 744 | "reinterpretation but the texture is tiled."); | 744 | "reinterpretation but the texture is tiled."); |
| 745 | } | 745 | } |
| 746 | std::size_t remaining_size = dst_params.size_in_bytes - src_params.size_in_bytes; | 746 | const std::size_t remaining_size = dst_params.size_in_bytes - src_params.size_in_bytes; |
| 747 | std::vector<u8> data(remaining_size); | ||
| 748 | std::memcpy(data.data(), Memory::GetPointer(dst_params.addr + src_params.size_in_bytes), | ||
| 749 | data.size()); | ||
| 750 | 747 | ||
| 751 | glBufferSubData(GL_PIXEL_PACK_BUFFER, src_params.size_in_bytes, remaining_size, | 748 | glBufferSubData(GL_PIXEL_PACK_BUFFER, src_params.size_in_bytes, remaining_size, |
| 752 | data.data()); | 749 | Memory::GetPointer(dst_params.addr + src_params.size_in_bytes)); |
| 753 | } | 750 | } |
| 754 | 751 | ||
| 755 | glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); | 752 | glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); |