mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-11-30 11:54:17 +01:00
gl_rasterizer_cache: Blit when possible on RecreateSurface.
This commit is contained in:
parent
fee8bdd90c
commit
d65f079cc1
@ -780,7 +780,10 @@ Surface RasterizerCacheOpenGL::GetSurface(const SurfaceParams& params, bool pres
|
|||||||
} else if (preserve_contents) {
|
} else if (preserve_contents) {
|
||||||
// If surface parameters changed and we care about keeping the previous data, recreate
|
// If surface parameters changed and we care about keeping the previous data, recreate
|
||||||
// the surface from the old one
|
// the surface from the old one
|
||||||
return RecreateSurface(surface, params);
|
UnregisterSurface(surface);
|
||||||
|
Surface new_surface{RecreateSurface(surface, params)};
|
||||||
|
RegisterSurface(new_surface);
|
||||||
|
return new_surface;
|
||||||
} else {
|
} else {
|
||||||
// Delete the old surface before creating a new one to prevent collisions.
|
// Delete the old surface before creating a new one to prevent collisions.
|
||||||
UnregisterSurface(surface);
|
UnregisterSurface(surface);
|
||||||
@ -813,6 +816,14 @@ Surface RasterizerCacheOpenGL::RecreateSurface(const Surface& surface,
|
|||||||
// Create a new surface with the new parameters, and blit the previous surface to it
|
// Create a new surface with the new parameters, and blit the previous surface to it
|
||||||
Surface new_surface{std::make_shared<CachedSurface>(new_params)};
|
Surface new_surface{std::make_shared<CachedSurface>(new_params)};
|
||||||
|
|
||||||
|
// If format is unchanged, we can do a faster blit without reinterpreting pixel data
|
||||||
|
if (params.pixel_format == new_params.pixel_format) {
|
||||||
|
BlitTextures(surface->Texture().handle, params.GetRect(), new_surface->Texture().handle,
|
||||||
|
new_surface->GetSurfaceParams().GetRect(), params.type,
|
||||||
|
read_framebuffer.handle, draw_framebuffer.handle);
|
||||||
|
return new_surface;
|
||||||
|
}
|
||||||
|
|
||||||
auto source_format = GetFormatTuple(params.pixel_format, params.component_type);
|
auto source_format = GetFormatTuple(params.pixel_format, params.component_type);
|
||||||
auto dest_format = GetFormatTuple(new_params.pixel_format, new_params.component_type);
|
auto dest_format = GetFormatTuple(new_params.pixel_format, new_params.component_type);
|
||||||
|
|
||||||
@ -872,10 +883,6 @@ Surface RasterizerCacheOpenGL::RecreateSurface(const Surface& surface,
|
|||||||
|
|
||||||
pbo.Release();
|
pbo.Release();
|
||||||
|
|
||||||
// Update cache accordingly
|
|
||||||
UnregisterSurface(surface);
|
|
||||||
RegisterSurface(new_surface);
|
|
||||||
|
|
||||||
return new_surface;
|
return new_surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user