refactor gpu plugins and Makefiles
authornotaz <notasas@gmail.com>
Wed, 18 Jan 2012 23:33:12 +0000 (01:33 +0200)
committernotaz <notasas@gmail.com>
Wed, 18 Jan 2012 23:38:45 +0000 (01:38 +0200)
name common gpu code gpulib, reduce amount of copy-paste
in plugin Makefiles

21 files changed:
Makefile
frontend/menu.c
frontend/plat_pollux.c
plugins/dfxvideo/draw_fb.c
plugins/dfxvideo/gpulib_if.c [moved from plugins/gpu_neon/peops_if.c with 99% similarity]
plugins/gpu_neon/Makefile
plugins/gpu_neon/psx_gpu_if.c
plugins/gpu_unai/Makefile
plugins/gpu_unai/gpu.cpp
plugins/gpu_unai/gpulib_if.cpp [moved from plugins/gpu_neon/unai_if.cpp with 99% similarity]
plugins/gpulib/Makefile [new file with mode: 0644]
plugins/gpulib/Makefile.test [moved from plugins/gpu_neon/Makefile.test with 83% similarity]
plugins/gpulib/cspace.c [moved from frontend/cspace.c with 100% similarity]
plugins/gpulib/cspace.h [moved from frontend/cspace.h with 100% similarity]
plugins/gpulib/cspace_neon.s [moved from frontend/cspace_neon.s with 100% similarity]
plugins/gpulib/gpu.c [moved from plugins/gpu_neon/gpu.c with 100% similarity]
plugins/gpulib/gpu.h [moved from plugins/gpu_neon/gpu.h with 100% similarity]
plugins/gpulib/gpulib.mak [new file with mode: 0644]
plugins/gpulib/test.c [moved from plugins/gpu_neon/test.c with 100% similarity]
plugins/gpulib/vout_fb.c [moved from plugins/gpu_neon/vout_fb.c with 98% similarity]
plugins/gpulib/vout_sdl.c [moved from plugins/gpu_neon/vout_sdl.c with 100% similarity]

index 21f3ef6..d40985b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -95,23 +95,25 @@ LDFLAGS += -lasound
 endif
 
 # gpu
-OBJS += plugins/gpu_neon/gpu.o
+OBJS += plugins/gpulib/gpu.o
 ifeq "$(HAVE_NEON)" "1"
+OBJS += plugins/gpulib/cspace_neon.o
 OBJS += plugins/gpu_neon/psx_gpu_if.o plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.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
 else
+OBJS += plugins/gpulib/cspace.o
 # note: code is not safe for strict-aliasing? (Castlevania problems)
-plugins/gpu_neon/peops_if.o: CFLAGS += -fno-strict-aliasing
-plugins/gpu_neon/peops_if.o: plugins/dfxvideo/prim.c plugins/dfxvideo/soft.c
-OBJS += plugins/gpu_neon/peops_if.o
+plugins/dfxvideo/gpulib_if.o: CFLAGS += -fno-strict-aliasing
+plugins/dfxvideo/gpulib_if.o: plugins/dfxvideo/prim.c plugins/dfxvideo/soft.c
+OBJS += plugins/dfxvideo/gpulib_if.o
 endif
 ifdef X11
 LDFLAGS += -lX11 `sdl-config --libs`
-OBJS += plugins/gpu_neon/vout_sdl.o
-plugins/gpu_neon/vout_sdl.o: CFLAGS += `sdl-config --cflags`
+OBJS += plugins/gpulib/vout_sdl.o
+plugins/gpulib/vout_sdl.o: CFLAGS += `sdl-config --cflags`
 else
-OBJS += plugins/gpu_neon/vout_fb.o
+OBJS += plugins/gpulib/vout_fb.o
 endif
 
 # cdrcimg
@@ -147,11 +149,6 @@ endif
 
 endif # !USE_GTK
 
