mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-26 15:45:42 +00:00
GPU/HW: Don't crash when switching to incompatible renderer
This commit is contained in:
parent
a397979d72
commit
5d26c2177f
|
@ -20,17 +20,17 @@ GPU_HW_D3D11::~GPU_HW_D3D11()
|
||||||
bool GPU_HW_D3D11::Initialize(HostDisplay* host_display, System* system, DMA* dma,
|
bool GPU_HW_D3D11::Initialize(HostDisplay* host_display, System* system, DMA* dma,
|
||||||
InterruptController* interrupt_controller, Timers* timers)
|
InterruptController* interrupt_controller, Timers* timers)
|
||||||
{
|
{
|
||||||
SetCapabilities();
|
|
||||||
|
|
||||||
if (!GPU_HW::Initialize(host_display, system, dma, interrupt_controller, timers))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (host_display->GetRenderAPI() != HostDisplay::RenderAPI::D3D11)
|
if (host_display->GetRenderAPI() != HostDisplay::RenderAPI::D3D11)
|
||||||
{
|
{
|
||||||
Log_ErrorPrintf("Host render API is incompatible");
|
Log_ErrorPrintf("Host render API is incompatible");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetCapabilities();
|
||||||
|
|
||||||
|
if (!GPU_HW::Initialize(host_display, system, dma, interrupt_controller, timers))
|
||||||
|
return false;
|
||||||
|
|
||||||
m_device = static_cast<ID3D11Device*>(host_display->GetHostRenderDevice());
|
m_device = static_cast<ID3D11Device*>(host_display->GetHostRenderDevice());
|
||||||
m_context = static_cast<ID3D11DeviceContext*>(host_display->GetHostRenderContext());
|
m_context = static_cast<ID3D11DeviceContext*>(host_display->GetHostRenderContext());
|
||||||
if (!m_device || !m_context)
|
if (!m_device || !m_context)
|
||||||
|
|
|
@ -19,17 +19,17 @@ GPU_HW_OpenGL::~GPU_HW_OpenGL()
|
||||||
bool GPU_HW_OpenGL::Initialize(HostDisplay* host_display, System* system, DMA* dma,
|
bool GPU_HW_OpenGL::Initialize(HostDisplay* host_display, System* system, DMA* dma,
|
||||||
InterruptController* interrupt_controller, Timers* timers)
|
InterruptController* interrupt_controller, Timers* timers)
|
||||||
{
|
{
|
||||||
SetCapabilities();
|
if (host_display->GetRenderAPI() != HostDisplay::RenderAPI::OpenGL)
|
||||||
|
|
||||||
if (!GPU_HW::Initialize(host_display, system, dma, interrupt_controller, timers))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (m_host_display->GetRenderAPI() != HostDisplay::RenderAPI::OpenGL)
|
|
||||||
{
|
{
|
||||||
Log_ErrorPrintf("Host render API type is incompatible");
|
Log_ErrorPrintf("Host render API type is incompatible");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetCapabilities();
|
||||||
|
|
||||||
|
if (!GPU_HW::Initialize(host_display, system, dma, interrupt_controller, timers))
|
||||||
|
return false;
|
||||||
|
|
||||||
CreateFramebuffer();
|
CreateFramebuffer();
|
||||||
CreateVertexBuffer();
|
CreateVertexBuffer();
|
||||||
CreateUniformBuffer();
|
CreateUniformBuffer();
|
||||||
|
|
|
@ -113,9 +113,11 @@ bool System::CreateGPU()
|
||||||
m_gpu = GPU::CreateHardwareOpenGLRenderer();
|
m_gpu = GPU::CreateHardwareOpenGLRenderer();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
case Settings::GPURenderer::HardwareD3D11:
|
case Settings::GPURenderer::HardwareD3D11:
|
||||||
m_gpu = GPU::CreateHardwareD3D11Renderer();
|
m_gpu = GPU::CreateHardwareD3D11Renderer();
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
case Settings::GPURenderer::Software:
|
case Settings::GPURenderer::Software:
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -71,7 +71,7 @@ bool SDLHostInterface::CreateSDLWindow()
|
||||||
|
|
||||||
bool SDLHostInterface::CreateDisplay()
|
bool SDLHostInterface::CreateDisplay()
|
||||||
{
|
{
|
||||||
#ifdef Y_PLATFORM_WINDOWS
|
#ifdef WIN32
|
||||||
m_display = UseOpenGLRenderer() ? OpenGLHostDisplay::Create(m_window) : D3D11HostDisplay::Create(m_window);
|
m_display = UseOpenGLRenderer() ? OpenGLHostDisplay::Create(m_window) : D3D11HostDisplay::Create(m_window);
|
||||||
#else
|
#else
|
||||||
m_display = OpenGLHostDisplay::Create(m_window);
|
m_display = OpenGLHostDisplay::Create(m_window);
|
||||||
|
|
|
@ -50,7 +50,7 @@ private:
|
||||||
|
|
||||||
bool HasSystem() const { return static_cast<bool>(m_system); }
|
bool HasSystem() const { return static_cast<bool>(m_system); }
|
||||||
|
|
||||||
#ifdef Y_PLATFORM_WINDOWS
|
#ifdef WIN32
|
||||||
bool UseOpenGLRenderer() const { return m_settings.gpu_renderer == Settings::GPURenderer::HardwareOpenGL; }
|
bool UseOpenGLRenderer() const { return m_settings.gpu_renderer == Settings::GPURenderer::HardwareOpenGL; }
|
||||||
#else
|
#else
|
||||||
bool UseOpenGLRenderer() const { return true; }
|
bool UseOpenGLRenderer() const { return true; }
|
||||||
|
|
Loading…
Reference in a new issue