[Scummvm-git-logs] scummvm master -> 90680549f41e95edb22da1e0ea1e86ef7a543fef

spleen1981 noreply at scummvm.org
Tue May 2 20:53:43 UTC 2023


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

Summary:
90680549f4 LIBRETRO: improve auto frameskip


Commit: 90680549f41e95edb22da1e0ea1e86ef7a543fef
    https://github.com/scummvm/scummvm/commit/90680549f41e95edb22da1e0ea1e86ef7a543fef
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-05-02T22:53:35+02:00

Commit Message:
LIBRETRO: improve auto frameskip

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 135fb7d328d..ded1a7c1e8f 100644
--- a/backends/platform/libretro/include/os.h
+++ b/backends/platform/libretro/include/os.h
@@ -25,6 +25,7 @@
 #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 f1b0222be43..a4924f0745d 100644
--- a/backends/platform/libretro/src/libretro.cpp
+++ b/backends/platform/libretro/src/libretro.cpp
@@ -87,6 +87,8 @@ 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;
@@ -742,8 +744,14 @@ 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)
@@ -763,10 +771,14 @@ void retro_run(void) {
 			} else if (skip_frame) {
 				frameskip_counter++;
 				/* Performance counter */
-				if ((performance_switch & PERF_SWITCH_ON) && !(performance_switch & PERF_SWITCH_OVER)) {
+				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)) {
 					frameskip_events += frameskip_counter;
 					if (frameskip_events > PERF_SWITCH_FRAMESKIP_EVENTS) {
-						increase_performance();
+						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();
 						frameskip_events = 0;
 						perf_ref_frame = current_frame;
 						perf_ref_audio_buff_occupancy = 0;
@@ -775,12 +787,17 @@ 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) {
+			if (!skip_frame && (((performance_switch & PERF_SWITCH_ON) && performance_switch > PERF_SWITCH_ON) || ((frameskip_type == 2 || (performance_switch & PERF_SWITCH_ON)) && min_auto_frameskip))) {
 				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();
+						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);
+						}
 					perf_ref_frame = current_frame - 1;
 					perf_ref_audio_buff_occupancy = 0;
 					frameskip_events = 0;




More information about the Scummvm-git-logs mailing list