-ifeq "$(HAVE_NEON)" "1"
-OBJS += frontend/cspace_neon.o
-else
-OBJS += frontend/cspace.o
-endif
 ifdef X11
 frontend/%.o: CFLAGS += -DX11
 OBJS += frontend/xkb.o
@@ -183,7 +180,7 @@ $(TARGET): $(OBJS)
        $(CC) -o $@ $^ $(LDFLAGS) -Wl,-Map=$@.map
 
 PLUGINS ?= plugins/spunull/spunull.so plugins/gpu-gles/gpuGLES.so \
-       plugins/gpu_neon/gpu_unai.so plugins/gpu_neon/gpu_peops.so
+       plugins/gpu_unai/gpu_unai.so plugins/dfxvideo/gpu_peops.so
 
 $(PLUGINS):
        make -C $(dir $@)
index a8d2e48..c05d910 100644 (file)
@@ -25,7 +25,6 @@
 #include "omap.h"
 #include "plat.h"
 #include "pcnt.h"
-#include "cspace.h"
 #include "common/plat.h"
 #include "common/input.h"
 #include "linux/in_evdev.h"
@@ -35,6 +34,7 @@
 #include "../libpcsxcore/psemu_plugin_defs.h"
 #include "../libpcsxcore/new_dynarec/new_dynarec.h"
 #include "../plugins/dfinput/main.h"
+#include "../plugins/gpulib/cspace.h"
 #include "revision.h"
 
 #define REARMED_BIRTHDAY_TIME 1293306830       /* 25 Dec 2010 */
index af5b81a..daf2f84 100644 (file)
 #include "warm/warm.h"
 #include "plugin_lib.h"
 #include "pl_gun_ts.h"
-#include "cspace.h"
 #include "blit320.h"
 #include "in_tsbutton.h"
 #include "main.h"
 #include "menu.h"
 #include "plat.h"
 #include "pcnt.h"
+#include "../plugins/gpulib/cspace.h"
 
 int gp2x_dev_id;
 
index 8814da8..22351a4 100644 (file)
@@ -9,8 +9,8 @@
 
 #include "gpu.h"
 
+#include "../gpulib/cspace.h"
 #include "../../frontend/plugin_lib.h"
-#include "../../frontend/cspace.h"
 #include "../../frontend/pcnt.h"
 
 // misc globals
similarity index 99%
rename from plugins/gpu_neon/peops_if.c
rename to plugins/dfxvideo/gpulib_if.c
index 191fce1..82bc38d 100644 (file)
@@ -15,7 +15,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include "gpu.h"
+#include "../gpulib/gpu.h"
 
 #define u32 uint32_t
 
@@ -260,8 +260,8 @@ unsigned short sSetMask = 0;
 unsigned long  lSetMask = 0;
 long           lLowerpart;
 
-#include "../dfxvideo/soft.c"
-#include "../dfxvideo/prim.c"
+#include "soft.c"
+#include "prim.c"
 
 /////////////////////////////////////////////////////////////////////////////
 
index 2d942f8..93839d2 100644 (file)
@@ -1,59 +1,28 @@
 CC = $(CROSS_COMPILE)gcc
-CXX = $(CROSS_COMPILE)g++
-CC_ = $(CC)
 
 ARCH = $(shell $(CC) -v 2>&1 | grep -i 'target:' | awk '{print $$2}' | awk -F '-' '{print $$1}')
 
-CFLAGS += -ggdb -Wall -fPIC -O2
-CFLAGS += -fno-strict-aliasing
-ifdef MAEMO
-CFLAGS += -DMAEMO
-endif
+HAVE_NEON = $(shell $(CC) -E -dD $(CFLAGS_) ../gpulib/gpu.h | grep -q '__ARM_NEON__ 1' && echo 1)
 
-SRC += gpu.c
+# FIXME: rework NEON detection to get rid of this
 ifeq "$(ARCH)" "arm"
