mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-26 15:45:42 +00:00
libretro: Recreate resources after context reset
This commit is contained in:
parent
32921acc5a
commit
df14519a97
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<HostDisplayTexture> 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,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue