summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.cpp17
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.h3
2 files changed, 18 insertions, 2 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
index 1fddc1c26..0456472fd 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
@@ -1178,6 +1178,14 @@ void RasterizerCacheOpenGL::FermiCopySurface(
1178 FastCopySurface(GetSurface(src_params, true), GetSurface(dst_params, false)); 1178 FastCopySurface(GetSurface(src_params, true), GetSurface(dst_params, false));
1179} 1179}
1180 1180
1181void RasterizerCacheOpenGL::AccurateCopySurface(const Surface& src_surface,
1182 const Surface& dst_surface) {
1183 const auto& src_params{src_surface->GetSurfaceParams()};
1184 const auto& dst_params{dst_surface->GetSurfaceParams()};
1185 FlushRegion(src_params.addr, dst_params.size_in_bytes);
1186 LoadSurface(dst_surface);
1187}
1188
1181Surface RasterizerCacheOpenGL::RecreateSurface(const Surface& old_surface, 1189Surface RasterizerCacheOpenGL::RecreateSurface(const Surface& old_surface,
1182 const SurfaceParams& new_params) { 1190 const SurfaceParams& new_params) {
1183 // Verify surface is compatible for blitting 1191 // Verify surface is compatible for blitting
@@ -1186,6 +1194,12 @@ Surface RasterizerCacheOpenGL::RecreateSurface(const Surface& old_surface,
1186 // Get a new surface with the new parameters, and blit the previous surface to it 1194 // Get a new surface with the new parameters, and blit the previous surface to it
1187 Surface new_surface{GetUncachedSurface(new_params)}; 1195 Surface new_surface{GetUncachedSurface(new_params)};
1188 1196
1197 // With use_accurate_gpu_emulation enabled, do an accurate surface copy
1198 if (Settings::values.use_accurate_gpu_emulation) {
1199 AccurateCopySurface(old_surface, new_surface);
1200 return new_surface;
1201 }
1202
1189 // For compatible surfaces, we can just do fast glCopyImageSubData based copy 1203 // For compatible surfaces, we can just do fast glCopyImageSubData based copy
1190 if (old_params.target == new_params.target && old_params.type == new_params.type && 1204 if (old_params.target == new_params.target && old_params.type == new_params.type &&
1191 old_params.depth == new_params.depth && old_params.depth == 1 && 1205 old_params.depth == new_params.depth && old_params.depth == 1 &&
@@ -1200,8 +1214,7 @@ Surface RasterizerCacheOpenGL::RecreateSurface(const Surface& old_surface,
1200 // reinterpreted. When use_accurate_gpu_emulation setting is enabled, perform a more accurate 1214 // reinterpreted. When use_accurate_gpu_emulation setting is enabled, perform a more accurate
1201 // surface copy, where pixels are reinterpreted as a new format (without conversion). This 1215 // surface copy, where pixels are reinterpreted as a new format (without conversion). This
1202 // code path uses OpenGL PBOs and is quite slow. 1216 // code path uses OpenGL PBOs and is quite slow.
1203 const bool is_blit{old_params.pixel_format == new_params.pixel_format || 1217 const bool is_blit{old_params.pixel_format == new_params.pixel_format};
1204 !Settings::values.use_accurate_gpu_emulation};
1205 1218
1206 switch (new_params.target) { 1219 switch (new_params.target) {
1207 case SurfaceParams::SurfaceTarget::Texture2D: 1220 case SurfaceParams::SurfaceTarget::Texture2D:
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
index 77d925250..7c1cb72d0 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
@@ -899,6 +899,9 @@ private:
899 /// Tries to get a reserved surface for the specified parameters 899 /// Tries to get a reserved surface for the specified parameters
900 Surface TryGetReservedSurface(const SurfaceParams& params); 900 Surface TryGetReservedSurface(const SurfaceParams& params);
901 901
902 /// Performs a slow but accurate surface copy, flushing to RAM and reinterpreting the data
903 void AccurateCopySurface(const Surface& src_surface, const Surface& dst_surface);
904
902 /// The surface reserve is a "backup" cache, this is where we put unique surfaces that have 905 /// The surface reserve is a "backup" cache, this is where we put unique surfaces that have
903 /// previously been used. This is to prevent surfaces from being constantly created and 906 /// previously been used. This is to prevent surfaces from being constantly created and
904 /// destroyed when used with different surface parameters. 907 /// destroyed when used with different surface parameters.