-ARM_CORTEXA8 ?= 1
-ifeq "$(ARM_CORTEXA8)" "1"
-CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp
-SRC += ../../frontend/cspace_neon.s
-else
-CFLAGS += -mcpu=arm926ej-s -mtune=arm926ej-s
-SRC += ../../frontend/cspace.c
-endif
-SRC += vout_fb.c
-EXT = so
-endif
-ifeq "$(ARCH)" "x86_64"
-CFLAGS += `sdl-config --cflags` -m32
-LDFLAGS += `sdl-config --libs`
-SRC += vout_sdl.c
-EXT = so.x86
+ ARM_CORTEXA8 ?= 1
+ ifeq "$(ARM_CORTEXA8)" "1"
+  CFLAGS_ += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp
+ endif
 endif
 
-HAVE_NEON = $(shell $(CC_) -E -dD $(CFLAGS) gpu.h | grep -q '__ARM_NEON__ 1' && echo 1)
+CFLAGS += -ggdb -Wall -fPIC -O2
 
-TARGETS = gpu_neon.$(EXT) gpu_peops.$(EXT) gpu_unai.$(EXT)
+SRC += psx_gpu_if.c
 
-gpu_neon.$(EXT): SRC += psx_gpu_if.c
-gpu_neon.$(EXT): CFLAGS += -DTEXTURE_CACHE_4BPP -DTEXTURE_CACHE_8BPP
+CFLAGS += -DTEXTURE_CACHE_4BPP -DTEXTURE_CACHE_8BPP
 ifeq "$(HAVE_NEON)" "1"
-gpu_neon.$(EXT): SRC += psx_gpu/psx_gpu_arm_neon.S
-gpu_neon.$(EXT): CFLAGS += -DNEON_BUILD
+SRC += psx_gpu/psx_gpu_arm_neon.S
+CFLAGS += -DNEON_BUILD
 else
-gpu_neon.$(EXT): CFLAGS += -fno-strict-aliasing
-endif
-gpu_peops.$(EXT): SRC += peops_if.c
-gpu_peops.$(EXT): CFLAGS += -fno-strict-aliasing
-gpu_unai.$(EXT): SRC += unai_if.cpp
-gpu_unai.$(EXT): CC_ = $(CXX)
-ifeq "$(ARCH)" "arm"
-gpu_unai.$(EXT): SRC += ../gpu_unai/gpu_arm.s
+CFLAGS += -fno-strict-aliasing
 endif
 
-all: $(TARGETS)
-
-$(TARGETS): $(SRC)
-       $(CC_) -o $@ $(SRC) $(CFLAGS) $(LDFLAGS) -shared -Wl,-soname,$@
-
-clean:
-       $(RM) $(TARGETS)
+BIN_GPULIB = gpu_neon.so
+include ../gpulib/gpulib.mak
index 1c462e1..3ff6e48 100644 (file)
@@ -15,7 +15,7 @@ extern const unsigned char cmd_lengths[256];
 
 #include "psx_gpu/psx_gpu.c"
 #include "psx_gpu/psx_gpu_parse.c"
-#include "gpu.h"
+#include "../gpulib/gpu.h"
 
 static psx_gpu_struct egpu __attribute__((aligned(256)));
 
index e4b6e6b..dd9e4ca 100644 (file)
@@ -1,34 +1,17 @@
-CC = $(CROSS_COMPILE)gcc
+CC = $(CROSS_COMPILE)g++
 
-CFLAGS += -ggdb -fPIC -Wall -DREARMED
-ifndef DEBUG
-CFLAGS += -O2 -ffast-math -fomit-frame-pointer
-endif
-ifdef MAEMO
-CFLAGS += -DMAEMO
-endif
-ARM_CORTEXA8 ?= 1
-ifeq "$(ARM_CORTEXA8)" "1"
-CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp
-SRC += ../../frontend/cspace_neon.s
-else
-CFLAGS += -mcpu=arm926ej-s -mtune=arm926ej-s
-SRC += ../../frontend/cspace.c
-endif
-
-SRC += gpu.cpp gpu_arm.s
+ARCH = $(shell $(CC) -v 2>&1 | grep -i 'target:' | awk '{print $$2}' | awk -F '-' '{print $$1}')
 
