From 1e21bf5074a93577cb4cbd71e0387c7d3b3b1c1e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2020 04:39:27 +0200 Subject: [PATCH] Move defines to top --- retroarch.c | 133 +++++++++++++++++++++++++++------------------------- 1 file changed, 68 insertions(+), 65 deletions(-) diff --git a/retroarch.c b/retroarch.c index ab546d8054..25634e36e0 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1074,6 +1074,68 @@ static const camera_driver_t *camera_drivers[] = { #define DEFAULT_NETWORK_CMD_PORT 55355 #define STDIN_BUF_SIZE 4096 +#ifdef HAVE_THREADS +#define video_driver_is_threaded_internal() ((!video_driver_is_hw_context() && video_driver_threaded) ? true : false) +#else +#define video_driver_is_threaded_internal() (false) +#endif + +#ifdef HAVE_THREADS +#define video_driver_lock() \ + if (display_lock) \ + slock_lock(display_lock) + +#define video_driver_unlock() \ + if (display_lock) \ + slock_unlock(display_lock) + +#define video_driver_context_lock() \ + if (context_lock) \ + slock_lock(context_lock) + +#define video_driver_context_unlock() \ + if (context_lock) \ + slock_unlock(context_lock) + +#define video_driver_lock_free() \ + slock_free(display_lock); \ + slock_free(context_lock); \ + display_lock = NULL; \ + context_lock = NULL + +#define video_driver_threaded_lock(is_threaded) \ + if (is_threaded) \ + video_driver_lock() + +#define video_driver_threaded_unlock(is_threaded) \ + if (is_threaded) \ + video_driver_unlock() +#else +#define video_driver_lock() ((void)0) +#define video_driver_unlock() ((void)0) +#define video_driver_lock_free() ((void)0) +#define video_driver_threaded_lock(is_threaded) ((void)0) +#define video_driver_threaded_unlock(is_threaded) ((void)0) +#define video_driver_context_lock() ((void)0) +#define video_driver_context_unlock() ((void)0) +#endif + +#ifdef HAVE_THREADS +#define video_driver_get_ptr_internal(force) ((video_driver_is_threaded_internal() && !force) ? video_thread_get_ptr(NULL) : video_driver_data) +#else +#define video_driver_get_ptr_internal(force) (video_driver_data) +#endif + +#define video_driver_get_hw_context_internal() (&hw_render) + +#ifdef HAVE_THREADS +#define runloop_msg_queue_lock() slock_lock(_runloop_msg_queue_lock) +#define runloop_msg_queue_unlock() slock_unlock(_runloop_msg_queue_lock) +#else +#define runloop_msg_queue_lock() +#define runloop_msg_queue_unlock() +#endif + /* Descriptive names for options without short variant. * * Please keep the name in sync with the option name. @@ -3617,15 +3679,6 @@ void menu_driver_set_binding_state(bool on) { menu_driver_is_binding = on; } - -#endif - -#ifdef HAVE_THREADS -#define runloop_msg_queue_lock() slock_lock(_runloop_msg_queue_lock) -#define runloop_msg_queue_unlock() slock_unlock(_runloop_msg_queue_lock) -#else -#define runloop_msg_queue_lock() -#define runloop_msg_queue_unlock() #endif #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) @@ -3636,65 +3689,11 @@ static void retroarch_set_runtime_shader_preset(const char *arg) else runtime_shader_preset[0] = '\0'; } -#endif static void retroarch_unset_runtime_shader_preset(void) { -#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) runtime_shader_preset[0] = '\0'; -#endif } - -#ifdef HAVE_THREADS -#define video_driver_is_threaded_internal() ((!video_driver_is_hw_context() && video_driver_threaded) ? true : false) -#else -#define video_driver_is_threaded_internal() (false) -#endif - -#ifdef HAVE_THREADS -#define video_driver_lock() \ - if (display_lock) \ - slock_lock(display_lock) - -#define video_driver_unlock() \ - if (display_lock) \ - slock_unlock(display_lock) - -#define video_driver_context_lock() \ - if (context_lock) \ - slock_lock(context_lock) - -#define video_driver_context_unlock() \ - if (context_lock) \ - slock_unlock(context_lock) - -#define video_driver_lock_free() \ - slock_free(display_lock); \ - slock_free(context_lock); \ - display_lock = NULL; \ - context_lock = NULL - -#define video_driver_threaded_lock(is_threaded) \ - if (is_threaded) \ - video_driver_lock() - -#define video_driver_threaded_unlock(is_threaded) \ - if (is_threaded) \ - video_driver_unlock() -#else -#define video_driver_lock() ((void)0) -#define video_driver_unlock() ((void)0) -#define video_driver_lock_free() ((void)0) -#define video_driver_threaded_lock(is_threaded) ((void)0) -#define video_driver_threaded_unlock(is_threaded) ((void)0) -#define video_driver_context_lock() ((void)0) -#define video_driver_context_unlock() ((void)0) -#endif - -#ifdef HAVE_THREADS -#define video_driver_get_ptr_internal(force) ((video_driver_is_threaded_internal() && !force) ? video_thread_get_ptr(NULL) : video_driver_data) -#else -#define video_driver_get_ptr_internal(force) (video_driver_data) #endif #if defined(HAVE_RUNAHEAD) @@ -3724,8 +3723,6 @@ static char *strcpy_alloc_force(const char *src) #endif /* GLOBAL POINTER GETTERS */ -#define video_driver_get_hw_context_internal() (&hw_render) - struct retro_hw_render_callback *video_driver_get_hw_context(void) { return video_driver_get_hw_context_internal(); @@ -5916,7 +5913,9 @@ static void command_event_deinit_core(bool reinit) #ifdef HAVE_CONFIGFILE command_event_disable_overrides(); #endif +#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) retroarch_unset_runtime_shader_preset(); +#endif #ifdef HAVE_CONFIGFILE if ( runloop_remaps_core_active @@ -7168,7 +7167,9 @@ bool command_event(enum event_command cmd, void *data) #ifdef HAVE_CONFIGFILE command_event_disable_overrides(); #endif +#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) retroarch_unset_runtime_shader_preset(); +#endif if (cached_video_driver[0]) { @@ -27609,7 +27610,9 @@ bool retroarch_main_quit(void) #ifdef HAVE_CONFIGFILE command_event_disable_overrides(); #endif +#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) retroarch_unset_runtime_shader_preset(); +#endif #ifdef HAVE_CONFIGFILE if ( runloop_remaps_core_active