GPUThread: Shutdown instead of panicing on switch failure

This commit is contained in:
Stenzek 2025-01-21 20:12:38 +10:00
parent 9c4b2112ae
commit 080eccd8fc
No known key found for this signature in database
1 changed files with 14 additions and 4 deletions

View File

@ -820,11 +820,11 @@ void GPUThread::ReconfigureOnThread(GPUThreadReconfigureCommand* cmd)
return;
}
// TODO: Make this suck less.
g_gpu_settings = g_settings;
// Readback old VRAM for hardware renderers.
if (s_state.gpu_backend && cmd->renderer.has_value() && cmd->upload_vram)
const bool had_renderer = static_cast<bool>(s_state.gpu_backend);
if (had_renderer && cmd->renderer.has_value() && cmd->upload_vram)
{
GPUBackendReadVRAMCommand read_cmd;
read_cmd.type = GPUBackendCommandType::ReadVRAM;
@ -878,8 +878,18 @@ void GPUThread::ReconfigureOnThread(GPUThreadReconfigureCommand* cmd)
// Do we want a renderer?
if (!(*cmd->out_result = CreateGPUBackendOnThread(cmd->renderer.value(), cmd->upload_vram, cmd->error_ptr)))
{
// No point keeping the presenter around.
DestroyGPUPresenterOnThread();
// If we had a renderer, it means it was a switch, and we need to bail out the thread.
if (had_renderer)
{
GPUThread::ReportFatalErrorAndShutdown("Failed to switch GPU backend.");
*cmd->out_result = true;
}
else
{
// No point keeping the presenter around.
DestroyGPUBackendOnThread();
DestroyGPUPresenterOnThread();
}
}
}
else if (s_state.requested_fullscreen_ui)