-TARGET = gpuPCSX4ALL.so
-LDFLAGS += -shared -Wl,-soname,$(TARGET)
+CFLAGS += -DREARMED
+CFLAGS += -ggdb -Wall -fPIC -O2 -ffast-math
 
--include Makefile.local
+SRC_STANDALONE += gpu.cpp
+SRC_GPULIB += gpulib_if.cpp
 
-all: $(TARGET)
-
-$(TARGET): $(SRC)
-       $(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS)
-
-# $(TARGET): *.h
+ifeq "$(ARCH)" "arm"
+SRC += gpu_arm.s
+endif
 
-clean:
-       $(RM) $(TARGET) $(OBJ)
+BIN_STANDLALONE = gpuPCSX4ALL.so
+BIN_GPULIB = gpu_unai.so
+include ../gpulib/gpulib.mak
index f0539c0..5a0ad2c 100644 (file)
@@ -821,7 +821,7 @@ void  GPU_updateLace(void)
 #else
 
 #include "../../frontend/plugin_lib.h"
-#include "../../frontend/cspace.h"
+#include "../gpulib/cspace.h"
 
 extern "C" {
 
similarity index 99%
rename from plugins/gpu_neon/unai_if.cpp
rename to plugins/gpu_unai/gpulib_if.cpp
index 8917f2a..22fe31e 100644 (file)
@@ -22,7 +22,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include "gpu.h"
+#include "../gpulib/gpu.h"
 
 #define u8 uint8_t
 #define s8 int8_t
diff --git a/plugins/gpulib/Makefile b/plugins/gpulib/Makefile
new file mode 100644 (file)
index 0000000..a244524
--- /dev/null
@@ -0,0 +1,38 @@
+CC = $(CROSS_COMPILE)gcc
+AS = $(CROSS_COMPILE)as
+AR = $(CROSS_COMPILE)ar
+
+ARCH = $(shell $(CC) -v 2>&1 | grep -i 'target:' | awk '{print $$2}' | awk -F '-' '{print $$1}')
+
+CFLAGS += -ggdb -Wall -fPIC -O2
+
+OBJS += gpu.o
+
+ifeq "$(ARCH)" "arm"
+ARM_CORTEXA8 ?= 1
+ifeq "$(ARM_CORTEXA8)" "1"
+CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp
+ASFLAGS += -mcpu=cortex-a8 -mfpu=neon
+OBJS += cspace_neon.o
+else
+CFLAGS += -mcpu=arm926ej-s -mtune=arm926ej-s
+ASFLAGS += -mcpu=arm926ej-s -mfloat-abi=softfp
+OBJS += cspace.o
+endif
+OBJS += vout_fb.o
+EXT = a
+else
+CFLAGS += `sdl-config --cflags` -m32
+OBJS += vout_sdl.o
+EXT = x86.a
+endif
+
+TARGET = gpulib.$(EXT)
+
+all: $(TARGET)
+
+$(TARGET): $(OBJS)
+       $(AR) crs $@ $^
+
+clean:
+       $(RM) $(TARGET) $(OBJS)
similarity index 83%
rename from plugins/gpu_neon/Makefile.test
rename to plugins/gpulib/Makefile.test
index 114f86e..196b1f9 100644 (file)
@@ -22,18 +22,17 @@ SRC += test.c
 
 all: $(TARGETS)
 
-test_neon: SRC += psx_gpu_if.c
-test_neon: psx_gpu_if.c psx_gpu/*.c
+test_neon: SRC += ../gpu_neon/psx_gpu_if.c
 test_neon: CFLAGS += -DTEXTURE_CACHE_4BPP -DTEXTURE_CACHE_8BPP
 ifeq "$(HAVE_NEON)" "1"
-test_neon: SRC += psx_gpu/psx_gpu_arm_neon.S
+test_neon: SRC += ../gpu_neon/psx_gpu/psx_gpu_arm_neon.S
 test_neon: CFLAGS += -DNEON_BUILD
 else
 test_neon: CFLAGS += -fno-strict-aliasing
 endif
-test_peops: SRC += peops_if.c
+test_peops: SRC += ../dfxvideo/gpulib_if.c
 test_peops: CFLAGS += -fno-strict-aliasing
-test_unai: SRC += unai_if.cpp
+test_unai: SRC += ../gpu_unai/gpulib_if.cpp
 test_unai: CC_ = $(CXX)
 ifeq "$(ARCH)" "arm"
 test_unai: SRC += ../gpu_unai/gpu_arm.s
similarity index 100%
rename from frontend/cspace.c
rename to plugins/gpulib/cspace.c
similarity index 100%
rename from frontend/cspace.h
rename to plugins/gpulib/cspace.h
similarity index 100%
rename from plugins/gpu_neon/gpu.c
rename to plugins/gpulib/gpu.c
similarity index 100%
rename from plugins/gpu_neon/gpu.h
rename to plugins/gpulib/gpu.h
diff --git a/plugins/gpulib/gpulib.mak b/plugins/gpulib/gpulib.mak
new file mode 100644 (file)
index 0000000..cec6f5a
--- /dev/null
@@ -0,0 +1,54 @@
+# depends on ARCH definition
+# always adding gpulib to LDLIBS in case cspace is needed
+
+LDFLAGS += -shared
+ifeq "$(ARCH)" "arm"
+ ARM_CORTEXA8 ?= 1
+ ifeq "$(ARM_CORTEXA8)" "1"
+  CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp
+  ASFLAGS += -mcpu=cortex-a8 -mfpu=neon
+ else
+  CFLAGS += -mcpu=arm926ej-s -mtune=arm926ej-s
+  ASFLAGS += -mcpu=arm926ej-s -mfloat-abi=softfp
+ endif
+ EXT =
+else
+ CFLAGS += -m32
+ LDFLAGS += -m32
+ LDLIBS_GPULIB += `sdl-config --libs`
+ EXT = .x86
+endif
+ifdef MAEMO
+ CFLAGS += -DMAEMO
+endif
+ifdef DEBUG
+ CFLAGS += -O0
+endif
+
+GPULIB_A = ../gpulib/gpulib$(EXT).a
+LDLIBS += $(GPULIB_A)
+
+ifdef BIN_STANDLALONE
+TARGETS += $(BIN_STANDLALONE)$(EXT)
+endif
+ifdef BIN_GPULIB
+TARGETS += $(BIN_GPULIB)$(EXT)
+endif
+
+all: $(GPULIB_A) $(TARGETS)
+
+ifdef BIN_STANDLALONE
+$(BIN_STANDLALONE)$(EXT): $(SRC) $(SRC_STANDALONE)
+       $(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS) $(LDLIBS) $(LDLIBS_STANDALONE)
+endif
+
+ifdef BIN_GPULIB
+$(BIN_GPULIB)$(EXT): $(SRC) $(SRC_GPULIB)
+       $(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS) $(LDLIBS) $(LDLIBS_GPULIB)
+endif
+
+$(GPULIB_A):
+       make -C ../gpulib/ all
+
+clean:
+       $(RM) $(TARGETS)
similarity index 98%
rename from plugins/gpu_neon/vout_fb.c
rename to plugins/gpulib/vout_fb.c
index 20c8ff3..021efa7 100644 (file)
@@ -9,8 +9,8 @@
  */
 
 #include "gpu.h"
+#include "cspace.h"
 #include "../../frontend/plugin_lib.h"
-#include "../../frontend/cspace.h"
 
 static const struct rearmed_cbs *cbs;
 static void *screen_buf;