[Scummvm-git-logs] scummvm master -> b3959adb5fdea4428bed2489437a7b021df1009d

spleen1981 noreply at scummvm.org
Tue Apr 4 13:56:18 UTC 2023


This automated email contains information about 15 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
cd7a8e58cc LIBRETRO: JANITORIAL: fix BUG_REPORT.md typo
c3df289896 LIBRETRO: expose 'consecutive screen updates' as user setting
7c8cc4df52 LIBRETRO: let auto perf tuner override settings
4135efbb68 LIBRETRO: add consecutive screen updates to auto perf tuner
a9ab90c456 LIBRETRO: send NULL to audio_batch_cb if on mute
ad822b3001 LIBRETRO: use auto frameskip with perf tuner
cb04a93042 LIBRETRO: drop OSD for auto perf tuner
a47e0933c5 LIBRETRO: auto perf tuner to upper level
b0f6af2332 LIBRETRO: rename Performance settings group to Timing
5fd7646c12 LIBRETRO: invert consecutive_screen_updates setting action
f1caf916ee LIBRETRO: chenge auto perf tuner logs to debug
c509343b6e LIBRETRO: add auto perf tuner restore feature
ffc7d644ef LIBRETRO: add auto perf tuner reset on engine exit
492dad0fdb LIBRETRO: force framerate reduction for cons screen updates
b3959adb5f LIBRETRO: drop unneeded THREAD_SWITCH_RECT


Commit: cd7a8e58cc435637ac229ff84f2ad985ce8fb1fa
    https://github.com/scummvm/scummvm/commit/cd7a8e58cc435637ac229ff84f2ad985ce8fb1fa
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-04-04T15:55:13+02:00

Commit Message:
LIBRETRO: JANITORIAL: fix BUG_REPORT.md typo

Changed paths:
    backends/platform/libretro/BUG_REPORT.md


diff --git a/backends/platform/libretro/BUG_REPORT.md b/backends/platform/libretro/BUG_REPORT.md
index 6f30a737e04..b1959c150d6 100644
--- a/backends/platform/libretro/BUG_REPORT.md
+++ b/backends/platform/libretro/BUG_REPORT.md
@@ -7,7 +7,7 @@ assignees: ''
 
 ---
 
-## Description
+### Description
 [Description of the bug]
 
 ### Expected behavior


Commit: c3df289896f8b66f552746f66701dbb56a80474b
    https://github.com/scummvm/scummvm/commit/c3df289896f8b66f552746f66701dbb56a80474b
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-04-04T15:55:14+02:00

Commit Message:
LIBRETRO: expose 'consecutive screen updates' as user setting

Changed paths:
    backends/platform/libretro/include/libretro-core-options-intl.h
    backends/platform/libretro/include/libretro-core-options.h
    backends/platform/libretro/src/libretro-os.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 5d1bd36555c..e52980e6cbe 100644
--- a/backends/platform/libretro/include/libretro-core-options-intl.h
+++ b/backends/platform/libretro/include/libretro-core-options-intl.h
@@ -209,6 +209,18 @@ struct retro_core_option_v2_definition option_defs_it[] = {
 		},
 		NULL
 	},
+	{
+		"scummvm_consecutive_screen_updates",
+		"Mostra aggiornamenti schermo consecutivi",
+		NULL,
+		"Mentre libretro si basa su FPS costante, ScummVM può aggiornare lo schermo indipentendemente dal framerate impostato. Se questa opzione è abilitata, 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. Altrimenti solo l'ultimo aggiornamento schermo di una serie consecutiva sarà mostrato. Se 'Consenti inaccuratezze di timing' è abilitato, questa impostazione sarà ignorata e disabilitata.",
+		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 a5d0e6e37b7..d262b6f4a26 100644
--- a/backends/platform/libretro/include/libretro-core-options.h
+++ b/backends/platform/libretro/include/libretro-core-options.h
@@ -276,6 +276,20 @@ struct retro_core_option_v2_definition option_defs_us[] = {
 		},
 		"enabled"
 	},
