diff --git a/src/core/host_display.h b/src/core/host_display.h index 95fb6c5c3..d6ab3bca7 100644 --- a/src/core/host_display.h +++ b/src/core/host_display.h @@ -59,6 +59,8 @@ public: virtual void DestroyRenderDevice() = 0; virtual void DestroyRenderSurface() = 0; virtual bool ChangeRenderWindow(const WindowInfo& wi) = 0; + virtual bool CreateResources() = 0; + virtual void DestroyResources() = 0; /// Call when the window size changes externally to recreate any resources. virtual void ResizeRenderWindow(s32 new_window_width, s32 new_window_height) = 0; diff --git a/src/duckstation-libretro/libretro_host_display.cpp b/src/duckstation-libretro/libretro_host_display.cpp index 86646f8dd..0bdabe75f 100644 --- a/src/duckstation-libretro/libretro_host_display.cpp +++ b/src/duckstation-libretro/libretro_host_display.cpp @@ -137,6 +137,13 @@ void LibretroHostDisplay::DestroyRenderDevice() {} void LibretroHostDisplay::DestroyRenderSurface() {} +bool LibretroHostDisplay::CreateResources() +{ + return true; +} + +void LibretroHostDisplay::DestroyResources() {} + bool LibretroHostDisplay::ChangeRenderWindow(const WindowInfo& wi) { m_window_info = wi; diff --git a/src/duckstation-libretro/libretro_host_display.h b/src/duckstation-libretro/libretro_host_display.h index 419377a62..03917a4ef 100644 --- a/src/duckstation-libretro/libretro_host_display.h +++ b/src/duckstation-libretro/libretro_host_display.h @@ -26,6 +26,9 @@ public: void ResizeRenderWindow(s32 new_window_width, s32 new_window_height) override; void DestroyRenderSurface() override; + bool CreateResources() override; + void DestroyResources() override; + std::unique_ptr CreateTexture(u32 width, u32 height, const void* data, u32 data_stride, bool dynamic) override; void UpdateTexture(HostDisplayTexture* texture, u32 x, u32 y, u32 width, u32 height, const void* data, diff --git a/src/duckstation-libretro/libretro_host_interface.cpp b/src/duckstation-libretro/libretro_host_interface.cpp index 52ec60a3d..c5b4ad2eb 100644 --- a/src/duckstation-libretro/libretro_host_interface.cpp +++ b/src/duckstation-libretro/libretro_host_interface.cpp @@ -935,6 +935,8 @@ void LibretroHostInterface::SwitchToHardwareRenderer() { Log_InfoPrintf("Using existing hardware display"); renderer = RenderAPIToRenderer(display->GetRenderAPI()); + if (!display->CreateResources()) + Panic("Failed to recreate resources after reinit"); } else { @@ -1013,6 +1015,7 @@ void LibretroHostInterface::SwitchToSoftwareRenderer() if (m_using_hardware_renderer) { m_hw_render_display = std::move(m_display); + m_hw_render_display->DestroyResources(); m_using_hardware_renderer = false; }