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