GPU: Fix crash when toggling software renderer

This commit is contained in:
Stenzek 2024-11-26 12:58:12 +10:00
parent 57595c47af
commit 5fd79254bd
No known key found for this signature in database
4 changed files with 11 additions and 19 deletions

View File

@ -186,8 +186,8 @@ public:
float ComputeDisplayAspectRatio() const;
float ComputeAspectRatioCorrection() const;
static std::unique_ptr<GPU> CreateHardwareRenderer(Error* error);
static std::unique_ptr<GPU> CreateSoftwareRenderer(Error* error);
static std::unique_ptr<GPU> CreateHardwareRenderer();
static std::unique_ptr<GPU> CreateSoftwareRenderer();
// Converts window coordinates into horizontal ticks and scanlines. Returns false if out of range. Used for lightguns.
void ConvertScreenCoordinatesToDisplayCoordinates(float window_x, float window_y, float* display_x,

View File

@ -4265,11 +4265,7 @@ void GPU_HW::DrawRendererStats()
}
}
std::unique_ptr<GPU> GPU::CreateHardwareRenderer(Error* error)
std::unique_ptr<GPU> GPU::CreateHardwareRenderer()
{
std::unique_ptr<GPU_HW> gpu(std::make_unique<GPU_HW>());
if (!gpu->Initialize(error))
gpu.reset();
return gpu;
return std::make_unique<GPU_HW>();
}

View File

@ -824,11 +824,7 @@ void GPU_SW::UpdateCLUT(GPUTexturePaletteReg reg, bool clut_is_8bit)
m_backend.PushCommand(cmd);
}
std::unique_ptr<GPU> GPU::CreateSoftwareRenderer(Error* error)
std::unique_ptr<GPU> GPU::CreateSoftwareRenderer()
{
std::unique_ptr<GPU_SW> gpu(std::make_unique<GPU_SW>());
if (!gpu->Initialize(error))
gpu.reset();
return gpu;
return std::make_unique<GPU_SW>();
}

View File

@ -2432,11 +2432,11 @@ bool System::CreateGPU(GPURenderer renderer, bool is_switching, bool fullscreen,
}
if (renderer == GPURenderer::Software)
g_gpu = GPU::CreateSoftwareRenderer(error);
g_gpu = GPU::CreateSoftwareRenderer();
else
g_gpu = GPU::CreateHardwareRenderer(error);
g_gpu = GPU::CreateHardwareRenderer();
if (!g_gpu)
if (!g_gpu->Initialize(error))
{
ERROR_LOG("Failed to initialize {} renderer, falling back to software renderer",
Settings::GetRendererName(renderer));
@ -2445,8 +2445,8 @@ bool System::CreateGPU(GPURenderer renderer, bool is_switching, bool fullscreen,
Settings::GetRendererName(renderer)),
Host::OSD_CRITICAL_ERROR_DURATION);
g_gpu.reset();
g_gpu = GPU::CreateSoftwareRenderer(error);
if (!g_gpu)
g_gpu = GPU::CreateSoftwareRenderer();
if (!g_gpu->Initialize(error))
{
ERROR_LOG("Failed to create fallback software renderer.");
if (!s_state.keep_gpu_device_on_shutdown)