From b2de5945c42564c39416c8dd02f0a2a820f94f37 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Fri, 27 Nov 2020 01:39:18 +1000 Subject: [PATCH] libretro: Disable context caching It's completely broken in RetroArch, see https://github.com/libretro/RetroArch/issues/11623 --- .../libretro_d3d11_host_display.cpp | 2 +- .../libretro_host_interface.cpp | 22 +++++++++---------- .../libretro_opengl_host_display.cpp | 2 +- .../libretro_vulkan_host_display.cpp | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/duckstation-libretro/libretro_d3d11_host_display.cpp b/src/duckstation-libretro/libretro_d3d11_host_display.cpp index 2c2a8d8b4..741da2d11 100644 --- a/src/duckstation-libretro/libretro_d3d11_host_display.cpp +++ b/src/duckstation-libretro/libretro_d3d11_host_display.cpp @@ -21,7 +21,7 @@ void LibretroD3D11HostDisplay::SetVSync(bool enabled) bool LibretroD3D11HostDisplay::RequestHardwareRendererContext(retro_hw_render_callback* cb) { - cb->cache_context = true; + cb->cache_context = false; cb->bottom_left_origin = false; cb->context_type = RETRO_HW_CONTEXT_DIRECT3D; cb->version_major = 11; diff --git a/src/duckstation-libretro/libretro_host_interface.cpp b/src/duckstation-libretro/libretro_host_interface.cpp index bcab9298e..386dbdf97 100644 --- a/src/duckstation-libretro/libretro_host_interface.cpp +++ b/src/duckstation-libretro/libretro_host_interface.cpp @@ -865,16 +865,15 @@ void LibretroHostInterface::UpdateSettings() { ReportMessage("Resolution changed, updating system AV info..."); - // this will probably recreate the device... so save the state first by switching to software - if (m_using_hardware_renderer) - SwitchToSoftwareRenderer(); - UpdateSystemAVInfo(true); - if (!m_hw_render_callback_valid) - RequestHardwareRendererContext(); - else if (!m_using_hardware_renderer) - SwitchToHardwareRenderer(); + if (!g_settings.IsUsingSoftwareRenderer()) + { + if (!m_hw_render_callback_valid) + RequestHardwareRendererContext(); + else if (!m_using_hardware_renderer) + SwitchToHardwareRenderer(); + } // Don't let the base class mess with the GPU. old_settings.gpu_resolution_scale = g_settings.gpu_resolution_scale; @@ -1215,12 +1214,11 @@ void LibretroHostInterface::SwitchToHardwareRenderer() void LibretroHostInterface::HardwareRendererContextDestroy() { + Log_InfoPrintf("Hardware context destroyed"); + // switch back to software if (g_libretro_host_interface.m_using_hardware_renderer) - { - Log_InfoPrintf("Lost hardware renderer context, switching to software renderer"); g_libretro_host_interface.SwitchToSoftwareRenderer(); - } if (g_libretro_host_interface.m_hw_render_display) { @@ -1233,6 +1231,8 @@ void LibretroHostInterface::HardwareRendererContextDestroy() void LibretroHostInterface::SwitchToSoftwareRenderer() { + Log_InfoPrintf("Switching to software renderer"); + // keep the hw renderer around in case we need it later // but keep it active until we've recreated the GPU so we can save the state std::unique_ptr save_display; diff --git a/src/duckstation-libretro/libretro_opengl_host_display.cpp b/src/duckstation-libretro/libretro_opengl_host_display.cpp index fa819a86f..6415b1589 100644 --- a/src/duckstation-libretro/libretro_opengl_host_display.cpp +++ b/src/duckstation-libretro/libretro_opengl_host_display.cpp @@ -79,7 +79,7 @@ static bool TryESVersions(retro_hw_render_callback* cb) bool LibretroOpenGLHostDisplay::RequestHardwareRendererContext(retro_hw_render_callback* cb, bool prefer_gles) { // Prefer a desktop OpenGL context where possible. If we can't get this, try OpenGL ES. - cb->cache_context = true; + cb->cache_context = false; cb->bottom_left_origin = true; if (!prefer_gles) diff --git a/src/duckstation-libretro/libretro_vulkan_host_display.cpp b/src/duckstation-libretro/libretro_vulkan_host_display.cpp index 8af173c75..03697f30c 100644 --- a/src/duckstation-libretro/libretro_vulkan_host_display.cpp +++ b/src/duckstation-libretro/libretro_vulkan_host_display.cpp @@ -76,7 +76,7 @@ static retro_hw_render_context_negotiation_interface_vulkan s_vulkan_context_neg bool LibretroVulkanHostDisplay::RequestHardwareRendererContext(retro_hw_render_callback* cb) { - cb->cache_context = true; + cb->cache_context = false; cb->bottom_left_origin = false; cb->context_type = RETRO_HW_CONTEXT_VULKAN; return g_retro_environment_callback(RETRO_ENVIRONMENT_SET_HW_RENDER, cb) &&