[Scummvm-git-logs] scummvm master -> 0c3e3aaebcaf23de7175a9df5e5c0e13ad2551fd
spleen1981
noreply at scummvm.org
Mon Jul 10 23:21:08 UTC 2023
This automated email contains information about 10 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
edfd3d0b10 LIBRETRO: add min_auto_frameskip reset
e2b5bc1f67 LIBRETRO: merge cons scr updates w timing inaccuracies setting
e4f6f5d7f8 LIBRETRO: simplify timer
968adcb49d LIBRETRO: drop min_auto_frameskip
f86ca443dd LIBRETRO: set auto frameskip based on frame time
7d846d9a82 LIBRETRO: switch thread in GUI on poll event only
d18ad98339 LIBRETRO: add framerate cap setting
3d67e4bcc1 LIBRETRO: add empty audio buffer to use for GUI framerate control
77f7e24097 LIBRETRO: add sample rate setting
0c3e3aaebc LIBRETRO: JANITORIAL: fix typo in setting description
Commit: edfd3d0b1058ece7ab7edbd61e00a727f1b64dc3
https://github.com/scummvm/scummvm/commit/edfd3d0b1058ece7ab7edbd61e00a727f1b64dc3
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-07-11T01:17:20+02:00
Commit Message:
LIBRETRO: add min_auto_frameskip reset
Changed paths:
backends/platform/libretro/src/libretro.cpp
diff --git a/backends/platform/libretro/src/libretro.cpp b/backends/platform/libretro/src/libretro.cpp
index d9b0d72d540..c7fc8df02df 100644
--- a/backends/platform/libretro/src/libretro.cpp
+++ b/backends/platform/libretro/src/libretro.cpp
@@ -187,6 +187,8 @@ void reset_performance_tuner() {
performance_switch = PERF_SWITCH_ON;
log_cb(RETRO_LOG_DEBUG, "Auto performance tuner: reset.\n");
}
+ min_auto_frameskip = 0;
+ min_auto_frameskip_count = 0;
}
void retro_osd_notification(const char* msg) {
@@ -308,6 +310,8 @@ static void update_variables(void) {
}
if (old_frameskip_type != frameskip_type) {
+ min_auto_frameskip = 0;
+ min_auto_frameskip_count = 0;
audio_status |= AUDIO_STATUS_UPDATE_LATENCY;
}
}
Commit: e2b5bc1f677cd0d20fe6b98d1181d14d299d427b
https://github.com/scummvm/scummvm/commit/e2b5bc1f677cd0d20fe6b98d1181d14d299d427b
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-07-11T01:17:49+02:00
Commit Message:
LIBRETRO: merge cons scr updates w timing inaccuracies setting
Changed paths:
backends/platform/libretro/include/libretro-core-options-intl.h
backends/platform/libretro/include/libretro-core-options.h
backends/platform/libretro/include/libretro-defs.h
backends/platform/libretro/include/libretro-os.h
backends/platform/libretro/src/libretro-os-events.cpp
backends/platform/libretro/src/libretro-os-graphics.cpp
backends/platform/libretro/src/libretro.cpp
diff --git a/backends/platform/libretro/include/libretro-core-options-intl.h b/backends/platform/libretro/include/libretro-core-options-intl.h
index 29cf511bcea..f530830ec1e 100644
--- a/backends/platform/libretro/include/libretro-core-options-intl.h
+++ b/backends/platform/libretro/include/libretro-core-options-intl.h
@@ -197,18 +197,6 @@ struct retro_core_option_v2_definition option_defs_it[] = {
},
NULL
},
- {
- "scummvm_consecutive_screen_updates",
- "Disabilita aggiornamenti schermo consecutivi",
- NULL,
- "Mentre libretro si basa su FPS costante, ScummVM può aggiornare lo schermo indipentendemente dal framerate impostato. Di default tutti gli aggiornamenti schermo consecutivi di ScummVM vengono catturati e processati nella stessa chiamata a retro_run, migliorando l'accuratezza (es. effetti nei titoli dell'intro di Legend of Kyrandia) ma aumentando il tempo di esecuzione di quel loop retro_run. Se questa opzione è abilitata solo l'ultimo aggiornamento schermo di una serie consecutiva sarà mostrato. Se 'Consenti inaccuratezze di timing' è abilitato, questa impostazione sarà ignorata e abilitata internamente.",
- NULL,
- NULL,
- {
- {NULL, NULL},
- },
- NULL
- },
{
"scummvm_allow_timing_inaccuracies",
"Consenti inaccuratezze di timing",
diff --git a/backends/platform/libretro/include/libretro-core-options.h b/backends/platform/libretro/include/libretro-core-options.h
index e000d010518..cf2059ca3c2 100644
--- a/backends/platform/libretro/include/libretro-core-options.h
+++ b/backends/platform/libretro/include/libretro-core-options.h
@@ -262,20 +262,6 @@ struct retro_core_option_v2_definition option_defs_us[] = {
},
"0"
},
- {
- "scummvm_consecutive_screen_updates",
- "Disable consecutive screen updates",
- NULL,
- "While libretro is FPS bounded, ScummVM can update the screen independently from the refresh rate set. By default all consecutive ScummVM screen updates will be captured and processed within the same retro_run call, improving accuracy (e.g. see titles effects in Legend of Kyrandia intro) but increasing the execution time of that retro_run loop. If this setting is enabled only last screen update of a consecutive series will be shown. If 'Allow Timing Inaccuracies' is enabled, this setting will be overridden and enabled internally.",
- NULL,
- "timing",
- {
- {"disabled", NULL},
- {"enabled", NULL},
- {NULL, NULL},
- },
- "disabled"
- },
{
"scummvm_allow_timing_inaccuracies",
"Allow Timing Inaccuracies",
diff --git a/backends/platform/libretro/include/libretro-defs.h b/backends/platform/libretro/include/libretro-defs.h
index d1c291740c4..d61050a3c21 100644
--- a/backends/platform/libretro/include/libretro-defs.h
+++ b/backends/platform/libretro/include/libretro-defs.h
@@ -34,8 +34,7 @@
#define PERF_SWITCH_FRAMESKIP_EVENTS REFRESH_RATE / 2
#define PERF_SWITCH_ON (1 << 0)
#define PERF_SWITCH_ENABLE_TIMING_INACCURACIES (1 << 1)
-#define PERF_SWITCH_DISABLE_CONSECUTIVE_SCREEN_UPDATES (1 << 2)
-#define PERF_SWITCH_OVER (1 << 3)
+#define PERF_SWITCH_OVER (1 << 2)
#define PERF_SWITCH_RESET_THRESHOLD 60
#define PERF_SWITCH_RESET_REST REFRESH_RATE * 30
diff --git a/backends/platform/libretro/include/libretro-os.h b/backends/platform/libretro/include/libretro-os.h
index 1f0955108ae..83d28e49273 100644
--- a/backends/platform/libretro/include/libretro-os.h
+++ b/backends/platform/libretro/include/libretro-os.h
@@ -34,7 +34,6 @@
extern retro_log_printf_t log_cb;
extern bool timing_inaccuracies_is_enabled(void);
-extern bool consecutive_screen_updates_is_enabled(void);
extern void reset_performance_tuner(void);
extern void retro_osd_notification(const char* msg);
extern float frame_rate;
diff --git a/backends/platform/libretro/src/libretro-os-events.cpp b/backends/platform/libretro/src/libretro-os-events.cpp
index c0d9f82cc29..69854047c4c 100644
--- a/backends/platform/libretro/src/libretro-os-events.cpp
+++ b/backends/platform/libretro/src/libretro-os-events.cpp
@@ -38,7 +38,6 @@ Common::List<Common::Event> OSystem_libretro::_events;
bool OSystem_libretro::pollEvent(Common::Event &event) {
_threadSwitchCaller = THREAD_SWITCH_POLL;
((LibretroTimerManager *)_timerManager)->checkThread();
- ((LibretroTimerManager *)_timerManager)->handler();
if (!_events.empty()) {
event = _events.front();
_events.pop_front();
@@ -97,8 +96,6 @@ void OSystem_libretro::delayMillis(uint msecs) {
elapsed_time = getMillis() - start_time;
}
}
-
- ((LibretroTimerManager *)_timerManager)->handler();
}
Common::MutexInternal *OSystem_libretro::createMutex(void) {
diff --git a/backends/platform/libretro/src/libretro-os-graphics.cpp b/backends/platform/libretro/src/libretro-os-graphics.cpp
index 8d9ea0f9215..3ef0287e0f9 100644
--- a/backends/platform/libretro/src/libretro-os-graphics.cpp
+++ b/backends/platform/libretro/src/libretro-os-graphics.cpp
@@ -301,14 +301,9 @@ void OSystem_libretro::updateScreen() {
}
}
- /* Switch directly to main thread in case of consecutive updateScreen, to avoid losing frames.
- Non consecutive updateScreen are covered by thread switches triggered by pollEvent or delayMillis. */
- if (! timing_inaccuracies_is_enabled() && consecutive_screen_updates_is_enabled()) {
- if (_threadSwitchCaller & THREAD_SWITCH_UPDATE) {
- ((LibretroTimerManager *)_timerManager)->switchThread();
- } else {
- _threadSwitchCaller = THREAD_SWITCH_UPDATE;
- }
+ if (! timing_inaccuracies_is_enabled()) {
+ _threadSwitchCaller = THREAD_SWITCH_UPDATE;
+ ((LibretroTimerManager *)_timerManager)->checkThread();
}
}
diff --git a/backends/platform/libretro/src/libretro.cpp b/backends/platform/libretro/src/libretro.cpp
index c7fc8df02df..a8eab2ea6bc 100644
--- a/backends/platform/libretro/src/libretro.cpp
+++ b/backends/platform/libretro/src/libretro.cpp
@@ -78,7 +78,6 @@ static float mouse_speed = 1.0f;
static float gamepad_acceleration_time = 0.2f;
static bool timing_inaccuracies_enabled = false;
-static bool consecutive_screen_updates = false;
char cmd_params[20][200];
char cmd_params_num;
@@ -150,12 +149,6 @@ static void retro_audio_buff_status_cb(bool active, unsigned occupancy, bool und
}
static void increase_performance() {
- if (!(performance_switch & PERF_SWITCH_DISABLE_CONSECUTIVE_SCREEN_UPDATES)) {
- performance_switch |= PERF_SWITCH_DISABLE_CONSECUTIVE_SCREEN_UPDATES;
- log_cb(RETRO_LOG_DEBUG, "Auto performance tuner: 'Disable consecutive screen updates' enabled.\n");
- return;
- }
-
if (!(performance_switch & PERF_SWITCH_ENABLE_TIMING_INACCURACIES)) {
performance_switch |= PERF_SWITCH_ENABLE_TIMING_INACCURACIES;
log_cb(RETRO_LOG_DEBUG, "Auto performance tuner: 'Allow Timing Inaccuracies' enabled.\n");
@@ -173,13 +166,6 @@ static void increase_accuracy() {
log_cb(RETRO_LOG_DEBUG, "Auto performance tuner: 'Allow Timing Inaccuracies' disabled.\n");
return;
}
-
-
- if (performance_switch & PERF_SWITCH_DISABLE_CONSECUTIVE_SCREEN_UPDATES) {
- performance_switch &= ~PERF_SWITCH_DISABLE_CONSECUTIVE_SCREEN_UPDATES;
- log_cb(RETRO_LOG_DEBUG, "Auto performance tuner: 'Disable consecutive screen updates' disabled.\n");
- return;
- }
}
void reset_performance_tuner() {
@@ -287,14 +273,6 @@ static void update_variables(void) {
performance_switch = 0;
}
- var.key = "scummvm_consecutive_screen_updates";
- if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
- if (strcmp(var.value, "enabled") == 0) {
- consecutive_screen_updates = false;
- } else
- consecutive_screen_updates = true;
- }
-
if (!(audio_status & AUDIO_STATUS_BUFFER_SUPPORT)) {
if (frameskip_type > 1) {
log_cb(RETRO_LOG_WARN, "Selected frameskip mode not available.\n");
@@ -323,13 +301,6 @@ bool timing_inaccuracies_is_enabled(){
return timing_inaccuracies_enabled;
}
-bool consecutive_screen_updates_is_enabled(){
- if (performance_switch & PERF_SWITCH_ON)
- return !(performance_switch & PERF_SWITCH_DISABLE_CONSECUTIVE_SCREEN_UPDATES);
- else
- return consecutive_screen_updates;
-}
-
void init_command_params(void) {
memset(cmd_params, 0, sizeof(cmd_params));
cmd_params_num = 1;
Commit: e4f6f5d7f8f432f78fcf9a8523f1f099d3163370
https://github.com/scummvm/scummvm/commit/e4f6f5d7f8f432f78fcf9a8523f1f099d3163370
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-07-11T01:18:05+02:00
Commit Message:
LIBRETRO: simplify timer
Changed paths:
backends/platform/libretro/src/libretro-timer.cpp
diff --git a/backends/platform/libretro/src/libretro-timer.cpp b/backends/platform/libretro/src/libretro-timer.cpp
index cc96effc213..13e81be4111 100644
--- a/backends/platform/libretro/src/libretro-timer.cpp
+++ b/backends/platform/libretro/src/libretro-timer.cpp
@@ -30,10 +30,11 @@ LibretroTimerManager::LibretroTimerManager(uint32 refresh_rate) {
}
void LibretroTimerManager::switchThread(void) {
- _nextSwitchTime = g_system->getMillis() + _interval;
+ _spentOnMainThread = g_system->getMillis();
retro_switch_to_main_thread();
- _spentOnMainThread = g_system->getMillis() - _nextSwitchTime + _interval;
- _nextSwitchTime += _interval <= _spentOnMainThread ? _spentOnMainThread + _interval : 0;
+ _spentOnMainThread = g_system->getMillis() - _spentOnMainThread;
+ _nextSwitchTime = g_system->getMillis() + _interval;
+ handler();
}
void LibretroTimerManager::checkThread(void) {
Commit: 968adcb49dae4a18cd738a63ac66a441ecdbe097
https://github.com/scummvm/scummvm/commit/968adcb49dae4a18cd738a63ac66a441ecdbe097
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-07-11T01:18:24+02:00
Commit Message:
LIBRETRO: drop min_auto_frameskip
Changed paths:
backends/platform/libretro/include/libretro-defs.h
backends/platform/libretro/src/libretro.cpp
diff --git a/backends/platform/libretro/include/libretro-defs.h b/backends/platform/libretro/include/libretro-defs.h
index d61050a3c21..84a7b22f173 100644
--- a/backends/platform/libretro/include/libretro-defs.h
+++ b/backends/platform/libretro/include/libretro-defs.h
@@ -21,7 +21,6 @@
#define SAMPLE_RATE 48000
#define REFRESH_RATE 60
#define FRAMESKIP_MAX REFRESH_RATE / 2
-#define MIN_AUTO_FRAMESKIP_MAX 5
// Audio status
#define AUDIO_STATUS_MUTE (1 << 0)
diff --git a/backends/platform/libretro/src/libretro.cpp b/backends/platform/libretro/src/libretro.cpp
index a8eab2ea6bc..dae45d870a7 100644
--- a/backends/platform/libretro/src/libretro.cpp
+++ b/backends/platform/libretro/src/libretro.cpp
@@ -87,8 +87,6 @@ int adjusted_RES_H = 0;
static uint32 current_frame = 0;
static uint8 frameskip_no;
-static uint8 min_auto_frameskip = 0;
-static uint8 min_auto_frameskip_count = 0;
static uint8 frameskip_type;
static uint8 frameskip_threshold;
static uint32 frameskip_counter = 0;
@@ -173,8 +171,6 @@ void reset_performance_tuner() {
performance_switch = PERF_SWITCH_ON;
log_cb(RETRO_LOG_DEBUG, "Auto performance tuner: reset.\n");
}
- min_auto_frameskip = 0;
- min_auto_frameskip_count = 0;
}
void retro_osd_notification(const char* msg) {
@@ -288,8 +284,6 @@ static void update_variables(void) {
}
if (old_frameskip_type != frameskip_type) {
- min_auto_frameskip = 0;
- min_auto_frameskip_count = 0;
audio_status |= AUDIO_STATUS_UPDATE_LATENCY;
}
}
@@ -730,14 +724,8 @@ void retro_run(void) {
delayMillis call in ScummVM thread. */
do {
/* Determine frameskip need based on settings */
- if ((frameskip_type == 2) || (performance_switch & PERF_SWITCH_ON)) {
+ if ((frameskip_type == 2) || (performance_switch & PERF_SWITCH_ON))
skip_frame = (audio_status & AUDIO_STATUS_BUFFER_UNDERRUN);
- if (skip_frame)
- min_auto_frameskip_count = min_auto_frameskip;
- else if (min_auto_frameskip_count) {
- skip_frame = min_auto_frameskip_count--;
- }
- }
else if (frameskip_type == 1)
skip_frame = !(current_frame % frameskip_no == 0);
else if (frameskip_type == 3)
@@ -757,14 +745,10 @@ void retro_run(void) {
} else if (skip_frame) {
frameskip_counter++;
/* Performance counter */
- if (((performance_switch & PERF_SWITCH_ON) && !(performance_switch & PERF_SWITCH_OVER)) || ((frameskip_type == 2 || (performance_switch & PERF_SWITCH_ON)) && min_auto_frameskip < MIN_AUTO_FRAMESKIP_MAX)) {
+ if ((performance_switch & PERF_SWITCH_ON) && !(performance_switch & PERF_SWITCH_OVER)) {
frameskip_events += frameskip_counter;
if (frameskip_events > PERF_SWITCH_FRAMESKIP_EVENTS) {
- if ((frameskip_type == 2 || (performance_switch & PERF_SWITCH_ON)) && min_auto_frameskip < MIN_AUTO_FRAMESKIP_MAX) {
- min_auto_frameskip++;
- log_cb(RETRO_LOG_DEBUG, "Auto frameskip: minimum frameskip number set to %d.\n", min_auto_frameskip + 1);
- } else if ((performance_switch & PERF_SWITCH_ON) && !(performance_switch & PERF_SWITCH_OVER))
- increase_performance();
+ increase_performance();
frameskip_events = 0;
perf_ref_frame = current_frame;
perf_ref_audio_buff_occupancy = 0;
@@ -773,17 +757,12 @@ void retro_run(void) {
}
/* 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) || ((frameskip_type == 2 || (performance_switch & PERF_SWITCH_ON)) && min_auto_frameskip))) {
+ 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)
- if ((performance_switch & PERF_SWITCH_ON) && performance_switch > PERF_SWITCH_ON)
- increase_accuracy();
- else if ((frameskip_type == 2 || (performance_switch & PERF_SWITCH_ON)) && min_auto_frameskip) {
- min_auto_frameskip--;
- log_cb(RETRO_LOG_DEBUG, "Auto frameskip: minimum frameskip number set to %d.\n", min_auto_frameskip + 1);
- }
+ increase_accuracy();
perf_ref_frame = current_frame - 1;
perf_ref_audio_buff_occupancy = 0;
frameskip_events = 0;
Commit: f86ca443dd3a02ed13587dcb0d9f338ff79c2f25
https://github.com/scummvm/scummvm/commit/f86ca443dd3a02ed13587dcb0d9f338ff79c2f25
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-07-11T01:18:42+02:00
Commit Message:
LIBRETRO: set auto frameskip based on frame time
Changed paths:
backends/platform/libretro/src/libretro.cpp
diff --git a/backends/platform/libretro/src/libretro.cpp b/backends/platform/libretro/src/libretro.cpp
index dae45d870a7..e93a9e0b33f 100644
--- a/backends/platform/libretro/src/libretro.cpp
+++ b/backends/platform/libretro/src/libretro.cpp
@@ -95,6 +95,7 @@ static uint8 frameskip_events = 0;
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;
@@ -138,7 +139,7 @@ static void retro_audio_buff_status_cb(bool active, unsigned occupancy, bool und
else
audio_status &= ~AUDIO_STATUS_BUFFER_ACTIVE;
- if (underrun_likely)
+ if (occupancy < retro_audio_buff_underrun_threshold)
audio_status |= AUDIO_STATUS_BUFFER_UNDERRUN;
else
audio_status &= ~AUDIO_STATUS_BUFFER_UNDERRUN;
@@ -704,6 +705,8 @@ void retro_run(void) {
audio_latency = (uint32)((8.0f * frame_time_msec) + 0.5f);
audio_latency = (audio_latency + 0x1F) & ~0x1F;
+ retro_audio_buff_underrun_threshold = frame_time_msec * 100 / audio_latency;
+
/* This can only be called from within retro_run() */
environ_cb(RETRO_ENVIRONMENT_SET_MINIMUM_AUDIO_LATENCY, &audio_latency);
audio_status &= ~AUDIO_STATUS_UPDATE_LATENCY;
Commit: 7d846d9a825a50a19e7e17f5bdc82ed28af9291c
https://github.com/scummvm/scummvm/commit/7d846d9a825a50a19e7e17f5bdc82ed28af9291c
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-07-11T01:18:55+02:00
Commit Message:
LIBRETRO: switch thread in GUI on poll event only
Changed paths:
backends/platform/libretro/src/libretro-os-events.cpp
backends/platform/libretro/src/libretro-os-graphics.cpp
diff --git a/backends/platform/libretro/src/libretro-os-events.cpp b/backends/platform/libretro/src/libretro-os-events.cpp
index 69854047c4c..576fc0a7665 100644
--- a/backends/platform/libretro/src/libretro-os-events.cpp
+++ b/backends/platform/libretro/src/libretro-os-events.cpp
@@ -76,7 +76,7 @@ void OSystem_libretro::delayMillis(uint msecs) {
while (elapsed_time < msecs) {
/* When remaining delay would take us past the next thread switch time, we switch immediately
in order to burn as much as possible delay time in the main RetroArch thread as soon as possible. */
- if (msecs - elapsed_time >= ((LibretroTimerManager *)_timerManager)->timeToNextSwitch())
+ if (msecs - elapsed_time >= ((LibretroTimerManager *)_timerManager)->timeToNextSwitch() && !_overlayInGUI)
((LibretroTimerManager *)_timerManager)->checkThread();
else
usleep(1000);
@@ -89,7 +89,7 @@ void OSystem_libretro::delayMillis(uint msecs) {
while (elapsed_time < msecs) {
/* if remaining delay is lower than last amount of time spent on main thread, burn it in emu thread
to avoid exceeding requested delay */
- if (msecs - elapsed_time >= ((LibretroTimerManager *)_timerManager)->spentOnMainThread() && !((LibretroTimerManager *)_timerManager)->timeToNextSwitch())
+ if (msecs - elapsed_time >= ((LibretroTimerManager *)_timerManager)->spentOnMainThread() && !((LibretroTimerManager *)_timerManager)->timeToNextSwitch() && !_overlayInGUI)
((LibretroTimerManager *)_timerManager)->checkThread();
else
usleep(1000);
diff --git a/backends/platform/libretro/src/libretro-os-graphics.cpp b/backends/platform/libretro/src/libretro-os-graphics.cpp
index 3ef0287e0f9..8064cbaf239 100644
--- a/backends/platform/libretro/src/libretro-os-graphics.cpp
+++ b/backends/platform/libretro/src/libretro-os-graphics.cpp
@@ -301,7 +301,7 @@ void OSystem_libretro::updateScreen() {
}
}
- if (! timing_inaccuracies_is_enabled()) {
+ if (! timing_inaccuracies_is_enabled() && !_overlayInGUI) {
_threadSwitchCaller = THREAD_SWITCH_UPDATE;
((LibretroTimerManager *)_timerManager)->checkThread();
}
Commit: d18ad98339aae82282b6cc6839e290c829c39f07
https://github.com/scummvm/scummvm/commit/d18ad98339aae82282b6cc6839e290c829c39f07
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-07-11T01:19:10+02:00
Commit Message:
LIBRETRO: add framerate cap setting
Changed paths:
backends/platform/libretro/include/libretro-core-options-intl.h
backends/platform/libretro/include/libretro-core-options.h
backends/platform/libretro/include/libretro-defs.h
backends/platform/libretro/include/libretro-timer.h
backends/platform/libretro/src/libretro-timer.cpp
backends/platform/libretro/src/libretro.cpp
diff --git a/backends/platform/libretro/include/libretro-core-options-intl.h b/backends/platform/libretro/include/libretro-core-options-intl.h
index f530830ec1e..052da559a91 100644
--- a/backends/platform/libretro/include/libretro-core-options-intl.h
+++ b/backends/platform/libretro/include/libretro-core-options-intl.h
@@ -209,6 +209,19 @@ struct retro_core_option_v2_definition option_defs_it[] = {
},
NULL
},
+
+ {
+ "scummvm_framerate",
+ "Tetto frequenza dei fotogrammi",
+ NULL,
+ "Imposta il limite superiore della frequenza dei fotogrammi. Il cambio di questa impostazione causerà il reset del core.",
+ NULL,
+ "timing",
+ {
+ { NULL, NULL },
+ },
+ NULL
+ },
{
"scummvm_auto_performance_tuner",
"Regolazione automatica performance",
diff --git a/backends/platform/libretro/include/libretro-core-options.h b/backends/platform/libretro/include/libretro-core-options.h
index cf2059ca3c2..5c7befe1d20 100644
--- a/backends/platform/libretro/include/libretro-core-options.h
+++ b/backends/platform/libretro/include/libretro-core-options.h
@@ -276,6 +276,23 @@ struct retro_core_option_v2_definition option_defs_us[] = {
},
"disabled"
},
+ {
+ "scummvm_framerate",
+ "Frame rate cap",
+ NULL,
+ "Set core frame rate upper limit. Changing this setting will reset the core.",
+ NULL,
+ "timing",
+ {
+ { "disabled", NULL },
+ { "60 Hz", NULL },
+ { "50 Hz", NULL },
+ { "30 Hz", NULL },
+ { "25 Hz", NULL },
+ { NULL, NULL },
+ },
+ "disabled"
+ },
{
"scummvm_auto_performance_tuner",
"Auto performance tuner",
diff --git a/backends/platform/libretro/include/libretro-defs.h b/backends/platform/libretro/include/libretro-defs.h
index 84a7b22f173..dffa0690d8b 100644
--- a/backends/platform/libretro/include/libretro-defs.h
+++ b/backends/platform/libretro/include/libretro-defs.h
@@ -19,8 +19,8 @@
#define LIBRETRO_DEFS_H
#define SAMPLE_RATE 48000
-#define REFRESH_RATE 60
-#define FRAMESKIP_MAX REFRESH_RATE / 2
+#define DEFAULT_REFRESH_RATE 60
+#define FRAMESKIP_MAX DEFAULT_REFRESH_RATE / 2
// Audio status
#define AUDIO_STATUS_MUTE (1 << 0)
@@ -28,14 +28,15 @@
#define AUDIO_STATUS_BUFFER_ACTIVE (1 << 2)
#define AUDIO_STATUS_BUFFER_UNDERRUN (1 << 3)
#define AUDIO_STATUS_UPDATE_LATENCY (1 << 4)
+#define AUDIO_STATUS_UPDATE_AV_INFO (1 << 5)
// Performance switcher
-#define PERF_SWITCH_FRAMESKIP_EVENTS REFRESH_RATE / 2
+#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 REFRESH_RATE * 30
+#define PERF_SWITCH_RESET_REST DEFAULT_REFRESH_RATE * 30
// Thread switch caller
#define THREAD_SWITCH_POLL (1 << 0)
diff --git a/backends/platform/libretro/include/libretro-timer.h b/backends/platform/libretro/include/libretro-timer.h
index 44cdb7b5308..1889b288f21 100644
--- a/backends/platform/libretro/include/libretro-timer.h
+++ b/backends/platform/libretro/include/libretro-timer.h
@@ -26,7 +26,7 @@ class LibretroTimerManager : public DefaultTimerManager {
uint32 _nextSwitchTime;
uint32 _spentOnMainThread;
public:
- LibretroTimerManager(uint32 refresh_rate = REFRESH_RATE);
+ LibretroTimerManager(uint32 refresh_rate);
~LibretroTimerManager(void) {};
void switchThread(void);
void checkThread(void);
diff --git a/backends/platform/libretro/src/libretro-timer.cpp b/backends/platform/libretro/src/libretro-timer.cpp
index 13e81be4111..49a6aeedb1d 100644
--- a/backends/platform/libretro/src/libretro-timer.cpp
+++ b/backends/platform/libretro/src/libretro-timer.cpp
@@ -23,8 +23,6 @@
#include "backends/platform/libretro/include/libretro-defs.h"
LibretroTimerManager::LibretroTimerManager(uint32 refresh_rate) {
- if (! refresh_rate > 0)
- refresh_rate = REFRESH_RATE;
_interval = 1000 / refresh_rate / 2;
_nextSwitchTime = _interval + g_system->getMillis();
}
diff --git a/backends/platform/libretro/src/libretro.cpp b/backends/platform/libretro/src/libretro.cpp
index e93a9e0b33f..6660aa89ac5 100644
--- a/backends/platform/libretro/src/libretro.cpp
+++ b/backends/platform/libretro/src/libretro.cpp
@@ -101,8 +101,8 @@ static uint8 performance_switch = 0;
static uint32 perf_ref_frame = 0;
static uint32 perf_ref_audio_buff_occupancy = 0;
-float frame_rate;
-static uint16 samples_per_frame = 0; // length in samples per frame
+float frame_rate = 0;
+static uint16 samples_per_frame = 0; // length in samples per frame
static size_t samples_per_frame_buffer_size = 0;
static int16_t *sound_buffer = NULL; // pointer to output buffer
@@ -234,6 +234,20 @@ static void update_variables(void) {
timing_inaccuracies_enabled = true;
}
+ var.key = "scummvm_framerate";
+ var.value = NULL;
+ float old_frame_rate = frame_rate;
+ if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
+ if (strcmp(var.value, "disabled") == 0)
+ frame_rate = environ_cb(RETRO_ENVIRONMENT_GET_TARGET_REFRESH_RATE, &frame_rate) ? frame_rate : DEFAULT_REFRESH_RATE;
+ else {
+ char frame_rate_var[3] = {0};
+ strncpy(frame_rate_var, var.value, 2);
+ frame_rate = (float)atof(frame_rate_var);
+ }
+ } else
+ frame_rate = DEFAULT_REFRESH_RATE;
+
var.key = "scummvm_frameskip_threshold";
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
frameskip_threshold = (uint8)strtol(var.value, NULL, 10);
@@ -284,8 +298,13 @@ static void update_variables(void) {
}
}
- if (old_frameskip_type != frameskip_type) {
+ if (old_frameskip_type != frameskip_type || old_frame_rate != frame_rate) {
audio_status |= AUDIO_STATUS_UPDATE_LATENCY;
+ if (old_frame_rate != frame_rate) {
+ audio_buffer_init(sample_rate, (uint16) frame_rate);
+ if (g_system)
+ audio_status |= AUDIO_STATUS_UPDATE_AV_INFO;
+ }
}
}
@@ -503,9 +522,7 @@ void retro_init(void) {
struct retro_audio_buffer_status_callback buf_status_cb;
buf_status_cb.callback = retro_audio_buff_status_cb;
audio_status = environ_cb(RETRO_ENVIRONMENT_SET_AUDIO_BUFFER_STATUS_CALLBACK, &buf_status_cb) ? (audio_status | AUDIO_STATUS_BUFFER_SUPPORT) : (audio_status & ~AUDIO_STATUS_BUFFER_SUPPORT);
- frame_rate = environ_cb(RETRO_ENVIRONMENT_GET_TARGET_REFRESH_RATE, &frame_rate) ? frame_rate : REFRESH_RATE;
- audio_buffer_init(SAMPLE_RATE, (uint16) frame_rate);
update_variables();
init_command_params();
@@ -698,6 +715,18 @@ void retro_run(void) {
update_variables();
}
+ if (audio_status & AUDIO_STATUS_UPDATE_AV_INFO){
+ struct retro_system_av_info info;
+ info.geometry.base_width = RES_W;
+ info.geometry.base_height = RES_H;
+ info.geometry.max_width = RES_W;
+ info.geometry.max_height = RES_H;
+ info.geometry.aspect_ratio = 4.0f / 3.0f;
+ info.timing.fps = frame_rate;
+ info.timing.sample_rate = SAMPLE_RATE;
+ environ_cb(RETRO_ENVIRONMENT_SET_SYSTEM_AV_INFO , &info);
+ }
+
if (audio_status & AUDIO_STATUS_UPDATE_LATENCY){
uint32 audio_latency;
float frame_time_msec = 1000.0f / frame_rate;
@@ -712,6 +741,13 @@ void retro_run(void) {
audio_status &= ~AUDIO_STATUS_UPDATE_LATENCY;
}
+ if (audio_status & AUDIO_STATUS_UPDATE_AV_INFO){
+ audio_status &= ~AUDIO_STATUS_UPDATE_AV_INFO;
+ retro_reset();
+ return;
+ }
+
+
/* Setting RA's video or audio driver to null will disable video/audio bits */
int audio_video_enable = 0;
environ_cb(RETRO_ENVIRONMENT_GET_AUDIO_VIDEO_ENABLE, &audio_video_enable);
Commit: 3d67e4bcc1957de637521d73ad55839c3ca561a5
https://github.com/scummvm/scummvm/commit/3d67e4bcc1957de637521d73ad55839c3ca561a5
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-07-11T01:19:25+02:00
Commit Message:
LIBRETRO: add empty audio buffer to use for GUI framerate control
Changed paths:
backends/platform/libretro/src/libretro.cpp
diff --git a/backends/platform/libretro/src/libretro.cpp b/backends/platform/libretro/src/libretro.cpp
index 6660aa89ac5..8e8f461ac73 100644
--- a/backends/platform/libretro/src/libretro.cpp
+++ b/backends/platform/libretro/src/libretro.cpp
@@ -102,10 +102,12 @@ static uint32 perf_ref_frame = 0;
static uint32 perf_ref_audio_buff_occupancy = 0;
float frame_rate = 0;
+uint16 sample_rate = 0;
static uint16 samples_per_frame = 0; // length in samples per frame
static size_t samples_per_frame_buffer_size = 0;
-static int16_t *sound_buffer = NULL; // pointer to output buffer
+static int16_t *sound_buffer = NULL; // pointer to output buffer
+static int16_t *sound_buffer_empty = NULL; // pointer to zeroed output buffer, to regulate GUI FPS
static void log_scummvm_exit_code(void) {
if (retro_get_scummvm_res() == Common::kNoError)
@@ -119,15 +121,15 @@ static void log_scummvm_exit_code(void) {
static void audio_buffer_init(uint16 sample_rate, uint16 frame_rate) {
samples_per_frame = sample_rate / frame_rate;
- samples_per_frame_buffer_size = samples_per_frame << 1 * sizeof(int16_t);
+ samples_per_frame_buffer_size = samples_per_frame << sizeof(int16_t);
- if (sound_buffer)
- sound_buffer = (int16_t *)realloc(sound_buffer, samples_per_frame_buffer_size);
- else
- sound_buffer = (int16_t *)malloc(samples_per_frame_buffer_size);
- if (sound_buffer)
+ sound_buffer = sound_buffer ? (int16_t *)realloc(sound_buffer, samples_per_frame_buffer_size) : (int16_t *)malloc(samples_per_frame_buffer_size);
+ sound_buffer_empty = sound_buffer_empty ? (int16_t *)realloc(sound_buffer_empty, samples_per_frame_buffer_size) : (int16_t *)malloc(samples_per_frame_buffer_size);
+
+ if (sound_buffer && sound_buffer_empty) {
memset(sound_buffer, 0, samples_per_frame_buffer_size);
- else
+ memset(sound_buffer_empty, 0, samples_per_frame_buffer_size);
+ } else
log_cb(RETRO_LOG_ERROR, "audio_buffer_init error.\n");
audio_status |= AUDIO_STATUS_UPDATE_LATENCY;
@@ -829,17 +831,9 @@ void retro_run(void) {
video_cb(screen.getPixels(), screen.w, screen.h, screen.pitch);
}
-#if defined(_3DS)
- /* Hack: 3DS will produce static noise
- * unless we manually send a zeroed
- * audio buffer when no samples are
- * available (i.e. when the overlay
- * is shown) */
- if (audio_status & AUDIO_STATUS_MUTE) {
- audio_buffer_init(SAMPLE_RATE, (uint16) frame_rate);
- }
-#endif
- if (!(audio_status & AUDIO_STATUS_MUTE))
+ if (audio_status & AUDIO_STATUS_MUTE)
+ audio_batch_cb((int16_t *) sound_buffer_empty, samples_per_frame_buffer_size >> sizeof(int16_t));
+ else
audio_batch_cb((int16_t *) sound_buffer, samples_count);
current_frame++;
Commit: 77f7e24097798a9cc076be2d9c9088c4d3940b3b
https://github.com/scummvm/scummvm/commit/77f7e24097798a9cc076be2d9c9088c4d3940b3b
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-07-11T01:19:50+02:00
Commit Message:
LIBRETRO: add sample rate setting
Changed paths:
backends/platform/libretro/include/libretro-core-options-intl.h
backends/platform/libretro/include/libretro-core-options.h
backends/platform/libretro/include/libretro-defs.h
backends/platform/libretro/include/libretro-os.h
backends/platform/libretro/src/libretro-os-base.cpp
backends/platform/libretro/src/libretro.cpp
diff --git a/backends/platform/libretro/include/libretro-core-options-intl.h b/backends/platform/libretro/include/libretro-core-options-intl.h
index 052da559a91..59850076fa4 100644
--- a/backends/platform/libretro/include/libretro-core-options-intl.h
+++ b/backends/platform/libretro/include/libretro-core-options-intl.h
@@ -222,6 +222,18 @@ struct retro_core_option_v2_definition option_defs_it[] = {
},
NULL
},
+ {
+ "scummvm_samplerate",
+ "Frequenza di campionamento",
+ NULL,
+ "Imposta la frequenza di campionamento. Il cambio di questa impostazione causerà il reset del core.",
+ NULL,
+ "timing",
+ {
+ { NULL, NULL },
+ },
+ NULL
+ },
{
"scummvm_auto_performance_tuner",
"Regolazione automatica performance",
diff --git a/backends/platform/libretro/include/libretro-core-options.h b/backends/platform/libretro/include/libretro-core-options.h
index 5c7befe1d20..ccc7b648006 100644
--- a/backends/platform/libretro/include/libretro-core-options.h
+++ b/backends/platform/libretro/include/libretro-core-options.h
@@ -293,6 +293,20 @@ struct retro_core_option_v2_definition option_defs_us[] = {
},
"disabled"
},
+ {
+ "scummvm_samplerate",
+ "Sample rate",
+ NULL,
+ "Set core sample rate. Changing this setting will erset the core.",
+ NULL,
+ "timing",
+ {
+ { "48000 Hz", NULL },
+ { "44100 Hz", NULL },
+ { NULL, NULL },
+ },
+ "48000"
+ },
{
"scummvm_auto_performance_tuner",
"Auto performance tuner",
diff --git a/backends/platform/libretro/include/libretro-defs.h b/backends/platform/libretro/include/libretro-defs.h
index dffa0690d8b..89b284035ea 100644
--- a/backends/platform/libretro/include/libretro-defs.h
+++ b/backends/platform/libretro/include/libretro-defs.h
@@ -18,7 +18,7 @@
#ifndef LIBRETRO_DEFS_H
#define LIBRETRO_DEFS_H
-#define SAMPLE_RATE 48000
+#define DEFAULT_SAMPLE_RATE 48000
#define DEFAULT_REFRESH_RATE 60
#define FRAMESKIP_MAX DEFAULT_REFRESH_RATE / 2
diff --git a/backends/platform/libretro/include/libretro-os.h b/backends/platform/libretro/include/libretro-os.h
index 83d28e49273..773caa1370e 100644
--- a/backends/platform/libretro/include/libretro-os.h
+++ b/backends/platform/libretro/include/libretro-os.h
@@ -37,6 +37,7 @@ extern bool timing_inaccuracies_is_enabled(void);
extern void reset_performance_tuner(void);
extern void retro_osd_notification(const char* msg);
extern float frame_rate;
+extern uint16 sample_rate;
extern const char * retro_get_system_dir(void);
extern const char * retro_get_save_dir(void);
diff --git a/backends/platform/libretro/src/libretro-os-base.cpp b/backends/platform/libretro/src/libretro-os-base.cpp
index 131ef9b1e22..35978080f10 100644
--- a/backends/platform/libretro/src/libretro-os-base.cpp
+++ b/backends/platform/libretro/src/libretro-os-base.cpp
@@ -83,7 +83,8 @@ void OSystem_libretro::initBackend() {
#else
_overlay.create(RES_W_OVERLAY, RES_H_OVERLAY, Graphics::PixelFormat(2, 5, 5, 5, 1, 10, 5, 0, 15));
#endif
- _mixer = new Audio::MixerImpl(SAMPLE_RATE);
+ _mixer = new Audio::MixerImpl(sample_rate);
+ log_cb(RETRO_LOG_DEBUG,"Mixer set up at %dHz\n", sample_rate);
_timerManager = new LibretroTimerManager(frame_rate);
diff --git a/backends/platform/libretro/src/libretro.cpp b/backends/platform/libretro/src/libretro.cpp
index 8e8f461ac73..5ae51c753f7 100644
--- a/backends/platform/libretro/src/libretro.cpp
+++ b/backends/platform/libretro/src/libretro.cpp
@@ -250,6 +250,16 @@ static void update_variables(void) {
} else
frame_rate = DEFAULT_REFRESH_RATE;
+ var.key = "scummvm_samplerate";
+ var.value = NULL;
+ uint16 old_sample_rate = sample_rate;
+ if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
+ char sample_rate_var[6] = {0};
+ strncpy(sample_rate_var, var.value, 5);
+ sample_rate = atoi(sample_rate_var);
+ } else
+ sample_rate = DEFAULT_SAMPLE_RATE;
+
var.key = "scummvm_frameskip_threshold";
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
frameskip_threshold = (uint8)strtol(var.value, NULL, 10);
@@ -300,9 +310,9 @@ static void update_variables(void) {
}
}
- if (old_frameskip_type != frameskip_type || old_frame_rate != frame_rate) {
+ if (old_frameskip_type != frameskip_type || old_frame_rate != frame_rate || old_sample_rate != sample_rate) {
audio_status |= AUDIO_STATUS_UPDATE_LATENCY;
- if (old_frame_rate != frame_rate) {
+ if (old_frame_rate != frame_rate || old_sample_rate != sample_rate) {
audio_buffer_init(sample_rate, (uint16) frame_rate);
if (g_system)
audio_status |= AUDIO_STATUS_UPDATE_AV_INFO;
@@ -478,7 +488,7 @@ void retro_get_system_av_info(struct retro_system_av_info *info) {
info->geometry.max_height = RES_H;
info->geometry.aspect_ratio = 4.0f / 3.0f;
info->timing.fps = frame_rate;
- info->timing.sample_rate = SAMPLE_RATE;
+ info->timing.sample_rate = sample_rate;
}
const char * retro_get_system_dir(void){
@@ -725,7 +735,7 @@ void retro_run(void) {
info.geometry.max_height = RES_H;
info.geometry.aspect_ratio = 4.0f / 3.0f;
info.timing.fps = frame_rate;
- info.timing.sample_rate = SAMPLE_RATE;
+ info.timing.sample_rate = sample_rate;
environ_cb(RETRO_ENVIRONMENT_SET_SYSTEM_AV_INFO , &info);
}
Commit: 0c3e3aaebcaf23de7175a9df5e5c0e13ad2551fd
https://github.com/scummvm/scummvm/commit/0c3e3aaebcaf23de7175a9df5e5c0e13ad2551fd
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-07-11T01:20:05+02:00
Commit Message:
LIBRETRO: JANITORIAL: fix typo in setting description
Changed paths:
backends/platform/libretro/include/libretro-core-options.h
diff --git a/backends/platform/libretro/include/libretro-core-options.h b/backends/platform/libretro/include/libretro-core-options.h
index ccc7b648006..930ca1bc9bb 100644
--- a/backends/platform/libretro/include/libretro-core-options.h
+++ b/backends/platform/libretro/include/libretro-core-options.h
@@ -297,7 +297,7 @@ struct retro_core_option_v2_definition option_defs_us[] = {
"scummvm_samplerate",
"Sample rate",
NULL,
- "Set core sample rate. Changing this setting will erset the core.",
+ "Set core sample rate. Changing this setting will reset the core.",
NULL,
"timing",
{
More information about the Scummvm-git-logs
mailing list