gpu_neon: integration for arm64
authornotaz <notasas@gmail.com>
Mon, 8 Aug 2022 18:16:59 +0000 (21:16 +0300)
committernotaz <notasas@gmail.com>
Mon, 8 Aug 2022 18:16:59 +0000 (21:16 +0300)
Makefile
configure
frontend/cspace.c
frontend/menu.c
frontend/plugin_lib.c
plugins/gpu_neon/Makefile

index fa5d279..585480d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -50,7 +50,7 @@ OBJS += libpcsxcore/gte.o libpcsxcore/gte_nf.o libpcsxcore/gte_divider.o
 ifeq "$(ARCH)" "arm"
 OBJS += libpcsxcore/gte_arm.o
 endif
-ifeq "$(HAVE_NEON)" "1"
+ifeq "$(HAVE_NEON_ASM)" "1"
 OBJS += libpcsxcore/gte_neon.o
 endif
 libpcsxcore/psxbios.o: CFLAGS += -Wno-nonnull
@@ -62,7 +62,7 @@ OBJS += libpcsxcore/new_dynarec/pcsxmem.o
  ifeq "$(ARCH)" "arm"
  OBJS += libpcsxcore/new_dynarec/linkage_arm.o
  libpcsxcore/new_dynarec/new_dynarec.o: libpcsxcore/new_dynarec/assem_arm.c
- else ifeq "$(ARCH)" "aarch64"
+ else ifneq (,$(findstring $(ARCH),aarch64 arm64))
  OBJS += libpcsxcore/new_dynarec/linkage_arm64.o
  libpcsxcore/new_dynarec/new_dynarec.o: libpcsxcore/new_dynarec/assem_arm64.c
  else
@@ -119,9 +119,17 @@ endif
 # builtin gpu
 OBJS += plugins/gpulib/gpu.o plugins/gpulib/vout_pl.o
 ifeq "$(BUILTIN_GPU)" "neon"
