mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-29 17:15:40 +00:00
Frontend: Add toggle for software rendering
This commit is contained in:
parent
d1be9460b9
commit
12ce777e30
|
@ -1,14 +1,14 @@
|
|||
#pragma once
|
||||
#include "types.h"
|
||||
|
||||
enum class GPURenderer
|
||||
{
|
||||
HardwareOpenGL,
|
||||
Software
|
||||
};
|
||||
|
||||
struct Settings
|
||||
{
|
||||
enum class GPURenderer
|
||||
{
|
||||
HardwareOpenGL,
|
||||
Software
|
||||
};
|
||||
|
||||
Settings();
|
||||
|
||||
bool start_paused = false;
|
||||
|
|
|
@ -108,11 +108,11 @@ bool System::CreateGPU()
|
|||
{
|
||||
switch (m_settings.gpu_renderer)
|
||||
{
|
||||
case GPURenderer::HardwareOpenGL:
|
||||
case Settings::GPURenderer::HardwareOpenGL:
|
||||
m_gpu = GPU::CreateHardwareOpenGLRenderer();
|
||||
break;
|
||||
|
||||
case GPURenderer::Software:
|
||||
case Settings::GPURenderer::Software:
|
||||
default:
|
||||
m_gpu = GPU::CreateSoftwareRenderer();
|
||||
break;
|
||||
|
@ -122,7 +122,7 @@ bool System::CreateGPU()
|
|||
{
|
||||
Log_ErrorPrintf("Failed to initialize GPU, falling back to software");
|
||||
m_gpu.reset();
|
||||
m_settings.gpu_renderer = GPURenderer::Software;
|
||||
m_settings.gpu_renderer = Settings::GPURenderer::Software;
|
||||
m_gpu = GPU::CreateSoftwareRenderer();
|
||||
if (!m_gpu->Initialize(this, m_dma.get(), m_interrupt_controller.get(), m_timers.get()))
|
||||
return false;
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
#include <nfd.h>
|
||||
Log_SetChannel(SDLInterface);
|
||||
|
||||
static constexpr std::array<std::pair<GPURenderer, const char*>, 2> s_gpu_renderer_names = {
|
||||
{{GPURenderer::HardwareOpenGL, "Hardware (OpenGL)"}, {GPURenderer::Software, "Software"}}};
|
||||
static constexpr std::array<std::pair<Settings::GPURenderer, const char*>, 2> s_gpu_renderer_names = {
|
||||
{{Settings::GPURenderer::HardwareOpenGL, "Hardware (OpenGL)"}, {Settings::GPURenderer::Software, "Software"}}};
|
||||
|
||||
SDLInterface::SDLInterface() = default;
|
||||
|
||||
|
@ -596,6 +596,14 @@ void SDLInterface::HandleSDLKeyEvent(const SDL_Event* event)
|
|||
DoFrameStep();
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_SCANCODE_PAGEUP:
|
||||
case SDL_SCANCODE_PAGEDOWN:
|
||||
{
|
||||
if (pressed)
|
||||
DoToggleSoftwareRendering();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -785,7 +793,7 @@ void SDLInterface::DrawMainMenuBar()
|
|||
{
|
||||
if (ImGui::BeginMenu("Renderer"))
|
||||
{
|
||||
const GPURenderer current = m_system->GetSettings().gpu_renderer;
|
||||
const Settings::GPURenderer current = m_system->GetSettings().gpu_renderer;
|
||||
for (const auto& it : s_gpu_renderer_names)
|
||||
{
|
||||
if (ImGui::MenuItem(it.second, nullptr, current == it.first))
|
||||
|
@ -1187,6 +1195,26 @@ void SDLInterface::DoFrameStep()
|
|||
m_paused = false;
|
||||
}
|
||||
|
||||
void SDLInterface::DoToggleSoftwareRendering()
|
||||
{
|
||||
if (!m_system)
|
||||
return;
|
||||
|
||||
auto& settings = m_system->GetSettings();
|
||||
if (settings.gpu_renderer != Settings::GPURenderer::Software)
|
||||
{
|
||||
settings.gpu_renderer = Settings::GPURenderer::Software;
|
||||
AddOSDMessage("Switched to software GPU renderer.");
|
||||
}
|
||||
else
|
||||
{
|
||||
settings.gpu_renderer = Settings::GPURenderer::HardwareOpenGL;
|
||||
AddOSDMessage("Switched to hardware GPU renderer.");
|
||||
}
|
||||
|
||||
m_system->RecreateGPU();
|
||||
}
|
||||
|
||||
void SDLInterface::Run()
|
||||
{
|
||||
m_audio_stream->PauseOutput(false);
|
||||
|
|
|
@ -74,6 +74,7 @@ private:
|
|||
void DoSaveState(u32 index);
|
||||
void DoTogglePause();
|
||||
void DoFrameStep();
|
||||
void DoToggleSoftwareRendering();
|
||||
|
||||
void HandleSDLEvent(const SDL_Event* event);
|
||||
void HandleSDLKeyEvent(const SDL_Event* event);
|
||||
|
|
Loading…
Reference in a new issue