+	{
+		"scummvm_consecutive_screen_updates",
+		"Show consecutive screen updates",
+		NULL,
+		"While libretro is FPS bounded, ScummVM can update the screen independently from the refresh rate set. If this option is enabled, 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. Otherwise only last screen update of a consecutive series will be shown. If 'Allow Timing Inaccuracies' is enabled, this setting will be ignored and disabled.",
+		NULL,
+		"performance",
+		{
+			{"disabled", NULL},
+			{"enabled", NULL},
+			{NULL, NULL},
+		},
+		"enabled"
+	},
 	{
 		"scummvm_allow_timing_inaccuracies",
 		"Allow Timing Inaccuracies",
diff --git a/backends/platform/libretro/src/libretro-os.cpp b/backends/platform/libretro/src/libretro-os.cpp
index f157920af6c..b3dada27fd3 100644
--- a/backends/platform/libretro/src/libretro-os.cpp
+++ b/backends/platform/libretro/src/libretro-os.cpp
@@ -320,6 +320,7 @@ static Common::String s_saveDir;
 Common::List<Common::Event> _events;
 
 extern bool timing_inaccuracies_is_enabled(void);
+extern bool consecutive_screen_updates_is_enabled(void);
 
 class OSystem_RETRO : public EventsBaseBackend, public PaletteManager {
 public:
@@ -506,7 +507,7 @@ public:
 		/* In a series of consecutive updateScreen calls, additionally switch directly to main thread when
 		(and if) first copyRectToScreen is called between two updateScreen. This reduces audio crackling.
 		Consecutive copyRectToScreen other than first are covered by thread switch triggered by pollEvent or delayMillis. */
-		if (! timing_inaccuracies_is_enabled()) {
+		if (! timing_inaccuracies_is_enabled() && consecutive_screen_updates_is_enabled()) {
 			if (!(_threadSwitchCaller & THREAD_SWITCH_RECT) && (_threadSwitchCaller & THREAD_SWITCH_UPDATE)) {
 				retro_switch_to_main_thread();
 				_threadSwitchCaller |= THREAD_SWITCH_RECT;
@@ -552,7 +553,7 @@ public:
 
 		/* 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()) {
+		if (! timing_inaccuracies_is_enabled() && consecutive_screen_updates_is_enabled()) {
 			if (_threadSwitchCaller & THREAD_SWITCH_UPDATE) {
 				retro_switch_to_main_thread();
 				_threadSwitchCaller &= ~THREAD_SWITCH_RECT;
diff --git a/backends/platform/libretro/src/libretro.cpp b/backends/platform/libretro/src/libretro.cpp
index 99591cd798a..d1946659407 100644
--- a/backends/platform/libretro/src/libretro.cpp
+++ b/backends/platform/libretro/src/libretro.cpp
@@ -91,6 +91,8 @@ static uint8 reduce_framerate_type = 0;
 static uint8 reduce_framerate_shift = 0;
 static uint8 reduce_framerate_countdown = 0;
 
+static bool consecutive_screen_updates = false;
+
 static bool can_dupe = false;
 static uint8 audio_status = 0;
 
@@ -273,6 +275,14 @@ 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 = true;
+		} else
+			consecutive_screen_updates = false;
+	}
+
 	set_audio_buffer_status();
 
 	if (!(audio_status & AUDIO_STATUS_BUFFER_SUPPORT)) {
@@ -309,6 +319,10 @@ bool timing_inaccuracies_is_enabled(){
 	return timing_inaccuracies_enabled || (performance_switch & PERF_SWITCH_ENABLE_TIMING_INACCURACIES);
 }
 
+bool consecutive_screen_updates_is_enabled(){
+	return consecutive_screen_updates;
+}
+
 void parse_command_params(char *cmdline) {
 	int j = 0;
 	int cmdlen = strlen(cmdline);


Commit: 7c8cc4df52028bd24950172ba7b0b8b18fa09fee
    https://github.com/scummvm/scummvm/commit/7c8cc4df52028bd24950172ba7b0b8b18fa09fee
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-04-04T15:55:15+02:00

Commit Message:
LIBRETRO: let auto perf tuner override settings

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 d1946659407..232b56c1b44 100644
--- a/backends/platform/libretro/src/libretro.cpp
+++ b/backends/platform/libretro/src/libretro.cpp
@@ -154,23 +154,36 @@ static void increase_performance() {
 	retro_msg.duration = 3000;
 	retro_msg.msg = "";
 
-	if (!timing_inaccuracies_enabled && !(performance_switch & PERF_SWITCH_ENABLE_TIMING_INACCURACIES)) {
-		retro_msg.msg = "Auto performance tuner: 'Allow Timing Inaccuracies' enabled";
-		log_cb(RETRO_LOG_INFO, "Auto performance tuner: 'Allow Timing Inaccuracies' enabled.\n");
+	if (!(performance_switch & PERF_SWITCH_ENABLE_TIMING_INACCURACIES)) {
 		performance_switch |= PERF_SWITCH_ENABLE_TIMING_INACCURACIES;
-	} else if (reduce_framerate_type != REDUCE_FRAMERATE_SHIFT_AUTO && !(performance_switch & PERF_SWITCH_ENABLE_REDUCE_FRAMERATE)) {
-		retro_msg.msg = "Auto performance tuner: 'Auto reduce framerate' enabled";
-		log_cb(RETRO_LOG_INFO, "Auto performance tuner: 'Auto reduce framerate' enabled.\n");
+		if (!timing_inaccuracies_enabled) {
+			retro_msg.msg = "Auto performance tuner: 'Allow Timing Inaccuracies' enabled";
+			log_cb(RETRO_LOG_INFO, "Auto performance tuner: 'Allow Timing Inaccuracies' enabled.\n");
+			environ_cb(RETRO_ENVIRONMENT_SET_MESSAGE_EXT, &retro_msg);
+			return;
+		}
+	}
+
+	if (!(performance_switch & PERF_SWITCH_ENABLE_REDUCE_FRAMERATE)) {
 		performance_switch |= PERF_SWITCH_ENABLE_REDUCE_FRAMERATE;
-	} else if (frameskip_type != 2 && !(performance_switch & PERF_SWITCH_ENABLE_AUTO_FRAMESKIP)) {
-		retro_msg.msg = "Auto performance tuner: 'Auto frameskip' enabled";
-		log_cb(RETRO_LOG_INFO, "Auto performance tuner: 'Auto frameskip' enabled.\n");
+		if (reduce_framerate_type != REDUCE_FRAMERATE_SHIFT_AUTO) {
+			retro_msg.msg = "Auto performance tuner: 'Auto reduce framerate' enabled";
+			log_cb(RETRO_LOG_INFO, "Auto performance tuner: 'Auto reduce framerate' enabled.\n");
+			environ_cb(RETRO_ENVIRONMENT_SET_MESSAGE_EXT, &retro_msg);
+			return;
+		}
+	}
+
+	if (!(performance_switch & PERF_SWITCH_ENABLE_AUTO_FRAMESKIP)) {
 		performance_switch |= PERF_SWITCH_ENABLE_AUTO_FRAMESKIP;
-	} else
-		performance_switch |= PERF_SWITCH_OVER;
+		if (frameskip_type != 2) {
+			retro_msg.msg = "Auto performance tuner: 'Auto frameskip' enabled";
+			log_cb(RETRO_LOG_INFO, "Auto performance tuner: 'Auto frameskip' enabled.\n");
+			environ_cb(RETRO_ENVIRONMENT_SET_MESSAGE_EXT, &retro_msg);
+		}
+	}
 
-	if (retro_msg.msg[0] != '\0')
-		environ_cb(RETRO_ENVIRONMENT_SET_MESSAGE_EXT, &retro_msg);
+	performance_switch |= PERF_SWITCH_OVER;
 }
 
 static void update_variables(void) {
@@ -316,7 +329,10 @@ static void update_variables(void) {
 }
 
 bool timing_inaccuracies_is_enabled(){
-	return timing_inaccuracies_enabled || (performance_switch & PERF_SWITCH_ENABLE_TIMING_INACCURACIES);
+	if (performance_switch & PERF_SWITCH_ON)
+		return (performance_switch & PERF_SWITCH_ENABLE_TIMING_INACCURACIES);
+	else
+		return timing_inaccuracies_enabled;
 }
 
 bool consecutive_screen_updates_is_enabled(){


Commit: 4135efbb68d6eb0a200e31710d0c6f34c4c099fd
    https://github.com/scummvm/scummvm/commit/4135efbb68d6eb0a200e31710d0c6f34c4c099fd
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-04-04T15:55:15+02:00

Commit Message:
LIBRETRO: add consecutive screen updates to auto perf tuner

Changed paths:
    backends/platform/libretro/include/os.h
    backends/platform/libretro/src/libretro.cpp


diff --git a/backends/platform/libretro/include/os.h b/backends/platform/libretro/include/os.h
index 3ee08980d54..8c83b5e41fa 100644
--- a/backends/platform/libretro/include/os.h
+++ b/backends/platform/libretro/include/os.h
@@ -35,11 +35,12 @@
 
 // Performance switcher
 #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_ENABLE_REDUCE_FRAMERATE       (1 << 2)
-#define PERF_SWITCH_ENABLE_AUTO_FRAMESKIP         (1 << 3)
-#define PERF_SWITCH_OVER                          (1 << 4)
+#define PERF_SWITCH_ON                                  (1 << 0)
+#define PERF_SWITCH_ENABLE_TIMING_INACCURACIES          (1 << 1)
+#define PERF_SWITCH_ENABLE_REDUCE_FRAMERATE             (1 << 2)
+#define PERF_SWITCH_ENABLE_AUTO_FRAMESKIP               (1 << 3)
+#define PERF_SWITCH_DISABLE_CONSECUTIVE_SCREEN_UPDATES  (1 << 4)
+#define PERF_SWITCH_OVER                                (1 << 5)
 
 // Reduce framerate
 #define REDUCE_FRAMERATE_TAIL           REFRESH_RATE / 2
diff --git a/backends/platform/libretro/src/libretro.cpp b/backends/platform/libretro/src/libretro.cpp
index 232b56c1b44..9f0f7b2060e 100644
--- a/backends/platform/libretro/src/libretro.cpp
+++ b/backends/platform/libretro/src/libretro.cpp
@@ -154,6 +154,16 @@ static void increase_performance() {
 	retro_msg.duration = 3000;
 	retro_msg.msg = "";
 
+	if (!(performance_switch & PERF_SWITCH_DISABLE_CONSECUTIVE_SCREEN_UPDATES)) {
+		performance_switch |= PERF_SWITCH_DISABLE_CONSECUTIVE_SCREEN_UPDATES;
+		if (consecutive_screen_updates) {
+			retro_msg.msg = "Auto performance tuner: 'Show consecutive screen updates' disabled";
+			log_cb(RETRO_LOG_INFO, "Auto performance tuner: 'Show consecutive screen updates' disabled.\n");
+			environ_cb(RETRO_ENVIRONMENT_SET_MESSAGE_EXT, &retro_msg);
+			return;
+		}
+	}
+
 	if (!(performance_switch & PERF_SWITCH_ENABLE_TIMING_INACCURACIES)) {
 		performance_switch |= PERF_SWITCH_ENABLE_TIMING_INACCURACIES;
 		if (!timing_inaccuracies_enabled) {
@@ -336,7 +346,10 @@ bool timing_inaccuracies_is_enabled(){
 }
 
 bool consecutive_screen_updates_is_enabled(){
-	return consecutive_screen_updates;
+	if (performance_switch & PERF_SWITCH_ON)
+		return !(performance_switch & PERF_SWITCH_DISABLE_CONSECUTIVE_SCREEN_UPDATES);
+	else
+		return consecutive_screen_updates;
 }
 
 void parse_command_params(char *cmdline) {


Commit: a9ab90c45679066a7567a1a51e9c8e53cb18126a
    https://github.com/scummvm/scummvm/commit/a9ab90c45679066a7567a1a51e9c8e53cb18126a
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-04-04T15:55:16+02:00

Commit Message:
LIBRETRO: send NULL to audio_batch_cb if on mute

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 9f0f7b2060e..e02e362cc8b 100644
--- a/backends/platform/libretro/src/libretro.cpp
+++ b/backends/platform/libretro/src/libretro.cpp
@@ -816,7 +816,7 @@ void retro_run(void) {
 				audio_buffer_init(SAMPLE_RATE, (uint16) frame_rate);
 			}
 #endif
-			audio_batch_cb((int16_t *) sound_buffer, samples_count);
+			audio_batch_cb((audio_status & AUDIO_STATUS_MUTE) ? NULL : (int16_t *) sound_buffer, samples_count); // Set to NULL to skip sound rendering
 
 			current_frame++;
 


Commit: ad822b300180413fbca7d3f815f02eda49e7f821
    https://github.com/scummvm/scummvm/commit/ad822b300180413fbca7d3f815f02eda49e7f821
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-04-04T15:55:17+02:00

Commit Message:
LIBRETRO: use auto frameskip with perf tuner

Changed paths:
    backends/platform/libretro/include/os.h
    backends/platform/libretro/src/libretro.cpp


diff --git a/backends/platform/libretro/include/os.h b/backends/platform/libretro/include/os.h
index 8c83b5e41fa..9fd85d4492b 100644
--- a/backends/platform/libretro/include/os.h
+++ b/backends/platform/libretro/include/os.h
@@ -34,13 +34,12 @@
 #define AUDIO_STATUS_UPDATE_LATENCY     (1 << 4)
 
 // Performance switcher
-#define PERF_SWITCH_FRAMESKIP_EVENTS              REFRESH_RATE * 2
+#define PERF_SWITCH_FRAMESKIP_EVENTS                    2
 #define PERF_SWITCH_ON                                  (1 << 0)
 #define PERF_SWITCH_ENABLE_TIMING_INACCURACIES          (1 << 1)
 #define PERF_SWITCH_ENABLE_REDUCE_FRAMERATE             (1 << 2)
-#define PERF_SWITCH_ENABLE_AUTO_FRAMESKIP               (1 << 3)
-#define PERF_SWITCH_DISABLE_CONSECUTIVE_SCREEN_UPDATES  (1 << 4)
-#define PERF_SWITCH_OVER                                (1 << 5)
+#define PERF_SWITCH_DISABLE_CONSECUTIVE_SCREEN_UPDATES  (1 << 3)
+#define PERF_SWITCH_OVER                                (1 << 4)
 
 // Reduce framerate
 #define REDUCE_FRAMERATE_TAIL           REFRESH_RATE / 2
diff --git a/backends/platform/libretro/src/libretro.cpp b/backends/platform/libretro/src/libretro.cpp
index e02e362cc8b..b6494c427fe 100644
--- a/backends/platform/libretro/src/libretro.cpp
+++ b/backends/platform/libretro/src/libretro.cpp
@@ -184,15 +184,6 @@ static void increase_performance() {
 		}
 	}
 
-	if (!(performance_switch & PERF_SWITCH_ENABLE_AUTO_FRAMESKIP)) {
-		performance_switch |= PERF_SWITCH_ENABLE_AUTO_FRAMESKIP;
-		if (frameskip_type != 2) {
-			retro_msg.msg = "Auto performance tuner: 'Auto frameskip' enabled";
-			log_cb(RETRO_LOG_INFO, "Auto performance tuner: 'Auto frameskip' enabled.\n");
-			environ_cb(RETRO_ENVIRONMENT_SET_MESSAGE_EXT, &retro_msg);
-		}
-	}
-
 	performance_switch |= PERF_SWITCH_OVER;
 }
 
@@ -737,14 +728,6 @@ void retro_run(void) {
 		delayMillis call in ScummVM thread.
 		*/
 		do {
-			/* Performance counter */
-			if ((performance_switch & PERF_SWITCH_ON) && !(performance_switch & PERF_SWITCH_OVER) && (audio_status & AUDIO_STATUS_BUFFER_UNDERRUN) && !(audio_status & AUDIO_STATUS_MUTE)) {
-				frameskip_events++;
-				if (frameskip_events > PERF_SWITCH_FRAMESKIP_EVENTS) {
-					increase_performance();
-					frameskip_events = 0;
-				}
-			}
 
 			/* Framerate reduction using sound buffer size */
 			if (reduce_framerate_type == REDUCE_FRAMERATE_SHIFT_AUTO || (performance_switch & PERF_SWITCH_ENABLE_REDUCE_FRAMERATE)) {
@@ -766,7 +749,7 @@ void retro_run(void) {
 			}
 
 			/* Determine frameskip need based on settings */
-			if ((frameskip_type == 2) || (performance_switch & PERF_SWITCH_ENABLE_AUTO_FRAMESKIP))
+			if ((frameskip_type == 2) || (performance_switch & PERF_SWITCH_ON))
 				skip_frame = (audio_status & AUDIO_STATUS_BUFFER_UNDERRUN);
 			else if (frameskip_type == 1)
 				skip_frame = !(current_frame % frameskip_no == 0);
@@ -782,6 +765,14 @@ void retro_run(void) {
 				log_cb(RETRO_LOG_DEBUG, "%d frame(s) skipped\n",frameskip_counter);
 				skip_frame = false;
 				frameskip_counter = 0;
+				/* Performance counter */
+				if ((performance_switch & PERF_SWITCH_ON) && !(performance_switch & PERF_SWITCH_OVER)) {
+					frameskip_events++;
+					if (frameskip_events > PERF_SWITCH_FRAMESKIP_EVENTS) {
+					increase_performance();
+						frameskip_events = 0;
+					}
+				}
 
 			/* Keep on skipping frames if flagged */
 			} else if (skip_frame)


Commit: cb04a930428bcf3ec3feb4fe89a061219c12a739
    https://github.com/scummvm/scummvm/commit/cb04a930428bcf3ec3feb4fe89a061219c12a739
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-04-04T15:55:17+02:00

Commit Message:
LIBRETRO: drop OSD for auto perf tuner

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 b6494c427fe..4b60366b34b 100644
--- a/backends/platform/libretro/src/libretro.cpp
+++ b/backends/platform/libretro/src/libretro.cpp
@@ -148,18 +148,10 @@ static void set_audio_buffer_status() {
 }
 
 static void increase_performance() {
-	struct retro_message_ext retro_msg;
-	retro_msg.type = RETRO_MESSAGE_TYPE_NOTIFICATION;
-	retro_msg.target = RETRO_MESSAGE_TARGET_OSD;
-	retro_msg.duration = 3000;
-	retro_msg.msg = "";
-
 	if (!(performance_switch & PERF_SWITCH_DISABLE_CONSECUTIVE_SCREEN_UPDATES)) {
 		performance_switch |= PERF_SWITCH_DISABLE_CONSECUTIVE_SCREEN_UPDATES;
 		if (consecutive_screen_updates) {
-			retro_msg.msg = "Auto performance tuner: 'Show consecutive screen updates' disabled";
 			log_cb(RETRO_LOG_INFO, "Auto performance tuner: 'Show consecutive screen updates' disabled.\n");
-			environ_cb(RETRO_ENVIRONMENT_SET_MESSAGE_EXT, &retro_msg);
 			return;
 		}
 	}
@@ -167,9 +159,7 @@ static void increase_performance() {
 	if (!(performance_switch & PERF_SWITCH_ENABLE_TIMING_INACCURACIES)) {
 		performance_switch |= PERF_SWITCH_ENABLE_TIMING_INACCURACIES;
 		if (!timing_inaccuracies_enabled) {
-			retro_msg.msg = "Auto performance tuner: 'Allow Timing Inaccuracies' enabled";
 			log_cb(RETRO_LOG_INFO, "Auto performance tuner: 'Allow Timing Inaccuracies' enabled.\n");
-			environ_cb(RETRO_ENVIRONMENT_SET_MESSAGE_EXT, &retro_msg);
 			return;
 		}
 	}
@@ -177,9 +167,7 @@ static void increase_performance() {
 	if (!(performance_switch & PERF_SWITCH_ENABLE_REDUCE_FRAMERATE)) {
 		performance_switch |= PERF_SWITCH_ENABLE_REDUCE_FRAMERATE;
 		if (reduce_framerate_type != REDUCE_FRAMERATE_SHIFT_AUTO) {
-			retro_msg.msg = "Auto performance tuner: 'Auto reduce framerate' enabled";
 			log_cb(RETRO_LOG_INFO, "Auto performance tuner: 'Auto reduce framerate' enabled.\n");
-			environ_cb(RETRO_ENVIRONMENT_SET_MESSAGE_EXT, &retro_msg);
 			return;
 		}
 	}
@@ -769,7 +757,7 @@ void retro_run(void) {
 				if ((performance_switch & PERF_SWITCH_ON) && !(performance_switch & PERF_SWITCH_OVER)) {
 					frameskip_events++;
 					if (frameskip_events > PERF_SWITCH_FRAMESKIP_EVENTS) {
-					increase_performance();
+						increase_performance();
 						frameskip_events = 0;
 					}
 				}


Commit: a47e0933c51d47340f8d01577e0e54eece21a0d8
    https://github.com/scummvm/scummvm/commit/a47e0933c51d47340f8d01577e0e54eece21a0d8
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-04-04T15:55:18+02:00

Commit Message:
LIBRETRO: auto perf tuner to upper level
- add platform dependant flag to set default value

Changed paths:
    backends/platform/libretro/Makefile
    backends/platform/libretro/include/libretro-core-options-intl.h
    backends/platform/libretro/include/libretro-core-options.h


diff --git a/backends/platform/libretro/Makefile b/backends/platform/libretro/Makefile
index d5b9b99a731..c09ea54c3f4 100644
--- a/backends/platform/libretro/Makefile
+++ b/backends/platform/libretro/Makefile
@@ -37,7 +37,7 @@ RM_REC    = rm -rf
 # Raspberry Pi 3 (64 bit)
 ifeq ($(platform), rpi3_64)
    TARGET   = $(TARGET_NAME)_libretro.so
-   DEFINES += -fPIC -D_ARM_ASSEM_ -DUSE_CXX11 -DARM
+   DEFINES += -fPIC -D_ARM_ASSEM_ -DUSE_CXX11 -DARM -DDEFAULT_PERF_TUNER
    LDFLAGS += -shared -Wl,--version-script=$(ROOT_PATH)/link.T -fPIC
    CFLAGS  += -fPIC -mcpu=cortex-a53 -mtune=cortex-a53 -fomit-frame-pointer -ffast-math
    CXXFLAGS = $(CFLAGS) -frtti -std=c++11
@@ -90,7 +90,7 @@ endif
 # QNX
 else ifeq ($(platform), qnx)
    TARGET  := $(TARGET_NAME)_libretro_$(platform).so
-   DEFINES += -fPIC -DSYSTEM_NOT_SUPPORTING_D_TYPE
+   DEFINES += -fPIC -DSYSTEM_NOT_SUPPORTING_D_TYPE -DDEFAULT_PERF_TUNER
    LDFLAGS += -shared -Wl,--version-script=$(ROOT_PATH)/link.T -fPIC
    CC = qcc -Vgcc_ntoarmv7le
    CXX = QCC -Vgcc_ntoarmv7le
@@ -101,7 +101,7 @@ else ifeq ($(platform), qnx)
 # Genode
 else ifeq ($(platform), genode)
    TARGET  := libretro.so
-   DEFINES += -fPIC -DSYSTEM_NOT_SUPPORTING_D_TYPE -DFRONTEND_SUPPORTS_RGB565
+   DEFINES += -fPIC -DSYSTEM_NOT_SUPPORTING_D_TYPE -DFRONTEND_SUPPORTS_RGB565 -DDEFAULT_PERF_TUNER
    C_PKGS   = libc
    CXX_PKGS = stdcxx genode-base
    CFLAGS   += -D__GENODE__ $(shell pkg-config --cflags $(C_PKGS))
@@ -130,7 +130,7 @@ else ifeq ($(platform), wii)
    CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
    CXX = $(DEVKITPPC)/bin/powerpc-eabi-g++$(EXE_EXT)
    AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT) rcs
-   DEFINES += -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float -D__ppc__ -I$(DEVKITPRO)/libogc/include
+   DEFINES += -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float -D__ppc__ -I$(DEVKITPRO)/libogc/include -DDEFAULT_PERF_TUNER
    STATIC_LINKING=1
 
 # Nintendo Switch (libnx)
@@ -175,7 +175,7 @@ else ifeq ($(platform), ctr)
    DEFINES += -DARM11 -D_3DS -I$(CTRULIB)/include
    DEFINES += -march=armv6k -mtune=mpcore -mfloat-abi=hard
    DEFINES += -Wall -mword-relocations
-   DEFINES += -fomit-frame-pointer -ffast-math
+   DEFINES += -fomit-frame-pointer -ffast-math -DDEFAULT_PERF_TUNER
    CXXFLAGS += -std=gnu++11 -fpermissive
    USE_VORBIS = 0
    USE_THEORADEC = 0
@@ -201,7 +201,7 @@ else ifeq ($(platform), gcw0)
    AR = /opt/gcw0-toolchain/usr/bin/mipsel-linux-ar cru
    RANLIB = /opt/gcw0-toolchain/usr/bin/mipsel-linux-ranlib
    DEFINES += -DDINGUX -fomit-frame-pointer -ffast-math -march=mips32 -mtune=mips32r2 -mhard-float -fPIC
-   DEFINES += -ffunction-sections -fdata-sections
+   DEFINES += -ffunction-sections -fdata-sections -DDEFAULT_PERF_TUNER
    LDFLAGS += -shared -Wl,--gc-sections -Wl,--version-script=$(ROOT_PATH)/link.T -fPIC
    CFLAGS += -std=gnu99
    CXXFLAGS += -std=c++11
@@ -222,7 +222,7 @@ else ifeq ($(platform), miyoo)
    AR = /opt/miyoo/usr/bin/arm-linux-ar cru
    RANLIB = /opt/miyoo/usr/bin/arm-linux-ranlib
    DEFINES += -DDINGUX -fomit-frame-pointer -ffast-math -march=armv5te -mtune=arm926ej-s -fPIC
-   DEFINES += -ffunction-sections -fdata-sections
+   DEFINES += -ffunction-sections -fdata-sections -DDEFAULT_PERF_TUNER
    LDFLAGS += -shared -Wl,--gc-sections -Wl,--version-script=$(ROOT_PATH)/link.T -fPIC
    USE_VORBIS = 0
    USE_THEORADEC = 0
@@ -241,7 +241,7 @@ else ifeq ($(platform), miyoomini)
    AR = /usr/bin/arm-linux-gnueabihf-ar cru
    RANLIB = /usr/bin/arm-linux-gnueabihf-ranlib
    DEFINES += -fomit-frame-pointer -ffast-math -marm -march=armv7ve+simd -mtune=cortex-a7 -fPIC
-   DEFINES += -ffunction-sections -fdata-sections
+   DEFINES += -ffunction-sections -fdata-sections -DDEFAULT_PERF_TUNER
    LDFLAGS += -shared -Wl,--gc-sections -Wl,--version-script=$(ROOT_PATH)/link.T -fPIC
    USE_VORBIS = 0
    USE_THEORADEC = 0
@@ -253,7 +253,7 @@ else ifeq ($(platform), miyoomini)
 # ARM v7
 else ifneq (,$(findstring armv7,$(platform)))
    TARGET := $(TARGET_NAME)_libretro.so
-   DEFINES += -fPIC -D_ARM_ASSEM_ -DUSE_CXX11 -marm -DARM
+   DEFINES += -fPIC -D_ARM_ASSEM_ -DUSE_CXX11 -marm -DARM -DDEFAULT_PERF_TUNER
    LDFLAGS += -shared -Wl,--version-script=$(ROOT_PATH)/link.T -fPIC
    USE_VORBIS = 0
    USE_THEORADEC = 0
@@ -278,7 +278,7 @@ endif
 # ARM v8
 else ifneq (,$(findstring armv8,$(platform)))
    TARGET := $(TARGET_NAME)_libretro.so
-   DEFINES += -fPIC -D_ARM_ASSEM_ -DARM -marm -mtune=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard -march=armv8-a+crc
+   DEFINES += -fPIC -D_ARM_ASSEM_ -DARM -marm -mtune=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard -march=armv8-a+crc -DDEFAULT_PERF_TUNER
    LDFLAGS += -shared -Wl,--version-script=$(ROOT_PATH)/link.T -fPIC
    CFLAGS   += -fPIC
    HAVE_NEON = 1
diff --git a/backends/platform/libretro/include/libretro-core-options-intl.h b/backends/platform/libretro/include/libretro-core-options-intl.h
index e52980e6cbe..c3899fe0e23 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_auto_performance_tuner",
-		"Regolazione automatica performance",
-		NULL,
-		"Cambio automatico delle impostazioni di performance e salto dei fotogrammi se vengono rilevate performance scadenti durante il gioco. 'Consenti inaccuratezze di timing' e 'Salto dei fotogrammi Auto' saranno temporaneamente abilitati in sequenza per la sola sessione di gioco, se necessario. Le singole impostazioni salvate non saranno modificate.",
-		NULL,
-		NULL,
-		{
-			{NULL, NULL},
-		},
-		NULL
-	},
 	{
 		"scummvm_consecutive_screen_updates",
 		"Mostra aggiornamenti schermo consecutivi",
@@ -249,9 +237,20 @@ 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 = {
 	option_cats_it,
 	option_defs_it
diff --git a/backends/platform/libretro/include/libretro-core-options.h b/backends/platform/libretro/include/libretro-core-options.h
index d262b6f4a26..ff299a0e633 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_auto_performance_tuner",
-		"Auto performance tuner",
-		NULL,
-		"In-game automatic change of performance/frameskip settings if low performances are detected. 'Allow Timing Inaccuracies' and 'Auto Frameskip' will be temporarily set on in sequence, if necessary, for the current game session only. Single saved settings will not be affected.",
-		NULL,
-		"performance",
-		{
-			{"disabled", NULL},
-			{"enabled", NULL},
-			{NULL, NULL},
-		},
-		"enabled"
-	},
 	{
 		"scummvm_consecutive_screen_updates",
 		"Show consecutive screen updates",
@@ -302,11 +288,7 @@ struct retro_core_option_v2_definition option_defs_us[] = {
 			{"enabled", NULL},
 			{NULL, NULL},
 		},
-#if defined(DINGUX) || defined(_3DS)
-		"enabled"
-#else
 		"disabled"
-#endif
 	},
 	{
 		"scummvm_reduce_framerate_type",
@@ -324,6 +306,24 @@ struct retro_core_option_v2_definition option_defs_us[] = {
 		},
 		"disabled"
 	},
+	{
+		"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 },
 };
 


Commit: b0f6af233280d2aafc063dfd514e9545f6edf59d
    https://github.com/scummvm/scummvm/commit/b0f6af233280d2aafc063dfd514e9545f6edf59d
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-04-04T15:55:19+02:00

Commit Message:
LIBRETRO: rename Performance settings group to Timing

Changed paths:
    backends/platform/libretro/include/libretro-core-options-intl.h
    backends/platform/libretro/include/libretro-core-options.h


diff --git a/backends/platform/libretro/include/libretro-core-options-intl.h b/backends/platform/libretro/include/libretro-core-options-intl.h
index c3899fe0e23..de57410467d 100644
--- a/backends/platform/libretro/include/libretro-core-options-intl.h
+++ b/backends/platform/libretro/include/libretro-core-options-intl.h
@@ -81,9 +81,9 @@ struct retro_core_option_v2_category option_cats_it[] = {
 		"Impostazioni per il salto dei fotogrammi"
 	},
 	{
-		"performance",
+		"timing",
 		NULL,
-		"Impostazioni relative alle performance"
+		"Impostazioni relative al timing"
 	},
 	{ NULL, NULL, NULL },
 };
diff --git a/backends/platform/libretro/include/libretro-core-options.h b/backends/platform/libretro/include/libretro-core-options.h
index ff299a0e633..4cb389be31c 100644
--- a/backends/platform/libretro/include/libretro-core-options.h
+++ b/backends/platform/libretro/include/libretro-core-options.h
@@ -83,9 +83,9 @@ struct retro_core_option_v2_category option_cats_us[] = {
 		"Configure frameskip settings"
 	},
 	{
-		"performance",
-		"Performance",
-		"Configure performance settings"
+		"timing",
+		"Timing",
+		"Configure timing settings"
 	},
 	{ NULL, NULL, NULL },
 };
@@ -268,7 +268,7 @@ struct retro_core_option_v2_definition option_defs_us[] = {
 		NULL,
 		"While libretro is FPS bounded, ScummVM can update the screen independently from the refresh rate set. If this option is enabled, 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. Otherwise only last screen update of a consecutive series will be shown. If 'Allow Timing Inaccuracies' is enabled, this setting will be ignored and disabled.",
 		NULL,
-		"performance",
+		"timing",
 		{
 			{"disabled", NULL},
 			{"enabled", NULL},
@@ -282,7 +282,7 @@ struct retro_core_option_v2_definition option_defs_us[] = {
 		NULL,
 		"Allow timing inaccuracies that reduces CPU requirements. Though most timing deviations are imperceptible, in some cases it may introduce audio sync/timing issues, hence this option should be enabled only if full speed cannot be reached otherwise.",
 		NULL,
-		"performance",
+		"timing",
 		{
 			{"disabled", NULL},
 			{"enabled", NULL},
@@ -296,7 +296,7 @@ struct retro_core_option_v2_definition option_defs_us[] = {
 		NULL,
 		"Reduces current framerate to reduce CPU requirements. 'Auto' mode temporarily reduces the framerate as needed when audio buffer underrun is detected, while the in the other modes the reduction is constant.",
 		NULL,
-		"performance",
+		"timing",
 		{
 			{ "disabled", NULL },
 			{ "auto", "Auto" },


Commit: 5fd7646c12d6871a87e18137986a380caa9b02c4
    https://github.com/scummvm/scummvm/commit/5fd7646c12d6871a87e18137986a380caa9b02c4
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-04-04T15:55:20+02:00

Commit Message:
LIBRETRO: invert consecutive_screen_updates setting action

Changed paths:
    backends/platform/libretro/include/libretro-core-options-intl.h
    backends/platform/libretro/include/libretro-core-options.h
    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 de57410467d..141e02e5898 100644
--- a/backends/platform/libretro/include/libretro-core-options-intl.h
+++ b/backends/platform/libretro/include/libretro-core-options-intl.h
@@ -199,9 +199,9 @@ struct retro_core_option_v2_definition option_defs_it[] = {
 	},
 	{
 		"scummvm_consecutive_screen_updates",
-		"Mostra aggiornamenti schermo consecutivi",
+		"Disabilita aggiornamenti schermo consecutivi",
 		NULL,
-		"Mentre libretro si basa su FPS costante, ScummVM può aggiornare lo schermo indipentendemente dal framerate impostato. Se questa opzione è abilitata, 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. Altrimenti solo l'ultimo aggiornamento schermo di una serie consecutiva sarà mostrato. Se 'Consenti inaccuratezze di timing' è abilitato, questa impostazione sarà ignorata e disabilitata.",
+		"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,
                 {
diff --git a/backends/platform/libretro/include/libretro-core-options.h b/backends/platform/libretro/include/libretro-core-options.h
index 4cb389be31c..d142d679d16 100644
--- a/backends/platform/libretro/include/libretro-core-options.h
+++ b/backends/platform/libretro/include/libretro-core-options.h
@@ -264,9 +264,9 @@ struct retro_core_option_v2_definition option_defs_us[] = {
 	},
 	{
 		"scummvm_consecutive_screen_updates",
-		"Show consecutive screen updates",
+		"Disable consecutive screen updates",
 		NULL,
-		"While libretro is FPS bounded, ScummVM can update the screen independently from the refresh rate set. If this option is enabled, 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. Otherwise only last screen update of a consecutive series will be shown. If 'Allow Timing Inaccuracies' is enabled, this setting will be ignored and disabled.",
+		"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",
 		{
@@ -274,7 +274,7 @@ struct retro_core_option_v2_definition option_defs_us[] = {
 			{"enabled", NULL},
 			{NULL, NULL},
 		},
-		"enabled"
+		"disabled"
 	},
 	{
 		"scummvm_allow_timing_inaccuracies",
diff --git a/backends/platform/libretro/src/libretro.cpp b/backends/platform/libretro/src/libretro.cpp
index 4b60366b34b..0eedbabe839 100644
--- a/backends/platform/libretro/src/libretro.cpp
+++ b/backends/platform/libretro/src/libretro.cpp
@@ -280,9 +280,9 @@ static void update_variables(void) {
 	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 = true;
-		} else
 			consecutive_screen_updates = false;
+		} else
+			consecutive_screen_updates = true;
 	}
 
 	set_audio_buffer_status();


Commit: f1caf916eefdb04e37a33f05cab974f81f14bad8
    https://github.com/scummvm/scummvm/commit/f1caf916eefdb04e37a33f05cab974f81f14bad8
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-04-04T15:55:20+02:00

Commit Message:
LIBRETRO: chenge auto perf tuner logs to debug

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 0eedbabe839..f8062154480 100644
--- a/backends/platform/libretro/src/libretro.cpp
+++ b/backends/platform/libretro/src/libretro.cpp
@@ -150,26 +150,20 @@ static void set_audio_buffer_status() {
 static void increase_performance() {
 	if (!(performance_switch & PERF_SWITCH_DISABLE_CONSECUTIVE_SCREEN_UPDATES)) {
 		performance_switch |= PERF_SWITCH_DISABLE_CONSECUTIVE_SCREEN_UPDATES;
-		if (consecutive_screen_updates) {
-			log_cb(RETRO_LOG_INFO, "Auto performance tuner: 'Show consecutive screen updates' disabled.\n");
-			return;
-		}
+		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;
-		if (!timing_inaccuracies_enabled) {
-			log_cb(RETRO_LOG_INFO, "Auto performance tuner: 'Allow Timing Inaccuracies' enabled.\n");
-			return;
-		}
+		log_cb(RETRO_LOG_DEBUG, "Auto performance tuner: 'Allow Timing Inaccuracies' enabled.\n");
+		return;
 	}
 
 	if (!(performance_switch & PERF_SWITCH_ENABLE_REDUCE_FRAMERATE)) {
 		performance_switch |= PERF_SWITCH_ENABLE_REDUCE_FRAMERATE;
-		if (reduce_framerate_type != REDUCE_FRAMERATE_SHIFT_AUTO) {
-			log_cb(RETRO_LOG_INFO, "Auto performance tuner: 'Auto reduce framerate' enabled.\n");
-			return;
-		}
+		log_cb(RETRO_LOG_DEBUG, "Auto performance tuner: 'Auto reduce framerate' enabled.\n");
+		return;
 	}
 
 	performance_switch |= PERF_SWITCH_OVER;


Commit: c509343b6eed85ec4a98e2f70e33c27b4050c547
    https://github.com/scummvm/scummvm/commit/c509343b6eed85ec4a98e2f70e33c27b4050c547
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-04-04T15:55:21+02:00

Commit Message:
LIBRETRO: add auto perf tuner restore feature

Changed paths:
    backends/platform/libretro/include/os.h
    backends/platform/libretro/src/libretro.cpp


diff --git a/backends/platform/libretro/include/os.h b/backends/platform/libretro/include/os.h
index 9fd85d4492b..351376e84fb 100644
--- a/backends/platform/libretro/include/os.h
+++ b/backends/platform/libretro/include/os.h
@@ -34,15 +34,17 @@
 #define AUDIO_STATUS_UPDATE_LATENCY     (1 << 4)
 
 // Performance switcher
-#define PERF_SWITCH_FRAMESKIP_EVENTS                    2
+#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_ENABLE_REDUCE_FRAMERATE             (1 << 2)
 #define PERF_SWITCH_DISABLE_CONSECUTIVE_SCREEN_UPDATES  (1 << 3)
 #define PERF_SWITCH_OVER                                (1 << 4)
+#define PERF_SWITCH_RESET_THRESHOLD                     60
+#define PERF_SWITCH_RESET_REST                          REFRESH_RATE * 30
 
 // Reduce framerate
-#define REDUCE_FRAMERATE_TAIL           REFRESH_RATE / 2
+#define REDUCE_FRAMERATE_REST           REFRESH_RATE / 2
 #define REDUCE_FRAMERATE_SHIFT_MAX      2
 #define REDUCE_FRAMERATE_SHIFT_AUTO     1
 #define REDUCE_FRAMERATE_SHIFT_HALF     2
diff --git a/backends/platform/libretro/src/libretro.cpp b/backends/platform/libretro/src/libretro.cpp
index f8062154480..a8206745fc2 100644
--- a/backends/platform/libretro/src/libretro.cpp
+++ b/backends/platform/libretro/src/libretro.cpp
@@ -80,7 +80,7 @@ char cmd_params_num;
 int adjusted_RES_W = 0;
 int adjusted_RES_H = 0;
 
-static uint32 current_frame = 0;
+static uint32 current_frame = 1;
 static uint8 frameskip_no;
 static uint8 frameskip_type;
 static uint8 frameskip_threshold;
@@ -98,6 +98,9 @@ static uint8 audio_status = 0;
 
 static unsigned retro_audio_buff_occupancy = 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
 static size_t samples_per_frame_buffer_size = 0;
@@ -169,6 +172,29 @@ static void increase_performance() {
 	performance_switch |= PERF_SWITCH_OVER;
 }
 
+static void increase_accuracy() {
+	performance_switch &= ~PERF_SWITCH_OVER;
+
+	if (performance_switch & PERF_SWITCH_ENABLE_REDUCE_FRAMERATE) {
+		performance_switch &= ~PERF_SWITCH_ENABLE_REDUCE_FRAMERATE;
+		log_cb(RETRO_LOG_DEBUG, "Auto performance tuner: 'Auto reduce framerate' disabled.\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' 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;
+	}
+}
+
 static void update_variables(void) {
 	struct retro_variable var;
 
@@ -716,7 +742,7 @@ void retro_run(void) {
 				if ((audio_status & AUDIO_STATUS_BUFFER_UNDERRUN) && !(audio_status & AUDIO_STATUS_MUTE)) {
 					if (reduce_framerate_shift < REDUCE_FRAMERATE_SHIFT_MAX)
 						reduce_framerate_shift++;
-					reduce_framerate_countdown = REDUCE_FRAMERATE_TAIL;
+					reduce_framerate_countdown = REDUCE_FRAMERATE_REST;
 				}
 				if (reduce_framerate_countdown)
 					reduce_framerate_countdown--;
@@ -747,18 +773,33 @@ void retro_run(void) {
 				log_cb(RETRO_LOG_DEBUG, "%d frame(s) skipped\n",frameskip_counter);
 				skip_frame = false;
 				frameskip_counter = 0;
+			/* Keep on skipping frames if flagged */
+			} else if (skip_frame) {
+				frameskip_counter++;
 				/* Performance counter */
 				if ((performance_switch & PERF_SWITCH_ON) && !(performance_switch & PERF_SWITCH_OVER)) {
 					frameskip_events++;
 					if (frameskip_events > PERF_SWITCH_FRAMESKIP_EVENTS) {
 						increase_performance();
 						frameskip_events = 0;
+						perf_ref_frame = current_frame - 1;
+						perf_ref_audio_buff_occupancy = 0;
 					}
 				}
+			}
 
-			/* Keep on skipping frames if flagged */
-			} else if (skip_frame)
-				frameskip_counter++;
+			/* 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 - 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, unless frameskipping is ongoing */
 			if (!skip_frame)


Commit: ffc7d644efa6eaa3a1a4121559416003fc3fb0b8
    https://github.com/scummvm/scummvm/commit/ffc7d644efa6eaa3a1a4121559416003fc3fb0b8
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-04-04T15:55:22+02:00

Commit Message:
LIBRETRO: add auto perf tuner reset on engine exit

Changed paths:
    backends/platform/libretro/src/libretro-os.cpp
    backends/platform/libretro/src/libretro.cpp


diff --git a/backends/platform/libretro/src/libretro-os.cpp b/backends/platform/libretro/src/libretro-os.cpp
index b3dada27fd3..9b7b7ccf139 100644
--- a/backends/platform/libretro/src/libretro-os.cpp
+++ b/backends/platform/libretro/src/libretro-os.cpp
@@ -321,6 +321,7 @@ Common::List<Common::Event> _events;
 
 extern bool timing_inaccuracies_is_enabled(void);
 extern bool consecutive_screen_updates_is_enabled(void);
+extern void reset_performance_tuner(void);
 
 class OSystem_RETRO : public EventsBaseBackend, public PaletteManager {
 public:
@@ -411,6 +412,10 @@ public:
 		}
 	}
 
+	virtual void engineDone() {
+		reset_performance_tuner();
+	}
+
 	virtual bool hasFeature(Feature f) {
 		return (f == OSystem::kFeatureCursorPalette);
 	}
diff --git a/backends/platform/libretro/src/libretro.cpp b/backends/platform/libretro/src/libretro.cpp
index a8206745fc2..47f05247cbd 100644
--- a/backends/platform/libretro/src/libretro.cpp
+++ b/backends/platform/libretro/src/libretro.cpp
@@ -195,6 +195,13 @@ static void increase_accuracy() {
 	}
 }
 
+void reset_performance_tuner() {
+	if (performance_switch & PERF_SWITCH_ON) {
+		performance_switch = PERF_SWITCH_ON;
+		log_cb(RETRO_LOG_DEBUG, "Auto performance tuner: reset.\n");
+	}
+}
+
 static void update_variables(void) {
 	struct retro_variable var;
 


Commit: 492dad0fdbbe8018090e7aca60d2d4a9def2220d
    https://github.com/scummvm/scummvm/commit/492dad0fdbbe8018090e7aca60d2d4a9def2220d
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-04-04T15:55:22+02:00

Commit Message:
LIBRETRO: force framerate reduction for cons screen updates

Changed paths:
    backends/platform/libretro/src/libretro-os.cpp
    backends/platform/libretro/src/libretro.cpp


diff --git a/backends/platform/libretro/src/libretro-os.cpp b/backends/platform/libretro/src/libretro-os.cpp
index 9b7b7ccf139..acff5dc7f31 100644
--- a/backends/platform/libretro/src/libretro-os.cpp
+++ b/backends/platform/libretro/src/libretro-os.cpp
@@ -508,16 +508,6 @@ public:
 		const uint8_t *src = (const uint8_t *)buf;
 		uint8_t *pix = (uint8_t *)_gameScreen.getPixels();
 		copyRectToSurface(pix, _gameScreen.pitch, src, pitch, x, y, w, h, _gameScreen.format.bytesPerPixel);
-
-		/* In a series of consecutive updateScreen calls, additionally switch directly to main thread when
-		(and if) first copyRectToScreen is called between two updateScreen. This reduces audio crackling.
-		Consecutive copyRectToScreen other than first are covered by thread switch triggered by pollEvent or delayMillis. */
-		if (! timing_inaccuracies_is_enabled() && consecutive_screen_updates_is_enabled()) {
-			if (!(_threadSwitchCaller & THREAD_SWITCH_RECT) && (_threadSwitchCaller & THREAD_SWITCH_UPDATE)) {
-				retro_switch_to_main_thread();
-				_threadSwitchCaller |= THREAD_SWITCH_RECT;
-			}
-		}
 	}
 
 	virtual void updateScreen() {
diff --git a/backends/platform/libretro/src/libretro.cpp b/backends/platform/libretro/src/libretro.cpp
index 47f05247cbd..ce11bec020e 100644
--- a/backends/platform/libretro/src/libretro.cpp
+++ b/backends/platform/libretro/src/libretro.cpp
@@ -755,7 +755,7 @@ void retro_run(void) {
 					reduce_framerate_countdown--;
 				else
 					reduce_framerate_shift = 0;
-			} else if (reduce_framerate_type == REDUCE_FRAMERATE_SHIFT_HALF) {
+			} else if ((reduce_framerate_type == REDUCE_FRAMERATE_SHIFT_HALF) || (getThreadSwitchCaller() & THREAD_SWITCH_UPDATE)) {
 				reduce_framerate_shift = 1;
 			} else if (reduce_framerate_type == REDUCE_FRAMERATE_SHIFT_QUARTER) {
 				reduce_framerate_shift = 2;


Commit: b3959adb5fdea4428bed2489437a7b021df1009d
    https://github.com/scummvm/scummvm/commit/b3959adb5fdea4428bed2489437a7b021df1009d
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-04-04T15:55:33+02:00

Commit Message:
LIBRETRO: drop unneeded THREAD_SWITCH_RECT

Changed paths:
    backends/platform/libretro/include/os.h
    backends/platform/libretro/src/libretro-os.cpp


diff --git a/backends/platform/libretro/include/os.h b/backends/platform/libretro/include/os.h
index 351376e84fb..296d8b6cd0e 100644
--- a/backends/platform/libretro/include/os.h
+++ b/backends/platform/libretro/include/os.h
@@ -54,7 +54,6 @@
 #define THREAD_SWITCH_POLL              (1 << 0)
 #define THREAD_SWITCH_DELAY             (1 << 1)
 #define THREAD_SWITCH_UPDATE            (1 << 2)
-#define THREAD_SWITCH_RECT              (1 << 3)
 
 // Preliminary scan results
 #define TEST_GAME_OK_TARGET_FOUND        0
diff --git a/backends/platform/libretro/src/libretro-os.cpp b/backends/platform/libretro/src/libretro-os.cpp
index acff5dc7f31..4aea3b35fc0 100644
--- a/backends/platform/libretro/src/libretro-os.cpp
+++ b/backends/platform/libretro/src/libretro-os.cpp
@@ -551,7 +551,6 @@ public:
 		if (! timing_inaccuracies_is_enabled() && consecutive_screen_updates_is_enabled()) {
 			if (_threadSwitchCaller & THREAD_SWITCH_UPDATE) {
 				retro_switch_to_main_thread();
-				_threadSwitchCaller &= ~THREAD_SWITCH_RECT;
 			} else {
 				_threadSwitchCaller = THREAD_SWITCH_UPDATE;
 			}




More information about the Scummvm-git-logs mailing list