-OBJS += plugins/gpu_neon/psx_gpu_if.o plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.o
+OBJS += plugins/gpu_neon/psx_gpu_if.o
 plugins/gpu_neon/psx_gpu_if.o: CFLAGS += -DNEON_BUILD -DTEXTURE_CACHE_4BPP -DTEXTURE_CACHE_8BPP
 plugins/gpu_neon/psx_gpu_if.o: plugins/gpu_neon/psx_gpu/*.c
+frontend/menu.o frontend/plugin_lib.o: CFLAGS += -DBUILTIN_GPU_NEON
+ ifeq "$(HAVE_NEON_ASM)" "1"
+ OBJS += plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.o
+ else
+ OBJS += plugins/gpu_neon/psx_gpu/psx_gpu_simd.o
+ plugins/gpu_neon/psx_gpu_if.o: CFLAGS += -DSIMD_BUILD
+ plugins/gpu_neon/psx_gpu/psx_gpu_simd.o: CFLAGS += -DSIMD_BUILD
+ endif
 endif
 ifeq "$(BUILTIN_GPU)" "peops"
 # note: code is not safe for strict-aliasing? (Castlevania problems)
@@ -168,11 +176,13 @@ OBJS += plugins/dfinput/main.o plugins/dfinput/pad.o plugins/dfinput/guncon.o
 
 # frontend/gui
 OBJS += frontend/cspace.o
-ifeq "$(HAVE_NEON)" "1"
+ifeq "$(HAVE_NEON_ASM)" "1"
 OBJS += frontend/cspace_neon.o
+frontend/cspace.o: CFLAGS += -DHAVE_bgr555_to_rgb565 -DHAVE_bgr888_to_x
 else
 ifeq "$(ARCH)" "arm"
 OBJS += frontend/cspace_arm.o
+frontend/cspace.o: CFLAGS += -DHAVE_bgr555_to_rgb565
 endif
 endif
 
@@ -235,7 +245,7 @@ OBJS += frontend/plugin_lib.o
 OBJS += frontend/libpicofe/linux/plat.o
 OBJS += frontend/libpicofe/readpng.o frontend/libpicofe/fonts.o
 frontend/libpicofe/linux/plat.o: CFLAGS += -DNO_HOME_DIR
-ifeq "$(HAVE_NEON)" "1"
+ifeq "$(HAVE_NEON_ASM)" "1"
 OBJS += frontend/libpicofe/arm/neon_scale2x.o
 OBJS += frontend/libpicofe/arm/neon_eagle2x.o
 frontend/libpicofe/arm/neon_scale2x.o: CFLAGS += -DDO_BGR_TO_RGB
index cb124ac..8ef59ce 100755 (executable)
--- a/configure
+++ b/configure
@@ -50,6 +50,7 @@ have_armv5=""
 have_armv6=""
 have_armv7=""
 have_arm_neon=""
+have_arm_neon_asm=""
 have_tslib=""
 have_gles=""
 have_c64x_dsp=""
@@ -213,7 +214,7 @@ arm*)
   fi
 
   if [ "x$have_arm_neon" = "x" ]; then
-    # detect NEON from user-supplied cflags to enable asm code
+    # detect NEON from user-supplied cflags to enable neon code
     have_arm_neon=`check_define __ARM_NEON__ && echo yes` || true
   fi
   if [ "x$have_armv7" = "x" ]; then
@@ -278,8 +279,14 @@ arm*)
     echo "You probably want to specify -mcpu= or -march= like this:"
     echo "  CFLAGS=-march=armv7-a ./configure ..."
   fi
+  have_arm_neon_asm=$have_arm_neon
   ;;
 aarch64)
+  have_arm_neon="yes"
+  have_arm_neon_asm="no"
+  if [ "x$builtin_gpu" = "x" ]; then
+    builtin_gpu="neon"
+  fi
   ;;
 *)
   # dynarec only available on ARM
@@ -508,6 +515,7 @@ done
 test "x$have_armv6" != "x" || have_armv6="no"
 test "x$have_armv7" != "x" || have_armv7="no"
 test "x$have_arm_neon" != "x" || have_arm_neon="no"
+test "x$have_arm_neon_asm" != "x" || have_arm_neon_asm="no"
 test "x$have_gles" != "x" || have_gles="no"
 test "x$have_c64x_dsp" != "x" || have_c64x_dsp="no"
 
@@ -521,9 +529,11 @@ echo "C compiler flags    $CFLAGS"
 echo "libraries           $MAIN_LDLIBS"
 echo "linker flags        $LDFLAGS$MAIN_LDFLAGS"
 echo "enable dynarec      $enable_dynarec"
+if [ "$ARCH" = "arm" -o "$ARCH" = "aarch64" ]; then
+  echo "enable ARM NEON     $have_arm_neon"
+fi
 if [ "$ARCH" = "arm" ]; then
   echo "ARMv7 optimizations $have_armv7"
-  echo "enable ARM NEON     $have_arm_neon"
   echo "TI C64x DSP support $have_c64x_dsp"
 fi
 echo "tslib support       $have_tslib"
@@ -558,6 +568,9 @@ echo "PLUGINS = $plugins" >> $config_mak
 if [ "$have_arm_neon" = "yes" ]; then
   echo "HAVE_NEON = 1" >> $config_mak
 fi
+if [ "$have_arm_neon_asm" = "yes" ]; then
+  echo "HAVE_NEON_ASM = 1" >> $config_mak
+fi
 if [ "$have_tslib" = "yes" ]; then
   echo "HAVE_TSLIB = 1" >> $config_mak
 fi
index f60026c..8426a13 100644 (file)
@@ -22,7 +22,7 @@
 #define LE16TOHx2(x) (x)
 #endif
 
-#ifndef __arm__
+#ifndef HAVE_bgr555_to_rgb565
 
 void bgr555_to_rgb565(void *dst_, const void *src_, int bytes)
 {
@@ -43,7 +43,7 @@ void bgr555_to_rgb565(void *dst_, const void *src_, int bytes)
 
 #endif
 
-#ifndef __ARM_NEON__
+#ifndef HAVE_bgr888_to_x
 
 void bgr888_to_rgb565(void *dst_, const void *src_, int bytes)
 {
index 85f7b7f..4808e9c 100644 (file)
@@ -1343,7 +1343,7 @@ static int menu_loop_gfx_options(int id, int keys)
 
 // ------------ bios/plugins ------------
 
-#ifdef __ARM_NEON__
+#ifdef BUILTIN_GPU_NEON
 
 static const char h_gpu_neon[] =
        "Configure built-in NEON GPU plugin";
@@ -1502,7 +1502,7 @@ static const char h_bios[]       = "HLE is simulated BIOS. BIOS selection is sav
                                   "savestates and can't be changed there. Must save\n"
                                   "config and reload the game for change to take effect";
 static const char h_plugin_gpu[] = 
-#ifdef __ARM_NEON__
+#ifdef BUILTIN_GPU_NEON
                                   "builtin_gpu is the NEON GPU, very fast and accurate\n"
 #endif
                                   "gpu_peops is Pete's soft GPU, slow but accurate\n"
@@ -1523,7 +1523,7 @@ static menu_entry e_menu_plugin_options[] =
        mee_enum_h    ("BIOS",                          0, bios_sel, bioses, h_bios),
        mee_enum_h    ("GPU plugin",                    0, gpu_plugsel, gpu_plugins, h_plugin_gpu),
        mee_enum_h    ("SPU plugin",                    0, spu_plugsel, spu_plugins, h_plugin_spu),
-#ifdef __ARM_NEON__
+#ifdef BUILTIN_GPU_NEON
        mee_handler_h ("Configure built-in GPU plugin", menu_loop_plugin_gpu_neon, h_gpu_neon),
 #endif
        mee_handler_h ("Configure gpu_peops plugin",    menu_loop_plugin_gpu_peops, h_gpu_peops),
@@ -1979,7 +1979,7 @@ static const char credits_text[] =
        "(C) 2005-2009 PCSX-df Team\n"
        "(C) 2009-2011 PCSX-Reloaded Team\n\n"
        "ARM recompiler (C) 2009-2011 Ari64\n"
-#ifdef __ARM_NEON__
+#ifdef BUILTIN_GPU_NEON
        "ARM NEON GPU (c) 2011-2012 Exophase\n"
 #endif
        "PEOpS GPU and SPU by Pete Bernert\n"
index d215636..cc3576b 100644 (file)
@@ -468,7 +468,7 @@ static int dispmode_default(void)
        return 1;
 }
 
-#ifdef __ARM_NEON__
+#ifdef BUILTIN_GPU_NEON
 static int dispmode_doubleres(void)
 {
        if (!(pl_rearmed_cbs.gpu_caps & GPU_CAP_SUPPORTS_2X)
@@ -480,7 +480,9 @@ static int dispmode_doubleres(void)
        snprintf(hud_msg, sizeof(hud_msg), "double resolution");
        return 1;
 }
+#endif
 
+#ifdef __ARM_NEON__
 static int dispmode_scale2x(void)
 {
        if (!resolution_ok(psx_w * 2, psx_h * 2) || psx_bpp != 16)
@@ -506,8 +508,10 @@ static int dispmode_eagle2x(void)
 
 static int (*dispmode_switchers[])(void) = {
        dispmode_default,
-#ifdef __ARM_NEON__
+#ifdef BUILTIN_GPU_NEON
        dispmode_doubleres,
+#endif
+#ifdef __ARM_NEON__
        dispmode_scale2x,
        dispmode_eagle2x,
 #endif
index 08bf0ee..955feab 100644 (file)
@@ -5,9 +5,14 @@ include ../../config.mak
 SRC += psx_gpu_if.c
 
 CFLAGS += -DTEXTURE_CACHE_4BPP -DTEXTURE_CACHE_8BPP
-ifeq "$(HAVE_NEON)" "1"
-SRC += psx_gpu/psx_gpu_arm_neon.S
 CFLAGS += -DNEON_BUILD
+ifeq "$(HAVE_NEON)" "1"
+ ifeq "$(HAVE_NEON_ASM)" "1"
+ SRC += psx_gpu/psx_gpu_arm_neon.S
+ else
+ OBJS += psx_gpu/psx_gpu_simd.c
+ CFLAGS += -DSIMD_BUILD
+ endif
 else
 CFLAGS += -fno-strict-aliasing
 endif