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,
|
||||
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)
|
||||
{
|
||||
Log_ErrorPrintf("Host render API is incompatible");
|
||||
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_context = static_cast<ID3D11DeviceContext*>(host_display->GetHostRenderContext());
|
||||
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,
|
||||
InterruptController* interrupt_controller, Timers* timers)
|
||||
{
|
||||
SetCapabilities();
|
||||
|
||||
if (!GPU_HW::Initialize(host_display, system, dma, interrupt_controller, timers))
|
||||
return false;
|
||||
|
||||
if (m_host_display->GetRenderAPI() != HostDisplay::RenderAPI::OpenGL)
|
||||
if (host_display->GetRenderAPI() != HostDisplay::RenderAPI::OpenGL)
|
||||
{
|
||||
Log_ErrorPrintf("Host render API type is incompatible");
|
||||
return false;
|
||||
}
|
||||
|
||||
SetCapabilities();
|
||||
|
||||
if (!GPU_HW::Initialize(host_display, system, dma, interrupt_controller, timers))
|
||||
return false;
|
||||
|
||||
CreateFramebuffer();
|
||||
CreateVertexBuffer();
|
||||
CreateUniformBuffer();
|
||||
|
|
|
@ -113,9 +113,11 @@ bool System::CreateGPU()
|
|||
m_gpu = GPU::CreateHardwareOpenGLRenderer();
|
||||
break;
|
||||
|
||||
#ifdef WIN32
|
||||
case Settings::GPURenderer::HardwareD3D11:
|
||||
m_gpu = GPU::CreateHardwareD3D11Renderer();
|
||||
break;
|
||||
#endif
|
||||
|
||||
case Settings::GPURenderer::Software:
|
||||
default:
|
||||
|
|
|
@ -71,7 +71,7 @@ bool SDLHostInterface::CreateSDLWindow()
|
|||
|
||||
bool SDLHostInterface::CreateDisplay()
|
||||
{
|
||||
#ifdef Y_PLATFORM_WINDOWS
|
||||
#ifdef WIN32
|
||||
m_display = UseOpenGLRenderer() ? OpenGLHostDisplay::Create(m_window) : D3D11HostDisplay::Create(m_window);
|
||||
#else
|
||||
m_display = OpenGLHostDisplay::Create(m_window);
|
||||
|
|
|
@ -50,7 +50,7 @@ private:
|
|||
|
||||
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; }
|
||||
#else
|
||||
bool UseOpenGLRenderer() const { return true; }
|
||||
|
|
Loading…
Reference in New Issue