Skip to content

Commit

Permalink
Optimize retroarch cores: fceumm, mame2000, snes9x2002, tyrquake, prboom
Browse files Browse the repository at this point in the history
  • Loading branch information
tiopex committed Jan 11, 2024
1 parent eb3ab10 commit e711974
Show file tree
Hide file tree
Showing 7 changed files with 220 additions and 5 deletions.
18 changes: 18 additions & 0 deletions package/libretro-fceumm/0001-optimize-flags.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
diff --git a/Makefile.libretro b/Makefile.libretro
index 522bd06..152101c 100644
--- a/Makefile.libretro
+++ b/Makefile.libretro
@@ -458,9 +458,11 @@ else ifeq ($(platform), miyoo)
CC = /opt/miyoo/usr/bin/arm-linux-gcc
CXX = /opt/miyoo/usr/bin/arm-linux-g++
AR = /opt/miyoo/usr/bin/arm-linux-ar
- fpic := -fPIC
+ fpic :=
SHARED := -shared -Wl,--version-script=src/libretro/link.T -Wl,-no-undefined
- PLATFORM_DEFINES += -fomit-frame-pointer -ffast-math -mcpu=arm926ej-s
+ PLATFORM_DEFINES += -mcpu=arm926ej-s -Wno-write-strings -Wno-sign-compare -fomit-frame-pointer -fno-builtin -fno-common -fpermissive -Ofast -flto -fomit-frame-pointer -fno-builtin \
+ -fno-common -Wno-write-strings -Wno-sign-compare -ffast-math -ftree-vectorize \
+ -funswitch-loops -fno-strict-aliasing
EXTERNAL_ZLIB = 1

# Windows MSVC 2017 all architectures
6 changes: 3 additions & 3 deletions package/libretro-fceumm/libretro-fceumm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
#
################################################################################

# Commit of 2023/09/16
LIBRETRO_FCEUMM_VERSION = 7fad08e5522e5396a1196055fc106be9b5d5de77
# Commit of 2024/01/08
LIBRETRO_FCEUMM_VERSION = 20efbf049918a1000e43fb240fba57ed70887581
LIBRETRO_FCEUMM_SITE = $(call github,libretro,libretro-fceumm,$(LIBRETRO_FCEUMM_VERSION))
LIBRETRO_FCEUMM_LICENSE = GPL-2.0
LIBRETRO_FCEUMM_LICENSE_FILES = Copying

define LIBRETRO_FCEUMM_BUILD_CMDS

$(SED) "s|-O2|-O3|g" $(@D)/Makefile
CFLAGS="$(TARGET_CFLAGS) $(COMPILER_COMMONS_CFLAGS_SO)" \
CXXFLAGS="$(TARGET_CXXFLAGS) $(COMPILER_COMMONS_CXXFLAGS_SO)" \
LDFLAGS="$(TARGET_LDFLAGS) $(COMPILER_COMMONS_LDFLAGS_SO)" \
Expand Down
106 changes: 106 additions & 0 deletions package/libretro-mame2000/0001-optimize.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
diff --git a/Makefile b/Makefile
index 64d8115..63e27cd 100644
--- a/Makefile
+++ b/Makefile
@@ -327,14 +327,14 @@ else ifeq ($(platform), miyoo)
TARGET := $(TARGET_NAME)_libretro.so
CC = /opt/miyoo/usr/bin/arm-linux-gcc
AR = /opt/miyoo/usr/bin/arm-linux-ar
- fpic := -fPIC
+ fpic :=
SHARED := -shared -Wl,--version-script=link.T -Wl,-no-undefined

DISABLE_ERROR_LOGGING := 1
- CFLAGS += -fomit-frame-pointer -ffast-math -march=armv5te -mtune=arm926ej-s
+ CFLAGS += -fomit-frame-pointer -ffast-math -mcpu=arm926ej-s -Ofast -fdata-sections -ffunction-sections -fsingle-precision-constant -flto
ARM = 1
- USE_CYCLONE = 1
- USE_DRZ80 = 1
+ USE_CYCLONE = 0
+ USE_DRZ80 = 0

