mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-26 15:45:42 +00:00
System: Restore/reset state on recreating GPU/updating settings
Fixes display corruption on RetroArch when switching renderers.
This commit is contained in:
parent
359234080a
commit
e5c46a54b7
|
@ -487,7 +487,9 @@ void HostInterface::CheckForSettingsChanges(const Settings& old_settings)
|
|||
g_settings.display_crop_mode != old_settings.display_crop_mode ||
|
||||
g_settings.display_aspect_ratio != old_settings.display_aspect_ratio)
|
||||
{
|
||||
g_gpu->RestoreGraphicsAPIState();
|
||||
g_gpu->UpdateSettings();
|
||||
g_gpu->ResetGraphicsAPIState();
|
||||
}
|
||||
|
||||
if (g_settings.gpu_pgxp_enable != old_settings.gpu_pgxp_enable ||
|
||||
|
@ -662,7 +664,11 @@ void HostInterface::ModifyResolutionScale(s32 increment)
|
|||
GPU::VRAM_HEIGHT * g_settings.gpu_resolution_scale);
|
||||
|
||||
if (!System::IsShutdown())
|
||||
{
|
||||
g_gpu->RestoreGraphicsAPIState();
|
||||
g_gpu->UpdateSettings();
|
||||
g_gpu->ResetGraphicsAPIState();
|
||||
}
|
||||
}
|
||||
|
||||
void HostInterface::UpdateSoftwareCursor()
|
||||
|
|
|
@ -222,6 +222,8 @@ ConsoleRegion GetConsoleRegionForDiscRegion(DiscRegion region)
|
|||
|
||||
bool RecreateGPU(GPURenderer renderer)
|
||||
{
|
||||
g_gpu->RestoreGraphicsAPIState();
|
||||
|
||||
// save current state
|
||||
std::unique_ptr<ByteStream> state_stream = ByteStream_CreateGrowableMemoryStream();
|
||||
StateWrapper sw(state_stream.get(), StateWrapper::Mode::Write);
|
||||
|
@ -229,6 +231,8 @@ bool RecreateGPU(GPURenderer renderer)
|
|||
if (!state_valid)
|
||||
Log_ErrorPrintf("Failed to save old GPU state when switching renderers");
|
||||
|
||||
g_gpu->ResetGraphicsAPIState();
|
||||
|
||||
// create new renderer
|
||||
g_gpu.reset();
|
||||
if (!CreateGPU(renderer))
|
||||
|
@ -241,8 +245,10 @@ bool RecreateGPU(GPURenderer renderer)
|
|||
{
|
||||
state_stream->SeekAbsolute(0);
|
||||
sw.SetMode(StateWrapper::Mode::Read);
|
||||
g_gpu->RestoreGraphicsAPIState();
|
||||
g_gpu->DoState(sw);
|
||||
TimingEvents::DoState(sw, TimingEvents::GetGlobalTickCounter());
|
||||
g_gpu->ResetGraphicsAPIState();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue