From b2faa299d5890a65ff979fcb379d2b20d0ca36fc Mon Sep 17 00:00:00 2001 From: Eric Warmenhoven Date: Tue, 7 Apr 2026 14:48:49 -0400 Subject: [PATCH] libretro: fix linker error with tests --- src/citra_libretro/citra_libretro.cpp | 26 +---------------------- src/citra_libretro/environment.cpp | 30 +++++++++++++++++++++++++++ src/citra_libretro/environment.h | 3 +++ 3 files changed, 34 insertions(+), 25 deletions(-) diff --git a/src/citra_libretro/citra_libretro.cpp b/src/citra_libretro/citra_libretro.cpp index 9263fc46b..c93931196 100644 --- a/src/citra_libretro/citra_libretro.cpp +++ b/src/citra_libretro/citra_libretro.cpp @@ -105,31 +105,6 @@ unsigned retro_api_version() { return RETRO_API_VERSION; } -void LibRetro::OnConfigureEnvironment() { - -#ifdef HAVE_LIBRETRO_VFS - struct retro_vfs_interface_info vfs_iface_info{1, nullptr}; - LibRetro::SetVFSCallback(&vfs_iface_info); -#endif - - LibRetro::RegisterCoreOptions(); - - static const struct retro_controller_description controllers[] = { - {"Nintendo 3DS", RETRO_DEVICE_JOYPAD}, - }; - - static const struct retro_controller_info ports[] = { - {controllers, 1}, - {nullptr, 0}, - }; - - LibRetro::SetControllerInfo(ports); -} - -uintptr_t LibRetro::GetFramebuffer() { - return emu_instance->hw_render.get_current_framebuffer(); -} - /** * Updates Citra's settings with Libretro's. */ @@ -598,6 +573,7 @@ bool retro_load_game(const struct retro_game_info* info) { LibRetro::DisplayMessage("Failed to set HW renderer"); return false; } + LibRetro::SetFramebufferCallback(emu_instance->hw_render.get_current_framebuffer); #endif break; case Settings::GraphicsAPI::Vulkan: diff --git a/src/citra_libretro/environment.cpp b/src/citra_libretro/environment.cpp index c3deddacc..03bf51053 100644 --- a/src/citra_libretro/environment.cpp +++ b/src/citra_libretro/environment.cpp @@ -8,6 +8,7 @@ #include "audio_core/libretro_sink.h" #include "common/scm_rev.h" #include "core/3ds.h" +#include "core_settings.h" #include "emu_window/libretro_window.h" #include "environment.h" @@ -26,6 +27,7 @@ static retro_audio_sample_batch_t audio_batch_cb; static retro_environment_t environ_cb; static retro_input_poll_t input_poll_cb; static retro_input_state_t input_state_cb; +static retro_hw_get_current_framebuffer_t framebuffer_cb; } // namespace @@ -232,6 +234,34 @@ bool CanUseJIT() { } #endif +void OnConfigureEnvironment() { +#ifdef HAVE_LIBRETRO_VFS + struct retro_vfs_interface_info vfs_iface_info{1, nullptr}; + SetVFSCallback(&vfs_iface_info); +#endif + + RegisterCoreOptions(); + + static const struct retro_controller_description controllers[] = { + {"Nintendo 3DS", RETRO_DEVICE_JOYPAD}, + }; + + static const struct retro_controller_info ports[] = { + {controllers, 1}, + {nullptr, 0}, + }; + + SetControllerInfo(ports); +} + +void SetFramebufferCallback(retro_hw_get_current_framebuffer_t cb) { + framebuffer_cb = cb; +} + +uintptr_t GetFramebuffer() { + return framebuffer_cb ? framebuffer_cb() : 0; +} + }; // namespace LibRetro void retro_get_system_info(struct retro_system_info* info) { diff --git a/src/citra_libretro/environment.h b/src/citra_libretro/environment.h index 2b84d8b85..18f2b04bd 100644 --- a/src/citra_libretro/environment.h +++ b/src/citra_libretro/environment.h @@ -109,6 +109,9 @@ bool HasUpdatedConfig(); /// Returns the current framebuffer. uintptr_t GetFramebuffer(); +/// Sets the callback used by GetFramebuffer(). +void SetFramebufferCallback(retro_hw_get_current_framebuffer_t cb); + /// Tells the frontend that we are done. bool Shutdown();