Skip to content

Commit

Permalink
Optimize libretro-snes9x2005 core
Browse files Browse the repository at this point in the history
  • Loading branch information
tiopex committed Jan 18, 2024
1 parent 043a0dd commit 68c7806
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 8 deletions.
69 changes: 69 additions & 0 deletions package/libretro-snes9x2005/0001-optimize-flags.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
diff --git a/Makefile b/Makefile
index 07d5368..a64871b 100644
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,8 @@
DEBUG = 0
PERF_TEST = 0
-LOAD_FROM_MEMORY = 1
+LOAD_FROM_MEMORY = 0
USE_BLARGG_APU ?= 0
-LAGFIX = 1
+LAGFIX = 0
USE_OLD_COLOUR_OPS = 0

SPACE :=
@@ -282,11 +282,26 @@ 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 -nostdlib
+ fpic :=
SHARED := -shared -Wl,--version-script=link.T
LIBM :=
- FLAGS += -fomit-frame-pointer -ffast-math -march=armv5te -mtune=arm926ej-s
- FLAGS += -DFAST_ALIGNED_LSB_WORD_ACCESS -fno-unroll-loops
+ CFLAGS += -fomit-frame-pointer -ffast-math -flto -mcpu=arm926ej-s \
+ -Ofast -msoft-float -finline-limit=42 -fno-unroll-loops \
+ -fno-ipa-cp -fno-common -fno-stack-protector -fno-guess-branch-probability \
+ -fno-caller-saves -fno-regmove -flto=4 -fwhole-program -fuse-linker-plugin \
+ -fdata-sections -ffunction-sections -Wl,--gc-sections \
+ -fno-stack-protector -fno-ident -fomit-frame-pointer \
+ -falign-functions=1 -falign-jumps=1 -falign-loops=1 \
+ -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-unroll-loops \
+ -fmerge-all-constants -fno-math-errno \
+ -marm
+ CXXFLAGS += $(CFLAGS)
+ CPPFLAGS += $(CFLAGS)
+ ASFLAGS += $(CFLAGS)
+ HAVE_NEON = 0
+ ARCH = arm
+ USE_DYNAREC = 1
+ CFLAGS += -DFAST_ALIGNED_LSB_WORD_ACCESS

# (armv7 a7, hard point, neon based) ###
# NESC, SNESC, C64 mini
@@ -578,7 +593,7 @@ endif
ifeq ($(DEBUG),1)
FLAGS += -O0 -g
else
- FLAGS += -O2 -DNDEBUG
+ FLAGS += -O3 -DNDEBUG
endif

ifneq (,$(findstring msvc,$(platform)))
diff --git a/libretro.c b/libretro.c
index f64b71c..c62a12e 100644
--- a/libretro.c
+++ b/libretro.c
@@ -71,8 +71,8 @@ static unsigned frameskip_type = 0;
static unsigned frameskip_threshold = 0;
static uint16_t frameskip_counter = 0;

-static bool retro_audio_buff_active = false;
-static unsigned retro_audio_buff_occupancy = 0;
+static bool retro_audio_buff_active = true;
+static unsigned retro_audio_buff_occupancy = 64;
static bool retro_audio_buff_underrun = false;
/* Maximum number of consecutive frames that
* can be skipped */
10 changes: 2 additions & 8 deletions package/libretro-snes9x2005/libretro-snes9x2005.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,18 @@ LIBRETRO_SNES9X2005_LICENSE = COPYRIGHT
LIBRETRO_SNES9X2005_LICENSE_FILES = copyright
LIBRETRO_SNES9X2005_NON_COMMERCIAL = y

# Dynarec on all boards
LIBRETRO_SNES9X2005_SUPP_OPT=USE_DYNAREC=1

LIBRETRO_SNES9X2005_SUPP_CFLAGS+=-Wa,-mimplicit-it=thumb
LIBRETRO_SNES9X2005_SUPP_OPT+=ARCH=arm

define LIBRETRO_SNES9X2005_BUILD_CMDS
$(SED) "s|-O2|-O3|g" $(@D)/Makefile
CFLAGS="$(TARGET_CFLAGS) $(COMPILER_COMMONS_CFLAGS_SO) $(LIBRETRO_SNES9X2005_SUPP_CFLAGS)" \
CXXFLAGS="$(TARGET_CXXFLAGS) $(COMPILER_COMMONS_CXXFLAGS_SO) $(LIBRETRO_SNES9X2005_SUPP_CFLAGS)" \
LDFLAGS="$(TARGET_LDFLAGS) $(COMPILER_COMMONS_LDFLAGS_SO)" \
$(MAKE) CXX="$(TARGET_CXX)" CC="$(TARGET_CC)" -C $(@D) platform="$(RETROARCH_LIBRETRO_PLATFORM)" $(LIBRETRO_SNES9X2005_SUPP_OPT) USE_BLARGG_APU=1
$(MAKE) CXX="$(TARGET_CXX)" CC="$(TARGET_CC)" -C $(@D) platform="$(RETROARCH_LIBRETRO_PLATFORM)" $(LIBRETRO_SNES9X2005_SUPP_OPT) USE_BLARGG_APU=0
$(TARGET_STRIP) --strip-unneeded $(@D)/*_libretro.so
endef

define LIBRETRO_SNES9X2005_INSTALL_TARGET_CMDS
mkdir -p "${BINARIES_DIR}/retroarch/cores"
$(INSTALL) -D $(@D)/snes9x2005_plus_libretro.so \
$(INSTALL) -D $(@D)/snes9x2005_libretro.so \
${BINARIES_DIR}/retroarch/cores/snes9x2005_libretro.so
endef

Expand Down

0 comments on commit 68c7806

Please sign in to comment.