# Windows MSVC 2010 x64
else ifeq ($(platform), windows_msvc2010_x64)
diff --git a/src/libretro/libretro.c b/src/libretro/libretro.c
index 7fd3662..f9a2794 100644
--- a/src/libretro/libretro.c
+++ b/src/libretro/libretro.c
@@ -51,8 +51,8 @@ static scond_t *libretro_cond = NULL;
static slock_t *libretro_mutex = NULL;
#endif

-unsigned frameskip_type = 0;
-unsigned frameskip_threshold = 0;
+unsigned frameskip_type = 2;
+unsigned frameskip_threshold = 50;
unsigned frameskip_counter = 0;
unsigned frameskip_interval = 0;

@@ -63,10 +63,10 @@ int retro_audio_buff_underrun = false;
unsigned retro_audio_latency = 0;
int update_audio_latency = false;

-int should_skip_frame = 0;
+int should_skip_frame = 1;

-static int sample_rate = 22050;
-static int stereo_enabled = true;
+static int sample_rate = 11025;
+static int stereo_enabled = false;

int game_index = -1;
unsigned short *gp2x_screen15;
@@ -222,7 +222,7 @@ static void update_variables(bool first_run)
var.value = NULL;

prev_frameskip_type = frameskip_type;
- frameskip_type = 0;
+ frameskip_type = 2;

if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
@@ -235,7 +235,7 @@ static void update_variables(bool first_run)
var.key = "mame2000-frameskip_threshold";
var.value = NULL;

- frameskip_threshold = 30;
+ frameskip_threshold = 50;

if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
frameskip_threshold = strtol(var.value, NULL, 10);
@@ -277,7 +277,7 @@ static void update_variables(bool first_run)
var.value = NULL;
var.key = "mame2000-sample_rate";

- sample_rate = 22050;
+ sample_rate = 11025;

if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
sample_rate = strtol(var.value, NULL, 10);
@@ -293,7 +293,7 @@ static void update_variables(bool first_run)
stereo_enabled = false;
}
else
- stereo_enabled = true;
+ stereo_enabled = false;

