summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2018-10-05 23:09:01 -0400
committerGravatar bunnei2018-10-06 03:20:04 -0400
commit749aef3dd0ccba7104ac630a59f01fa369c3581d (patch)
tree91459ac0275a9d5bd6e09784dc2690a2f4dadc69 /src
parentMerge pull request #1449 from lioncash/link (diff)
downloadyuzu-749aef3dd0ccba7104ac630a59f01fa369c3581d.tar.gz
yuzu-749aef3dd0ccba7104ac630a59f01fa369c3581d.tar.xz
yuzu-749aef3dd0ccba7104ac630a59f01fa369c3581d.zip
gl_rasterizer_cache: Implement a simpler surface copy using glCopyImageSubData.
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
index ce967c4d6..5fe6befe1 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
@@ -559,6 +559,18 @@ static bool BlitSurface(const Surface& src_surface, const Surface& dst_surface,
559 return true; 559 return true;
560} 560}
561 561
562static void FastCopySurface(const Surface& src_surface, const Surface& dst_surface) {
563 const auto& src_params{src_surface->GetSurfaceParams()};
564 const auto& dst_params{dst_surface->GetSurfaceParams()};
565
566 const u32 width{std::min(src_params.width, dst_params.width)};
567 const u32 height{std::min(src_params.height, dst_params.height)};
568
569 glCopyImageSubData(src_surface->Texture().handle, SurfaceTargetToGL(src_params.target), 0, 0, 0,
570 0, dst_surface->Texture().handle, SurfaceTargetToGL(dst_params.target), 0, 0,
571 0, 0, width, height, 1);
572}
573
562static void CopySurface(const Surface& src_surface, const Surface& dst_surface, 574static void CopySurface(const Surface& src_surface, const Surface& dst_surface,
563 GLuint copy_pbo_handle, GLenum src_attachment = 0, 575 GLuint copy_pbo_handle, GLenum src_attachment = 0,
564 GLenum dst_attachment = 0, std::size_t cubemap_face = 0) { 576 GLenum dst_attachment = 0, std::size_t cubemap_face = 0) {
@@ -1041,6 +1053,15 @@ Surface RasterizerCacheOpenGL::RecreateSurface(const Surface& old_surface,
1041 // Get a new surface with the new parameters, and blit the previous surface to it 1053 // Get a new surface with the new parameters, and blit the previous surface to it
1042 Surface new_surface{GetUncachedSurface(new_params)}; 1054 Surface new_surface{GetUncachedSurface(new_params)};
1043 1055
1056 // For compatible surfaces, we can just do fast glCopyImageSubData based copy
1057 if (old_params.target == new_params.target && old_params.type == new_params.type &&
1058 old_params.depth == new_params.depth && old_params.depth == 1 &&
1059 SurfaceParams::GetFormatBpp(old_params.pixel_format) ==
1060 SurfaceParams::GetFormatBpp(new_params.pixel_format)) {
1061 FastCopySurface(old_surface, new_surface);
1062 return new_surface;
1063 }
1064
1044 // If the format is the same, just do a framebuffer blit. This is significantly faster than 1065 // If the format is the same, just do a framebuffer blit. This is significantly faster than
1045 // using PBOs. The is also likely less accurate, as textures will be converted rather than 1066 // using PBOs. The is also likely less accurate, as textures will be converted rather than
1046 // reinterpreted. When use_accurate_framebuffers setting is enabled, perform a more accurate 1067 // reinterpreted. When use_accurate_framebuffers setting is enabled, perform a more accurate