Skip to content

Commit

Permalink
PKG: optimize libretro-mednafen-wswan (#153)
Browse files Browse the repository at this point in the history
- optimize `mednafen_wswan_libretro` core code
- add PGO data (uclibc)
  • Loading branch information
Apaczer authored Feb 17, 2025
1 parent c43d514 commit 982f6ee
Show file tree
Hide file tree
Showing 17 changed files with 117 additions and 1 deletion.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
From 9872ea07fab71eddfdd52df1840dff0ef5dba36d Mon Sep 17 00:00:00 2001
From: Apaczer <[email protected]>
Date: Sun, 16 Feb 2025 21:00:26 +0100
Subject: [PATCH 1/2] Makefile: optimize & pgo flags

---
Makefile | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 851dd5b..b2e06c6 100644
--- a/Makefile
+++ b/Makefile
@@ -12,6 +12,8 @@ filter_out2 = $(call filter_out1,$(call filter_out1,$1))
unixpath = $(subst \,/,$1)
unixcygpath = /$(subst :,,$(call unixpath,$1))

+PROFILE ?= 0
+
# system platform
ifeq ($(platform),)
platform = unix
@@ -325,9 +327,18 @@ 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 := -fno-PIC
SHARED := -shared -Wl,--no-undefined -Wl,--version-script=link.T
- FLAGS += -fomit-frame-pointer -ffast-math -march=armv5te -mtune=arm926ej-s
+ FLAGS += -fomit-frame-pointer -ffast-math -march=armv5te -mtune=arm926ej-s \
+ -fdata-sections -ffunction-sections -Wl,--gc-sections \
+ -fno-stack-protector -fno-ident -fomit-frame-pointer \
+ -fno-unroll-loops
+ifeq ($(PROFILE), YES)
+ FLAGS += -fprofile-generate=/mnt/profile # rm path if you want dir structure intact at runtime
+ LDFLAGS += -lgcov
+else ifeq ($(PROFILE), APPLY)
+ FLAGS += -fprofile-use -fbranch-probabilities -Wno-error=coverage-mismatch
+endif

# Windows MSVC 2017 all architectures
else ifneq (,$(findstring windows_msvc2017,$(platform)))
@@ -562,7 +573,7 @@ all: $(TARGET)
ifeq ($(DEBUG),1)
FLAGS += -O0 -g
else
- FLAGS += -O2 -DNDEBUG $(EXTRA_GCC_FLAGS)
+ FLAGS += -Ofast -DNDEBUG $(EXTRA_GCC_FLAGS)
endif

ifneq (,$(findstring msvc,$(platform)))
--
2.45.2.windows.1

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
From eaece46af09d9a79466d0dd2f9450356e9c84057 Mon Sep 17 00:00:00 2001
From: Apaczer <[email protected]>
Date: Sun, 16 Feb 2025 23:11:50 +0100
Subject: [PATCH 2/2] lr_core_options: finetune frameskip & samprate

disable 60Hz mode
---
libretro_core_options.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libretro_core_options.h b/libretro_core_options.h
index 462ff2c..22cb9f4 100644
--- a/libretro_core_options.h
+++ b/libretro_core_options.h
@@ -151,7 +151,7 @@ struct retro_core_option_v2_definition option_defs_us[] = {
{ "manual", "Manual" },
{ NULL, NULL },
},
- "disabled"
+ "manual"
},
{
"wswan_frameskip_threshold",
@@ -179,7 +179,7 @@ struct retro_core_option_v2_definition option_defs_us[] = {
{ "60", NULL },
{ NULL, NULL },
},
- "33"
+ "60"
},
{
"wswan_60hz_mode",
@@ -193,7 +193,7 @@ struct retro_core_option_v2_definition option_defs_us[] = {
{ "enabled", NULL },
{ NULL, NULL },
},
- "enabled",
+ "disabled",
},
{
"wswan_sound_sample_rate",
@@ -209,7 +209,7 @@ struct retro_core_option_v2_definition option_defs_us[] = {
{ "48000", NULL },
{ NULL, NULL },
},
- "44100",
+ "11025",
},
{
"wswan_sound_low_pass",
--
2.45.2.windows.1

Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,20 @@ LIBRETRO_MEDNAFEN_WSWAN_VERSION = 32bf70a3032a138baa969c22445f4b7821632c30
LIBRETRO_MEDNAFEN_WSWAN_SITE = $(call github,libretro,beetle-wswan-libretro,$(LIBRETRO_MEDNAFEN_WSWAN_VERSION))
LIBRETRO_MEDNAFEN_WSWAN_LICENSE = GPL-2.0
LIBRETRO_MEDNAFEN_WSWAN_LICENSE_FILES = COPYING
# Optimize build with Profile Guided Optimization (values: 0, YES, APPLY)
LIBRETRO_MEDNAFEN_WSWAN_PGO ?= APPLY

ifeq ($(LIBRETRO_MEDNAFEN_WSWAN_PGO), APPLY)
define LIBRETRO_MEDNAFEN_WSWAN_CONFIGURE_CMDS
cp -r $(BASE_DIR)/../board/miyoo/profile/libretro-mednafen-wswan/* $(@D)/
endef
endif

define LIBRETRO_MEDNAFEN_WSWAN_BUILD_CMDS
CFLAGS="$(TARGET_CFLAGS) $(COMPILER_COMMONS_CFLAGS_SO)" \
CXXFLAGS="$(TARGET_CXXFLAGS) $(COMPILER_COMMONS_CXXFLAGS_SO)" \
LDFLAGS="$(TARGET_LDFLAGS) $(COMPILER_COMMONS_LDFLAGS_SO)" \
$(MAKE) CXX="$(TARGET_CXX)" CC="$(TARGET_CC)" -C $(@D)/ platform="$(RETROARCH_LIBRETRO_PLATFORM)"
$(MAKE) PROFILE="$(LIBRETRO_MEDNAFEN_WSWAN_PGO)" CXX="$(TARGET_CXX)" CC="$(TARGET_CC)" -C $(@D)/ platform="$(RETROARCH_LIBRETRO_PLATFORM)"
$(TARGET_STRIP) --strip-unneeded $(@D)/*_libretro.so
endef

Expand Down

0 comments on commit 982f6ee

Please sign in to comment.