From: notaz Date: Sun, 13 Oct 2024 18:37:10 +0000 (+0300) Subject: standalone: enable the new threaded stuff X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2ba621768bbc12d0b1982950fa22db0bf9533d54;p=pcsx_rearmed.git standalone: enable the new threaded stuff --- diff --git a/Makefile b/Makefile index c6ce01f0..f510e50e 100644 --- a/Makefile +++ b/Makefile @@ -21,6 +21,10 @@ CFLAGS += -fsanitize=address LDFLAGS += -fsanitize=address #LDFLAGS += -static-libasan endif +ifneq ($(NO_FSECTIONS), 1) +CFLAGS += -ffunction-sections -fdata-sections +LDFLAGS += -Wl,--gc-sections +endif CFLAGS += -DP_HAVE_MMAP=$(if $(NO_MMAP),0,1) \ -DP_HAVE_PTHREAD=$(if $(NO_PTHREAD),0,1) \ -DP_HAVE_POSIX_MEMALIGN=$(if $(NO_POSIX_MEMALIGN),0,1) \ @@ -101,6 +105,13 @@ OBJS += libpcsxcore/gte_neon.o endif libpcsxcore/psxbios.o: CFLAGS += -Wno-nonnull +ifeq "$(USE_ASYNC_CDROM)" "1" +libpcsxcore/cdrom-async.o: CFLAGS += -DUSE_ASYNC_CDROM +frontend/libretro.o: CFLAGS += -DUSE_ASYNC_CDROM +frontend/menu.o: CFLAGS += -DUSE_ASYNC_CDROM +USE_RTHREADS := 1 +endif + # dynarec ifeq "$(DYNAREC)" "lightrec" CFLAGS += -Ideps/lightning/include -Ideps/lightrec -Iinclude/lightning -Iinclude/lightrec \ @@ -341,8 +352,7 @@ frontend/main.o frontend/menu.o: CFLAGS += -include frontend/pandora/ui_feat.h frontend/libpicofe/linux/plat.o: CFLAGS += -DPANDORA USE_PLUGIN_LIB = 1 USE_FRONTEND = 1 -CFLAGS += -gdwarf-3 -ffunction-sections -fdata-sections -LDFLAGS += -Wl,--gc-sections +CFLAGS += -gdwarf-3 endif ifeq "$(PLATFORM)" "caanoo" OBJS += frontend/libpicofe/gp2x/in_gp2x.o frontend/warm/warm.o @@ -376,10 +386,6 @@ OBJS += deps/libretro-common/memmap/memalign.o OBJS += deps/libretro-common/vfs/vfs_implementation_cdrom.o CFLAGS += -DHAVE_CDROM endif -ifeq "$(USE_ASYNC_CDROM)" "1" -CFLAGS += -DUSE_ASYNC_CDROM -USE_RTHREADS := 1 -endif ifeq "$(USE_LIBRETRO_VFS)" "1" OBJS += deps/libretro-common/compat/compat_posix_string.o OBJS += deps/libretro-common/compat/fopen_utf8.o @@ -442,6 +448,8 @@ frontend/main.o: CFLAGS += -DBUILTIN_GPU=$(BUILTIN_GPU) frontend/menu.o frontend/main.o: frontend/revision.h frontend/plat_sdl.o frontend/libretro.o: frontend/revision.h +CFLAGS += $(CFLAGS_LAST) + frontend/libpicofe/%.c: @echo "libpicofe module is missing, please run:" @echo "git submodule init && git submodule update" diff --git a/configure b/configure index be2c4ff4..0d315b68 100755 --- a/configure +++ b/configure @@ -24,25 +24,25 @@ compile_binary() check_define() { - $CC -E -dD $CFLAGS include/arm_features.h | grep -q "$1" || return 1 + $CC -E -dD $CFLAGS include/arm_features.h | grep -v '#undef' | grep -q "$1" || return 1 return 0 } check_define_val() { - $CC -E -dD $CFLAGS include/arm_features.h | grep "$1" | awk '{print $3}' + $CC -E -dD $CFLAGS include/arm_features.h | grep -v '#undef' | grep "$1" | awk '{print $3}' return 0 } # setting options to "yes" or "no" will make that choice default, # "" means "autodetect". -platform_list="generic pandora maemo caanoo libretro" +platform_list="generic pandora maemo caanoo" platform="generic" builtin_gpu_list="neon peops unai unai_old" dynarec_list="ari64 lightrec none" builtin_gpu="" -sound_driver_list="oss alsa pulseaudio sdl libretro" +sound_driver_list="oss alsa pulseaudio sdl" sound_drivers="" plugins="plugins/spunull/spunull.so \ plugins/dfxvideo/gpu_peops.so plugins/gpu_unai_old/gpu_unai_old.so plugins/gpu_unai/gpu_unai.so" @@ -56,6 +56,7 @@ have_tslib="" have_gles="" have_c64x_dsp="" dynarec="" +multithreading="yes" need_sdl="no" need_xlib="no" need_libpicofe="yes" @@ -109,21 +110,20 @@ set_platform() optimize_cortexa8="yes" have_arm_neon="yes" need_xlib="yes" + multithreading="no" ;; maemo) drc_cache_base="yes" optimize_cortexa8="yes" have_arm_neon="yes" + multithreading="no" ;; caanoo) sound_drivers="oss" drc_cache_base="yes" optimize_arm926ej="yes" need_warm="yes" - ;; - libretro) - sound_drivers="libretro" - need_libpicofe="no" + multithreading="no" ;; *) fail "unsupported platform: $platform" @@ -146,6 +146,10 @@ for opt do ;; --disable-neon) have_arm_neon="no" ;; + --enable-threads) multithreading="yes" + ;; + --disable-threads) multithreading="no" + ;; --dynarec=*) dynarec="$optarg" ;; --disable-dynarec) dynarec="no" @@ -166,6 +170,8 @@ if [ "$show_help" = "yes" ]; then echo " available: $sound_driver_list" echo " --enable-neon" echo " --disable-neon enable/disable ARM NEON optimizations [guessed]" + echo " --enable-threads" + echo " --disable-threads enable/disable multithreaded features [guessed]" echo " --dynarec=NAME select dynamic recompiler [guessed]" echo " available: $dynarec_list" echo "influential environment variables:" @@ -340,10 +346,6 @@ generic) maemo) CFLAGS="$CFLAGS -DMAEMO -DMAEMO_CHANGES" ;; -libretro) - CFLAGS="$CFLAGS -fPIC" - MAIN_LDFLAGS="$MAIN_LDFLAGS -shared -Wl,--no-undefined" - ;; esac # header/library presence tests @@ -570,6 +572,7 @@ echo "tslib support $have_tslib" if [ "$platform" = "generic" ]; then echo "OpenGL ES output $have_gles" fi +echo "multithreading $multithreading" echo "# Automatically generated by configure" > $config_mak printf "# Configured with:" >> $config_mak @@ -587,9 +590,6 @@ echo "MAIN_LDLIBS += $MAIN_LDLIBS" >> $config_mak echo "PLUGIN_CFLAGS += $PLUGIN_CFLAGS" >> $config_mak echo >> $config_mak -if [ "$platform" = "libretro" ]; then - echo "TARGET = libretro.so" >> $config_mak -fi echo "ARCH = $ARCH" >> $config_mak echo "PLATFORM = $platform" >> $config_mak echo "BUILTIN_GPU = $builtin_gpu" >> $config_mak @@ -616,6 +616,10 @@ fi if [ "$have_c64x_dsp" = "yes" ]; then echo "HAVE_C64_TOOLS = 1" >> $config_mak fi +if [ "$multithreading" = "yes" ]; then + echo "USE_ASYNC_CDROM = 1" >> $config_mak + echo "NDRC_THREAD = 1" >> $config_mak +fi # use pandora's skin (for now) test -e skin || ln -s frontend/pandora/skin skin diff --git a/frontend/main.c b/frontend/main.c index 750e5661..0bb4a6df 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -14,6 +14,9 @@ #if !defined(_WIN32) && !defined(NO_DYLIB) #include #endif +#ifdef HAVE_CPU_FEATURES +#include "features/features_cpu.h" +#endif #include "main.h" #include "plugin.h" @@ -510,6 +513,9 @@ int emu_core_preinit(void) int emu_core_init(void) { SysPrintf("Starting PCSX-ReARMed " REV "%s\n", get_build_info()); +#ifdef HAVE_CPU_FEATURES + SysPrintf("%d cpu core(s) detected\n", cpu_features_get_core_amount()); +#endif #ifndef NO_FRONTEND check_profile(); diff --git a/frontend/menu.c b/frontend/menu.c index 49ffed9a..8549279a 100644 --- a/frontend/menu.c +++ b/frontend/menu.c @@ -104,6 +104,7 @@ static char last_selected_fname[MAXPATHLEN]; static int config_save_counter, region, in_type_sel1, in_type_sel2; static int psx_clock; static int memcard1_sel = -1, memcard2_sel = -1; +static int cd_buf_count; extern int g_autostateld_opt; static int menu_iopts[8]; int g_opts, g_scaler, g_gamma = 100; @@ -436,6 +437,7 @@ static const struct { CE_INTVAL(memcard1_sel), CE_INTVAL(memcard2_sel), CE_INTVAL(g_autostateld_opt), + CE_INTVAL(cd_buf_count), CE_INTVAL_N("adev0_is_nublike", in_adev_is_nublike[0]), CE_INTVAL_N("adev1_is_nublike", in_adev_is_nublike[1]), CE_INTVAL_V(frameskip, 4), @@ -530,6 +532,8 @@ static int menu_write_config(int is_game) return -1; } + cd_buf_count = cdra_get_buf_count(); + for (i = 0; i < ARRAY_SIZE(config_data); i++) { fprintf(f, "%s = ", config_data[i].name); switch (config_data[i].len) { @@ -691,6 +695,7 @@ int menu_load_config(int is_game) } keys_load_all(cfg); + cdra_set_buf_count(cd_buf_count); ret = 0; fail_read: free(cfg); @@ -1687,6 +1692,9 @@ static menu_entry e_menu_adv_options[] = mee_enum_h ("GPU l-list slow walking",0, menu_iopts[AMO_GPUL], men_autooo, h_cfg_gpul), mee_enum_h ("Fractional framerate", 0, menu_iopts[AMO_FFPS], men_autooo, h_cfg_ffps), mee_onoff_h ("Turbo CD-ROM ", 0, menu_iopts[AMO_TCD], 1, h_cfg_tcd), +#ifdef USE_ASYNC_CDROM + mee_range ("CD-ROM read-ahead", 0, cd_buf_count, 0, 1024), +#endif #if !defined(DRC_DISABLE) || defined(LIGHTREC) mee_onoff_h ("Disable dynarec (slow!)",0, menu_iopts[AMO_CPU], 1, h_cfg_nodrc), #endif @@ -1721,6 +1729,7 @@ static int menu_loop_adv_options(int id, int keys) *opts[i].opt = *opts[i].mopt; Config.GpuListWalking = menu_iopts[AMO_GPUL] - 1; Config.FractionalFramerate = menu_iopts[AMO_FFPS] - 1; + cdra_set_buf_count(cd_buf_count); return 0; } diff --git a/libpcsxcore/cdrom-async.c b/libpcsxcore/cdrom-async.c index 2cb30473..4da0f374 100644 --- a/libpcsxcore/cdrom-async.c +++ b/libpcsxcore/cdrom-async.c @@ -487,6 +487,10 @@ void cdra_set_buf_count(int newcount) cdra_start_thread(); } +int cdra_get_buf_count(void) +{ + return acdrom.buf_cnt; +} #else // phys. CD-ROM without a cache is unusable so not implemented @@ -561,6 +565,7 @@ int cdra_is_physical(void) { return 0; } int cdra_check_eject(int *inserted) { return 0; } void cdra_stop_thread(void) {} void cdra_set_buf_count(int newcount) {} +int cdra_get_buf_count(void) { return 0; } #endif diff --git a/libpcsxcore/cdrom-async.h b/libpcsxcore/cdrom-async.h index 02fe6b71..22747a85 100644 --- a/libpcsxcore/cdrom-async.h +++ b/libpcsxcore/cdrom-async.h @@ -21,6 +21,7 @@ int cdra_is_physical(void); int cdra_check_eject(int *inserted); void cdra_stop_thread(void); void cdra_set_buf_count(int count); +int cdra_get_buf_count(void); void *cdra_getBuffer(void);