mirror of
https://github.com/libretro/RetroArch.git
synced 2024-05-20 13:27:22 -04:00
Split up runahead into its own file(s) - runahead.c/runahead.h -
by Dwedit's request
This commit is contained in:
parent
ee6aa753c3
commit
f0c8008bda
|
@ -430,6 +430,7 @@ endif
|
||||||
|
|
||||||
ifeq ($(HAVE_RUNAHEAD), 1)
|
ifeq ($(HAVE_RUNAHEAD), 1)
|
||||||
DEFINES += -DHAVE_RUNAHEAD
|
DEFINES += -DHAVE_RUNAHEAD
|
||||||
|
OBJ += runahead.o
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(HAVE_CC_RESAMPLER), 1)
|
ifeq ($(HAVE_CC_RESAMPLER), 1)
|
||||||
|
|
|
@ -1236,6 +1236,9 @@ RETROARCH
|
||||||
============================================================ */
|
============================================================ */
|
||||||
#include "../retroarch.c"
|
#include "../retroarch.c"
|
||||||
#include "../runloop.c"
|
#include "../runloop.c"
|
||||||
|
#ifdef HAVE_RUNAHEAD
|
||||||
|
#include "../runahead.c"
|
||||||
|
#endif
|
||||||
#include "../command.c"
|
#include "../command.c"
|
||||||
#include "../midi_driver.c"
|
#include "../midi_driver.c"
|
||||||
#include "../location_driver.c"
|
#include "../location_driver.c"
|
||||||
|
|
|
@ -8710,7 +8710,7 @@ static void runahead_change_handler(rarch_setting_t *setting)
|
||||||
{
|
{
|
||||||
/* Disable preemptive frames and inform user */
|
/* Disable preemptive frames and inform user */
|
||||||
settings->bools.preemptive_frames_enable = false;
|
settings->bools.preemptive_frames_enable = false;
|
||||||
runloop_preempt_deinit();
|
preempt_deinit(runloop_state_get_ptr());
|
||||||
runloop_msg_queue_push(
|
runloop_msg_queue_push(
|
||||||
msg_hash_to_str(MSG_PREEMPT_DISABLED), 1, 100, false,
|
msg_hash_to_str(MSG_PREEMPT_DISABLED), 1, 100, false,
|
||||||
NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||||
|
|
|
@ -8438,7 +8438,7 @@ void deinit_netplay(void)
|
||||||
|
|
||||||
#if HAVE_RUNAHEAD
|
#if HAVE_RUNAHEAD
|
||||||
/* Reinitialize preemptive frames if enabled */
|
/* Reinitialize preemptive frames if enabled */
|
||||||
runloop_preempt_init();
|
preempt_init(runloop_state_get_ptr());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
18
retroarch.c
18
retroarch.c
|
@ -2272,7 +2272,7 @@ bool command_event(enum event_command cmd, void *data)
|
||||||
|
|
||||||
/* Disable preemptive frames */
|
/* Disable preemptive frames */
|
||||||
settings->bools.preemptive_frames_enable = false;
|
settings->bools.preemptive_frames_enable = false;
|
||||||
runloop_preempt_deinit();
|
preempt_deinit(runloop_st);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -2318,8 +2318,8 @@ bool command_event(enum event_command cmd, void *data)
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_PREEMPT_UPDATE:
|
case CMD_EVENT_PREEMPT_UPDATE:
|
||||||
#if HAVE_RUNAHEAD
|
#if HAVE_RUNAHEAD
|
||||||
runloop_preempt_deinit();
|
preempt_deinit(runloop_st);
|
||||||
runloop_preempt_init();
|
preempt_init(runloop_st);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_PREEMPT_RESET_BUFFER:
|
case CMD_EVENT_PREEMPT_RESET_BUFFER:
|
||||||
|
@ -2411,9 +2411,9 @@ bool command_event(enum event_command cmd, void *data)
|
||||||
|
|
||||||
if (!runloop_st->secondary_lib_handle)
|
if (!runloop_st->secondary_lib_handle)
|
||||||
{
|
{
|
||||||
if (!secondary_core_ensure_exists(settings))
|
if (!secondary_core_ensure_exists(runloop_st, settings))
|
||||||
{
|
{
|
||||||
runloop_secondary_core_destroy();
|
runahead_secondary_core_destroy(runloop_st);
|
||||||
runloop_st->flags &=
|
runloop_st->flags &=
|
||||||
~RUNLOOP_FLAG_RUNAHEAD_SECONDARY_CORE_AVAILABLE;
|
~RUNLOOP_FLAG_RUNAHEAD_SECONDARY_CORE_AVAILABLE;
|
||||||
return false;
|
return false;
|
||||||
|
@ -3042,10 +3042,10 @@ bool command_event(enum event_command cmd, void *data)
|
||||||
* remain disabled until the user restarts
|
* remain disabled until the user restarts
|
||||||
* RetroArch */
|
* RetroArch */
|
||||||
if (!(runloop_st->flags & RUNLOOP_FLAG_RUNAHEAD_AVAILABLE))
|
if (!(runloop_st->flags & RUNLOOP_FLAG_RUNAHEAD_AVAILABLE))
|
||||||
runloop_runahead_clear_variables(runloop_st);
|
runahead_clear_variables(runloop_st);
|
||||||
|
|
||||||
/* Deallocate preemptive frames */
|
/* Deallocate preemptive frames */
|
||||||
runloop_preempt_deinit();
|
preempt_deinit(runloop_st);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (hwr)
|
if (hwr)
|
||||||
|
@ -3583,7 +3583,7 @@ bool command_event(enum event_command cmd, void *data)
|
||||||
}
|
}
|
||||||
#if HAVE_RUNAHEAD
|
#if HAVE_RUNAHEAD
|
||||||
/* Deinit preemptive frames; not compatible with netplay */
|
/* Deinit preemptive frames; not compatible with netplay */
|
||||||
runloop_preempt_deinit();
|
preempt_deinit(runloop_st);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -6248,7 +6248,7 @@ bool retroarch_main_init(int argc, char *argv[])
|
||||||
#ifdef HAVE_NETWORKING
|
#ifdef HAVE_NETWORKING
|
||||||
if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL))
|
if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL))
|
||||||
#endif
|
#endif
|
||||||
runloop_preempt_init();
|
preempt_init(runloop_st);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
1705
runahead.c
Normal file
1705
runahead.c
Normal file
File diff suppressed because it is too large
Load diff
96
runahead.h
Normal file
96
runahead.h
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
/* RetroArch - A frontend for libretro.
|
||||||
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||||
|
* Copyright (C) 2011-2023 - Daniel De Matteis
|
||||||
|
*
|
||||||
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||||
|
* of the GNU General Public License as published by the Free Software Found-
|
||||||
|
* ation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __RUNAHEAD_H
|
||||||
|
#define __RUNAHEAD_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include <boolean.h>
|
||||||
|
#include <retro_common_api.h>
|
||||||
|
|
||||||
|
#include "core.h"
|
||||||
|
|
||||||
|
#define MAX_RUNAHEAD_FRAMES 12
|
||||||
|
|
||||||
|
typedef void *(*constructor_t)(void);
|
||||||
|
typedef void (*destructor_t )(void*);
|
||||||
|
|
||||||
|
typedef struct my_list_t
|
||||||
|
{
|
||||||
|
void **data;
|
||||||
|
constructor_t constructor;
|
||||||
|
destructor_t destructor;
|
||||||
|
int capacity;
|
||||||
|
int size;
|
||||||
|
} my_list;
|
||||||
|
|
||||||
|
typedef struct preemptive_frames_data
|
||||||
|
{
|
||||||
|
/* Savestate buffer */
|
||||||
|
void* buffer[MAX_RUNAHEAD_FRAMES];
|
||||||
|
size_t state_size;
|
||||||
|
|
||||||
|
/* Frame count since buffer init/reset */
|
||||||
|
uint64_t frame_count;
|
||||||
|
|
||||||
|
/* Mask of analog states requested */
|
||||||
|
uint32_t analog_mask[MAX_USERS];
|
||||||
|
|
||||||
|
/* Input states. Replays triggered on changes */
|
||||||
|
int16_t joypad_state[MAX_USERS];
|
||||||
|
int16_t analog_state[MAX_USERS][20];
|
||||||
|
int16_t ptrdev_state[MAX_USERS][4];
|
||||||
|
|
||||||
|
/* Pointing device requested */
|
||||||
|
uint8_t ptr_dev[MAX_USERS];
|
||||||
|
/* Buffer indexes for replays */
|
||||||
|
uint8_t start_ptr;
|
||||||
|
uint8_t replay_ptr;
|
||||||
|
/* Number of latency frames to remove */
|
||||||
|
uint8_t frames;
|
||||||
|
} preempt_t;
|
||||||
|
|
||||||
|
RETRO_BEGIN_DECLS
|
||||||
|
|
||||||
|
typedef bool(*runahead_load_state_function)(const void*, size_t);
|
||||||
|
|
||||||
|
void runahead_run(
|
||||||
|
void *data,
|
||||||
|
int runahead_count,
|
||||||
|
bool runahead_hide_warnings,
|
||||||
|
bool use_secondary);
|
||||||
|
|
||||||
|
void runahead_clear_variables(void *data);
|
||||||
|
|
||||||
|
void runahead_remember_controller_port_device(void *data,
|
||||||
|
long port, long device);
|
||||||
|
void runahead_clear_controller_port_map(void *data);
|
||||||
|
|
||||||
|
void runahead_set_load_content_info(
|
||||||
|
void *data,
|
||||||
|
const retro_ctx_load_content_info_t *ctx);
|
||||||
|
|
||||||
|
void runahead_secondary_core_destroy(void *data);
|
||||||
|
|
||||||
|
bool preempt_init(void *data);
|
||||||
|
void preempt_deinit(void *data);
|
||||||
|
|
||||||
|
void preempt_run(preempt_t *preempt, void *data);
|
||||||
|
|
||||||
|
RETRO_END_DECLS
|
||||||
|
|
||||||
|
#endif
|
76
runloop.h
76
runloop.h
|
@ -41,6 +41,9 @@
|
||||||
#include "core_option_manager.h"
|
#include "core_option_manager.h"
|
||||||
#include "performance_counters.h"
|
#include "performance_counters.h"
|
||||||
#include "state_manager.h"
|
#include "state_manager.h"
|
||||||
|
#ifdef HAVE_RUNAHEAD
|
||||||
|
#include "runahead.h"
|
||||||
|
#endif
|
||||||
#include "tasks/tasks_internal.h"
|
#include "tasks/tasks_internal.h"
|
||||||
|
|
||||||
/* Arbitrary twenty subsystems limit */
|
/* Arbitrary twenty subsystems limit */
|
||||||
|
@ -158,51 +161,6 @@ typedef struct core_options_callbacks
|
||||||
retro_core_options_update_display_callback_t update_display;
|
retro_core_options_update_display_callback_t update_display;
|
||||||
} core_options_callbacks_t;
|
} core_options_callbacks_t;
|
||||||
|
|
||||||
#ifdef HAVE_RUNAHEAD
|
|
||||||
#define MAX_RUNAHEAD_FRAMES 12
|
|
||||||
|
|
||||||
typedef bool(*runahead_load_state_function)(const void*, size_t);
|
|
||||||
|
|
||||||
typedef void *(*constructor_t)(void);
|
|
||||||
typedef void (*destructor_t )(void*);
|
|
||||||
|
|
||||||
typedef struct my_list_t
|
|
||||||
{
|
|
||||||
void **data;
|
|
||||||
constructor_t constructor;
|
|
||||||
destructor_t destructor;
|
|
||||||
int capacity;
|
|
||||||
int size;
|
|
||||||
} my_list;
|
|
||||||
|
|
||||||
typedef struct preemptive_frames_data
|
|
||||||
{
|
|
||||||
/* Savestate buffer */
|
|
||||||
void* buffer[MAX_RUNAHEAD_FRAMES];
|
|
||||||
size_t state_size;
|
|
||||||
|
|
||||||
/* Number of latency frames to remove */
|
|
||||||
uint8_t frames;
|
|
||||||
|
|
||||||
/* Buffer indexes for replays */
|
|
||||||
uint8_t start_ptr;
|
|
||||||
uint8_t replay_ptr;
|
|
||||||
|
|
||||||
/* Frame count since buffer init/reset */
|
|
||||||
uint64_t frame_count;
|
|
||||||
|
|
||||||
/* Input states. Replays triggered on changes */
|
|
||||||
int16_t joypad_state[MAX_USERS];
|
|
||||||
int16_t analog_state[MAX_USERS][20];
|
|
||||||
int16_t ptrdev_state[MAX_USERS][4];
|
|
||||||
|
|
||||||
/* Pointing device requested */
|
|
||||||
uint8_t ptr_dev[MAX_USERS];
|
|
||||||
/* Mask of analog states requested */
|
|
||||||
uint32_t analog_mask[MAX_USERS];
|
|
||||||
} preempt_t;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct runloop
|
struct runloop
|
||||||
{
|
{
|
||||||
#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL)
|
#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL)
|
||||||
|
@ -413,13 +371,6 @@ void runloop_runtime_log_deinit(
|
||||||
|
|
||||||
void runloop_event_deinit_core(void);
|
void runloop_event_deinit_core(void);
|
||||||
|
|
||||||
#ifdef HAVE_RUNAHEAD
|
|
||||||
void runloop_runahead_clear_variables(runloop_state_t *runloop_st);
|
|
||||||
|
|
||||||
bool runloop_preempt_init(void);
|
|
||||||
void runloop_preempt_deinit(void);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool runloop_event_init_core(
|
bool runloop_event_init_core(
|
||||||
settings_t *settings,
|
settings_t *settings,
|
||||||
void *input_data,
|
void *input_data,
|
||||||
|
@ -453,13 +404,11 @@ void runloop_task_msg_queue_push(
|
||||||
unsigned prio, unsigned duration,
|
unsigned prio, unsigned duration,
|
||||||
bool flush);
|
bool flush);
|
||||||
|
|
||||||
bool secondary_core_ensure_exists(settings_t *settings);
|
bool secondary_core_ensure_exists(void *data, settings_t *settings);
|
||||||
|
|
||||||
void runloop_log_counters(
|
void runloop_log_counters(
|
||||||
struct retro_perf_counter **counters, unsigned num);
|
struct retro_perf_counter **counters, unsigned num);
|
||||||
|
|
||||||
void runloop_secondary_core_destroy(void);
|
|
||||||
|
|
||||||
void runloop_msg_queue_deinit(void);
|
void runloop_msg_queue_deinit(void);
|
||||||
|
|
||||||
void runloop_msg_queue_init(void);
|
void runloop_msg_queue_init(void);
|
||||||
|
@ -482,6 +431,23 @@ void runloop_path_set_special(char **argv, unsigned num_content);
|
||||||
|
|
||||||
void runloop_path_deinit_subsystem(void);
|
void runloop_path_deinit_subsystem(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* init_libretro_symbols:
|
||||||
|
* @type : Type of core to be loaded.
|
||||||
|
* If CORE_TYPE_DUMMY, will
|
||||||
|
* load dummy symbols.
|
||||||
|
*
|
||||||
|
* Setup libretro callback symbols.
|
||||||
|
*
|
||||||
|
* @return true on success, or false if symbols could not be loaded.
|
||||||
|
**/
|
||||||
|
bool runloop_init_libretro_symbols(
|
||||||
|
void *data,
|
||||||
|
enum rarch_core_type type,
|
||||||
|
struct retro_core_t *current_core,
|
||||||
|
const char *lib_path,
|
||||||
|
void *_lib_handle_p);
|
||||||
|
|
||||||
runloop_state_t *runloop_state_get_ptr(void);
|
runloop_state_t *runloop_state_get_ptr(void);
|
||||||
|
|
||||||
RETRO_END_DECLS
|
RETRO_END_DECLS
|
||||||
|
|
Loading…
Reference in a new issue