/* Reinitialise frameskipping, if required */
if (!first_run &&
@@ -304,13 +304,13 @@ static void update_variables(bool first_run)
void retro_set_environment(retro_environment_t cb)
{
static const struct retro_variable vars[] = {
- { "mame2000-frameskip", "Frameskip ; disabled|auto|threshold" },
- { "mame2000-frameskip_threshold", "Frameskip Threshold (%); 30|40|50|60" },
+ { "mame2000-frameskip", "Frameskip ; threshold|disabled|auto" },
+ { "mame2000-frameskip_threshold", "Frameskip Threshold (%); 50|40|50|60" },
{ "mame2000-frameskip_interval", "Frameskip Interval; 1|2|3|4|5|6|7|8|9" },
{ "mame2000-skip_disclaimer", "Skip Disclaimer; enabled|disabled" },
{ "mame2000-show_gameinfo", "Show Game Information; disabled|enabled" },
- { "mame2000-sample_rate", "Audio Rate (Restart); 22050|11025|22050|32000|44100" },
- { "mame2000-stereo", "Stereo (Restart); enabled|disabled" },
+ { "mame2000-sample_rate", "Audio Rate (Restart); 11025|11025|22050|32000|44100" },
+ { "mame2000-stereo", "Stereo (Restart); disabled|enabled" },
{ NULL, NULL },
};
environ_cb = cb;
4 changes: 2 additions & 2 deletions package/libretro-mame2000/libretro-mame2000.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#
################################################################################

# Commit of 2023/04/25
LIBRETRO_MAME2000_VERSION = 720b8ad4cbd76abd57b9aeced9ba541dc8476f7f
# Commit of 2023/11/01
LIBRETRO_MAME2000_VERSION = 1472da3a39ab14fff8325b1f51a1dfdb8eabb5c8
LIBRETRO_MAME2000_SITE = $(call github,libretro,mame2000-libretro,$(LIBRETRO_MAME2000_VERSION))
LIBRETRO_MAME2000_LICENSE = MAME
LIBRETRO_MAME2000_NON_COMMERCIAL = y
Expand Down
16 changes: 16 additions & 0 deletions package/libretro-prboom/0001-optimize-flags.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff --git a/Makefile b/Makefile
index 1322d47..1b57f43 100644
--- a/Makefile
+++ b/Makefile
@@ -368,9 +368,9 @@ else ifeq ($(platform), miyoo)
CC = /opt/miyoo/usr/bin/arm-linux-gcc
CXX = /opt/miyoo/usr/bin/arm-linux-g++
AR = /opt/miyoo/usr/bin/arm-linux-ar
- fpic := -fPIC
+ fpic :=
SHARED := -shared -Wl,--version-script=libretro/link.T -Wl,-no-undefined
- CFLAGS += -ffast-math -march=armv5te -mtune=arm926ej-s -fomit-frame-pointer
+ CFLAGS += -fomit-frame-pointer -ffast-math -flto -mcpu=arm926ej-s -Ofast
HAVE_LOW_MEMORY = 1

# Windows MSVC 2003 Xbox 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
diff --git a/Makefile b/Makefile
index b6af83f..d6d5d83 100644
--- a/Makefile
+++ b/Makefile
@@ -250,14 +250,19 @@ else ifeq ($(platform), miyoo)
CC = /opt/miyoo/usr/bin/arm-linux-gcc
CXX = /opt/miyoo/usr/bin/arm-linux-g++
AR = /opt/miyoo/usr/bin/arm-linux-ar
- fpic := -fPIC
+ fpic :=
ARM_ASM = 1
ASM_CPU = 0
ASM_SPC700 = 0
SHARED := -shared -Wl,--version-script=libretro/link.T -Wl,--no-undefined
- CFLAGS += -fomit-frame-pointer -ffast-math -fno-unroll-loops -flto -mcpu=arm926ej-s
- CFLAGS += -DFAST_ALIGNED_LSB_WORD_ACCESS
-
+ CFLAGS += -fomit-frame-pointer -ffast-math -flto -mcpu=arm926ej-s -Ofast
+ CFLAGS += -DFAST_ALIGNED_LSB_WORD_ACCESS \
+ -DDINGUX \
+ -DLSB_FIRST \
+ -DPSS_STYLE=1 \
+ -DHAVE_ASPRINTF \
+ -DFRAMESKIP \
+ -D_REENTRANT
# Windows MSVC 2010 x64
else ifeq ($(platform), windows_msvc2010_x64)
CC = cl.exe
@@ -396,7 +401,7 @@ LIBRETRO_DIR := ./libretro
ifeq ($(DEBUG), 1)
DEFINES += -O0 -g
else ifneq (,$(findstring msvc,$(platform)))
-DEFINES += -O2 -DNDEBUG=1
+DEFINES += -O3 -DNDEBUG=1
else
DEFINES += -O3 -DNDEBUG=1
endif
diff --git a/libretro/libretro_core_options.h b/libretro/libretro_core_options.h
index ad03eae..455debb 100644
--- a/libretro/libretro_core_options.h
+++ b/libretro/libretro_core_options.h
@@ -68,7 +68,7 @@ struct retro_core_option_v2_definition option_defs_us[] = {
{ "fixed_interval", "Fixed Interval" },
{ NULL, NULL },
},
- "disabled"
+ "auto"
},
{
"snes9x2002_frameskip_threshold",
@@ -133,7 +133,7 @@ struct retro_core_option_v2_definition option_defs_us[] = {
{ "enabled", NULL },
{ NULL, NULL },
},
- "enabled"
+ "disabled"
},
{
"snes9x2002_low_pass_filter",
16 changes: 16 additions & 0 deletions package/libretro-tyrquake/0001-optimize-flags.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff --git a/Makefile b/Makefile
index ef82d42..bb51b40 100644
--- a/Makefile
+++ b/Makefile
@@ -232,9 +232,9 @@ else ifeq ($(platform), miyoo)
TARGET := $(TARGET_NAME)_libretro.so
CC = /opt/miyoo/usr/bin/arm-linux-gcc
AR = /opt/miyoo/usr/bin/arm-linux-ar
- fpic := -fPIC
+ fpic :=
SHARED := -shared -Wl,--version-script=common/libretro-link.T
- CFLAGS += -DDINGUX -D_MIYOO -fomit-frame-pointer -ffast-math -mcpu=arm926ej-s
+ CFLAGS += -DDINGUX -D_MIYOO -fomit-frame-pointer -ffast-math -mcpu=arm926ej-s -Ofast -fdata-sections -ffunction-sections -fsingle-precision-constant -flto -marm -DARM
HAVE_NETWORKING=0

# Raspberry Pi 1

0 comments on commit e711974

Please sign in to comment.