From: notaz Date: Wed, 18 Jan 2012 23:33:12 +0000 (+0200) Subject: refactor gpu plugins and Makefiles X-Git-Tag: r14~29 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=commitdiff_plain;h=62d7fa9555924ab8e152b546711d27add640b102 refactor gpu plugins and Makefiles name common gpu code gpulib, reduce amount of copy-paste in plugin Makefiles --- diff --git a/Makefile b/Makefile index 21f3ef6b..d40985ba 100644 --- 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 $@) diff --git a/frontend/menu.c b/frontend/menu.c index a8d2e487..c05d9103 100644 --- a/frontend/menu.c +++ b/frontend/menu.c @@ -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 */ diff --git a/frontend/plat_pollux.c b/frontend/plat_pollux.c index af5b81a8..daf2f848 100644 --- a/frontend/plat_pollux.c +++ b/frontend/plat_pollux.c @@ -23,13 +23,13 @@ #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; diff --git a/plugins/dfxvideo/draw_fb.c b/plugins/dfxvideo/draw_fb.c index 8814da80..22351a44 100644 --- a/plugins/dfxvideo/draw_fb.c +++ b/plugins/dfxvideo/draw_fb.c @@ -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 diff --git a/plugins/gpu_neon/peops_if.c b/plugins/dfxvideo/gpulib_if.c similarity index 99% rename from plugins/gpu_neon/peops_if.c rename to plugins/dfxvideo/gpulib_if.c index 191fce17..82bc38da 100644 --- a/plugins/gpu_neon/peops_if.c +++ b/plugins/dfxvideo/gpulib_if.c @@ -15,7 +15,7 @@ #include #include #include -#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" ///////////////////////////////////////////////////////////////////////////// diff --git a/plugins/gpu_neon/Makefile b/plugins/gpu_neon/Makefile index 2d942f83..93839d23 100644 --- a/plugins/gpu_neon/Makefile +++ b/plugins/gpu_neon/Makefile @@ -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 diff --git a/plugins/gpu_neon/psx_gpu_if.c b/plugins/gpu_neon/psx_gpu_if.c index 1c462e1a..3ff6e486 100644 --- a/plugins/gpu_neon/psx_gpu_if.c +++ b/plugins/gpu_neon/psx_gpu_if.c @@ -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))); diff --git a/plugins/gpu_unai/Makefile b/plugins/gpu_unai/Makefile index e4b6e6b9..dd9e4cad 100644 --- a/plugins/gpu_unai/Makefile +++ b/plugins/gpu_unai/Makefile @@ -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 diff --git a/plugins/gpu_unai/gpu.cpp b/plugins/gpu_unai/gpu.cpp index f0539c03..5a0ad2c3 100644 --- a/plugins/gpu_unai/gpu.cpp +++ b/plugins/gpu_unai/gpu.cpp @@ -821,7 +821,7 @@ void GPU_updateLace(void) #else #include "../../frontend/plugin_lib.h" -#include "../../frontend/cspace.h" +#include "../gpulib/cspace.h" extern "C" { diff --git a/plugins/gpu_neon/unai_if.cpp b/plugins/gpu_unai/gpulib_if.cpp similarity index 99% rename from plugins/gpu_neon/unai_if.cpp rename to plugins/gpu_unai/gpulib_if.cpp index 8917f2a3..22fe31ea 100644 --- a/plugins/gpu_neon/unai_if.cpp +++ b/plugins/gpu_unai/gpulib_if.cpp @@ -22,7 +22,7 @@ #include #include #include -#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 index 00000000..a2445244 --- /dev/null +++ b/plugins/gpulib/Makefile @@ -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) diff --git a/plugins/gpu_neon/Makefile.test b/plugins/gpulib/Makefile.test similarity index 83% rename from plugins/gpu_neon/Makefile.test rename to plugins/gpulib/Makefile.test index 114f86ed..196b1f9b 100644 --- a/plugins/gpu_neon/Makefile.test +++ b/plugins/gpulib/Makefile.test @@ -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 diff --git a/frontend/cspace.c b/plugins/gpulib/cspace.c similarity index 100% rename from frontend/cspace.c rename to plugins/gpulib/cspace.c diff --git a/frontend/cspace.h b/plugins/gpulib/cspace.h similarity index 100% rename from frontend/cspace.h rename to plugins/gpulib/cspace.h diff --git a/frontend/cspace_neon.s b/plugins/gpulib/cspace_neon.s similarity index 100% rename from frontend/cspace_neon.s rename to plugins/gpulib/cspace_neon.s diff --git a/plugins/gpu_neon/gpu.c b/plugins/gpulib/gpu.c similarity index 100% rename from plugins/gpu_neon/gpu.c rename to plugins/gpulib/gpu.c diff --git a/plugins/gpu_neon/gpu.h b/plugins/gpulib/gpu.h 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 index 00000000..cec6f5a6 --- /dev/null +++ b/plugins/gpulib/gpulib.mak @@ -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) diff --git a/plugins/gpu_neon/test.c b/plugins/gpulib/test.c similarity index 100% rename from plugins/gpu_neon/test.c rename to plugins/gpulib/test.c diff --git a/plugins/gpu_neon/vout_fb.c b/plugins/gpulib/vout_fb.c similarity index 98% rename from plugins/gpu_neon/vout_fb.c rename to plugins/gpulib/vout_fb.c index 20c8ff39..021efa72 100644 --- a/plugins/gpu_neon/vout_fb.c +++ b/plugins/gpulib/vout_fb.c @@ -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; diff --git a/plugins/gpu_neon/vout_sdl.c b/plugins/gpulib/vout_sdl.c similarity index 100% rename from plugins/gpu_neon/vout_sdl.c rename to plugins/gpulib/vout_sdl.c