mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-03 00:35:54 +00:00
LIBRETRO: drop performance auto tuner
This commit is contained in:
parent
f5a45d36e3
commit
8ed85326fa
@ -556,18 +556,6 @@ struct retro_core_option_v2_definition option_defs_it[] = {
|
||||
},
|
||||
NULL,
|
||||
},
|
||||
{
|
||||
"scummvm_auto_performance_tuner",
|
||||
"Regolazione automatica performance",
|
||||
NULL,
|
||||
"Cambio automatico delle impostazioni di timing e salto dei fotogrammi se vengono rilevate performance scadenti durante il gioco. Le impostazioni di timing/frameskip saranno temporaneamente cambiate in sequenza, se saranno rilevati audio buffer underrun e per la sola sessione di gioco, e ripristinati in sequenza in caso di recupero del buffer audio. Le singole impostazioni salvate non saranno modificate ma saranno ignorati.",
|
||||
NULL,
|
||||
NULL,
|
||||
{
|
||||
{NULL, NULL},
|
||||
},
|
||||
NULL
|
||||
},
|
||||
{ NULL, NULL, NULL, NULL, NULL, NULL, {{0}}, NULL },
|
||||
};
|
||||
struct retro_core_options_v2 options_it = {
|
||||
|
@ -632,24 +632,6 @@ struct retro_core_option_v2_definition option_defs_us[] = {
|
||||
},
|
||||
"RETROK_RIGHT"
|
||||
},
|
||||
{
|
||||
"scummvm_auto_performance_tuner",
|
||||
"Auto performance tuner",
|
||||
NULL,
|
||||
"In-game automatic change of timing/frameskip settings if low performances are detected. Timing/frameskip settings will be changed in sequence, if audio buffer underruns are detected and for the current game session only, and restored in sequence if audio buffers recovers. Single saved settings will not be affected but will be overridden in-game.",
|
||||
NULL,
|
||||
NULL,
|
||||
{
|
||||
{"disabled", NULL},
|
||||
{"enabled", NULL},
|
||||
{NULL, NULL},
|
||||
},
|
||||
#if defined(DEFAULT_PERF_TUNER)
|
||||
"enabled"
|
||||
#else
|
||||
"disabled"
|
||||
#endif
|
||||
},
|
||||
{ NULL, NULL, NULL, NULL, NULL, NULL, {{0}}, NULL },
|
||||
};
|
||||
|
||||
|
@ -24,7 +24,6 @@ extern retro_log_printf_t retro_log_cb;
|
||||
extern retro_input_state_t retro_input_cb;
|
||||
|
||||
bool retro_get_input_bitmask_supported(void);
|
||||
void reset_performance_tuner(void);
|
||||
void retro_osd_notification(const char* msg);
|
||||
int retro_get_input_device(void);
|
||||
const char * retro_get_core_dir(void);
|
||||
|
@ -45,14 +45,6 @@ will be updated to include it */
|
||||
#define AUDIO_STATUS_UPDATE_LATENCY (1 << 4)
|
||||
#define AUDIO_STATUS_UPDATE_AV_INFO (1 << 5)
|
||||
|
||||
// Performance switcher
|
||||
#define PERF_SWITCH_FRAMESKIP_EVENTS DEFAULT_REFRESH_RATE / 2
|
||||
#define PERF_SWITCH_ON (1 << 0)
|
||||
#define PERF_SWITCH_ENABLE_TIMING_INACCURACIES (1 << 1)
|
||||
#define PERF_SWITCH_OVER (1 << 2)
|
||||
#define PERF_SWITCH_RESET_THRESHOLD 60
|
||||
#define PERF_SWITCH_RESET_REST DEFAULT_REFRESH_RATE * 30
|
||||
|
||||
// Thread switch caller
|
||||
#define THREAD_SWITCH_POLL (1 << 0)
|
||||
#define THREAD_SWITCH_DELAY (1 << 1)
|
||||
|
@ -105,7 +105,6 @@ public:
|
||||
~OSystem_libretro(void) override;
|
||||
void initBackend(void) override;
|
||||
void engineInit(void) override;
|
||||
void engineDone(void) override;
|
||||
bool hasFeature(Feature f) override;
|
||||
void setFeatureState(Feature f, bool enable) override;
|
||||
bool getFeatureState(Feature f) override;
|
||||
|
@ -94,10 +94,6 @@ static uint8 audio_status = AUDIO_STATUS_MUTE;
|
||||
static unsigned retro_audio_buff_occupancy = 0;
|
||||
static uint8 retro_audio_buff_underrun_threshold = 25;
|
||||
|
||||
static uint8 performance_switch = 0;
|
||||
static uint32 perf_ref_frame = 0;
|
||||
static uint32 perf_ref_audio_buff_occupancy = 0;
|
||||
|
||||
static float frame_rate = 0;
|
||||
static uint16 sample_rate = 0;
|
||||
static float audio_samples_per_frame = 0.0f; // length in samples per frame
|
||||
@ -201,33 +197,6 @@ static void retro_audio_buff_status_cb(bool active, unsigned occupancy, bool und
|
||||
retro_audio_buff_occupancy = occupancy;
|
||||
}
|
||||
|
||||
static void increase_performance() {
|
||||
if (!(performance_switch & PERF_SWITCH_ENABLE_TIMING_INACCURACIES)) {
|
||||
performance_switch |= PERF_SWITCH_ENABLE_TIMING_INACCURACIES;
|
||||
retro_log_cb(RETRO_LOG_DEBUG, "Auto performance tuner: 'Allow Timing Inaccuracies' enabled.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
performance_switch |= PERF_SWITCH_OVER;
|
||||
}
|
||||
|
||||
static void increase_accuracy() {
|
||||
performance_switch &= ~PERF_SWITCH_OVER;
|
||||
|
||||
if (performance_switch & PERF_SWITCH_ENABLE_TIMING_INACCURACIES) {
|
||||
performance_switch &= ~PERF_SWITCH_ENABLE_TIMING_INACCURACIES;
|
||||
retro_log_cb(RETRO_LOG_DEBUG, "Auto performance tuner: 'Allow Timing Inaccuracies' disabled.\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void reset_performance_tuner() {
|
||||
if (performance_switch & PERF_SWITCH_ON) {
|
||||
performance_switch = PERF_SWITCH_ON;
|
||||
retro_log_cb(RETRO_LOG_DEBUG, "Auto performance tuner: reset.\n");
|
||||
}
|
||||
}
|
||||
|
||||
void retro_osd_notification(const char *msg) {
|
||||
if (!msg || *msg == '\0')
|
||||
return;
|
||||
@ -355,18 +324,6 @@ static void update_variables(void) {
|
||||
}
|
||||
}
|
||||
|
||||
var.key = "scummvm_auto_performance_tuner";
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
|
||||
if (strcmp(var.value, "enabled") == 0) {
|
||||
if (!performance_switch)
|
||||
audio_status |= AUDIO_STATUS_UPDATE_LATENCY;
|
||||
|
||||
performance_switch &= ~PERF_SWITCH_OVER;
|
||||
performance_switch |= PERF_SWITCH_ON;
|
||||
} else
|
||||
performance_switch = 0;
|
||||
}
|
||||
|
||||
var.key = "scummvm_mapper_up";
|
||||
var.value = NULL;
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
|
||||
@ -517,12 +474,6 @@ static void update_variables(void) {
|
||||
retro_osd_notification("Selected frameskip mode not available");
|
||||
frameskip_type = 0;
|
||||
}
|
||||
|
||||
if (performance_switch) {
|
||||
retro_log_cb(RETRO_LOG_WARN, "Auto performance tuner not available.\n");
|
||||
retro_osd_notification("Auto performance tuner not available");
|
||||
performance_switch = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (old_frameskip_type != frameskip_type || old_frame_rate != frame_rate || old_sample_rate != sample_rate) {
|
||||
@ -563,10 +514,7 @@ static bool retro_update_options_display(void) {
|
||||
}
|
||||
|
||||
bool retro_setting_get_timing_inaccuracies_enabled() {
|
||||
if (performance_switch & PERF_SWITCH_ON)
|
||||
return (performance_switch & PERF_SWITCH_ENABLE_TIMING_INACCURACIES);
|
||||
else
|
||||
return timing_inaccuracies_enabled;
|
||||
return timing_inaccuracies_enabled;
|
||||
}
|
||||
|
||||
bool retro_setting_get_gamepad_cursor_only(void) {
|
||||
@ -1056,7 +1004,7 @@ void retro_run(void) {
|
||||
if (g_system) {
|
||||
|
||||
/* Determine frameskip need based on settings */
|
||||
if ((frameskip_type == 2) || (performance_switch & PERF_SWITCH_ON))
|
||||
if (frameskip_type == 2)
|
||||
skip_frame = ((audio_status & (AUDIO_STATUS_BUFFER_UNDERRUN | AUDIO_STATUS_BUFFER_ACTIVE)) == (AUDIO_STATUS_BUFFER_UNDERRUN | AUDIO_STATUS_BUFFER_ACTIVE));
|
||||
else if (frameskip_type == 1)
|
||||
skip_frame = !(current_frame % frameskip_no == 0);
|
||||
@ -1074,32 +1022,8 @@ void retro_run(void) {
|
||||
skip_frame = false;
|
||||
frameskip_counter = 0;
|
||||
/* Keep on skipping frames if flagged */
|
||||
} else if (skip_frame) {
|
||||
} else if (skip_frame)
|
||||
frameskip_counter++;
|
||||
/* Performance counter */
|
||||
if ((performance_switch & PERF_SWITCH_ON) && !(performance_switch & PERF_SWITCH_OVER)) {
|
||||
frameskip_events += frameskip_counter;
|
||||
if (frameskip_events > PERF_SWITCH_FRAMESKIP_EVENTS) {
|
||||
increase_performance();
|
||||
frameskip_events = 0;
|
||||
perf_ref_frame = current_frame;
|
||||
perf_ref_audio_buff_occupancy = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Performance tuner reset if average buffer occupacy is above the required threshold again */
|
||||
if (!skip_frame && (performance_switch & PERF_SWITCH_ON) && performance_switch > PERF_SWITCH_ON) {
|
||||
perf_ref_audio_buff_occupancy += retro_audio_buff_occupancy;
|
||||
if ((current_frame - perf_ref_frame) % (PERF_SWITCH_RESET_REST) == 0) {
|
||||
uint32 avg_audio_buff_occupancy = perf_ref_audio_buff_occupancy / (current_frame + 1 - perf_ref_frame);
|
||||
if (avg_audio_buff_occupancy > PERF_SWITCH_RESET_THRESHOLD || avg_audio_buff_occupancy == retro_audio_buff_occupancy)
|
||||
increase_accuracy();
|
||||
perf_ref_frame = current_frame - 1;
|
||||
perf_ref_audio_buff_occupancy = 0;
|
||||
frameskip_events = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Switch to ScummVM thread */
|
||||
retro_switch_to_emu_thread();
|
||||
|
@ -134,10 +134,6 @@ void OSystem_libretro::engineInit() {
|
||||
_gamePalette.reset();
|
||||
}
|
||||
|
||||
void OSystem_libretro::engineDone() {
|
||||
reset_performance_tuner();
|
||||
}
|
||||
|
||||
bool OSystem_libretro::hasFeature(Feature f) {
|
||||
return (f == OSystem::kFeatureCursorPalette) || (f == OSystem::kFeatureCursorAlpha);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user