From 90ca49139cdc64ab374f2e763cb4c28fffd0a7b8 Mon Sep 17 00:00:00 2001 From: notaz Date: Tue, 20 Dec 2011 23:56:35 +0200 Subject: [PATCH] gpu_neon: integrate Exophase's rasterizer --- Makefile | 8 +++++ frontend/menu.c | 5 +++- plugins/gpu_neon/Makefile | 4 +-- plugins/gpu_neon/Makefile.test | 15 +++++++--- plugins/gpu_neon/psx_gpu_if.c | 53 ++++++++++++++++++++++++++++++++++ 5 files changed, 78 insertions(+), 7 deletions(-) create mode 100644 plugins/gpu_neon/psx_gpu_if.c diff --git a/Makefile b/Makefile index 8d49f10f..611d5c34 100644 --- a/Makefile +++ b/Makefile @@ -96,10 +96,16 @@ endif # gpu OBJS += plugins/gpu_neon/gpu.o +ifeq "$(HAVE_NEON)" "1" +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 # 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 +endif ifdef X11 LDFLAGS += -lX11 `sdl-config --libs` OBJS += plugins/gpu_neon/vout_sdl.o @@ -170,6 +176,8 @@ frontend/revision.h: FORCE @rm $@_ .PHONY: FORCE +%.o: %.S + $(CC) $(CFLAGS) -c $^ -o $@ $(TARGET): $(OBJS) $(CC) -o $@ $^ $(LDFLAGS) -Wl,-Map=$@.map diff --git a/frontend/menu.c b/frontend/menu.c index d3e16a42..daec5003 100644 --- a/frontend/menu.c +++ b/frontend/menu.c @@ -241,6 +241,9 @@ static void menu_set_defconfig(void) { #val, sizeof(pl_rearmed_cbs.val), &pl_rearmed_cbs.val } // 'versioned' var, used when defaults change +#define CE_CONFIG_STR_V(val, ver) \ + { #val #ver, 0, Config.val } + #define CE_INTVAL_V(val, ver) \ { #val #ver, sizeof(val), &val } @@ -253,7 +256,7 @@ static const struct { void *val; } config_data[] = { CE_CONFIG_STR(Bios), - CE_CONFIG_STR(Gpu), + CE_CONFIG_STR_V(Gpu, 2), CE_CONFIG_STR(Spu), // CE_CONFIG_STR(Cdr), CE_CONFIG_VAL(Xa), diff --git a/plugins/gpu_neon/Makefile b/plugins/gpu_neon/Makefile index 66a2bd5c..419558f8 100644 --- a/plugins/gpu_neon/Makefile +++ b/plugins/gpu_neon/Makefile @@ -37,8 +37,8 @@ ifeq "$(HAVE_NEON)" "1" TARGETS += gpu_neon.$(EXT) endif -gpu_neon.$(EXT): SRC += psx_gpu_if.c -gpu_neon.$(EXT): CFLAGS += -fno-strict-aliasing +gpu_neon.$(EXT): SRC += psx_gpu_if.c psx_gpu/psx_gpu_arm_neon.S +gpu_neon.$(EXT): CFLAGS += -DNEON_BUILD -DTEXTURE_CACHE_4BPP -DTEXTURE_CACHE_8BPP gpu_peops.$(EXT): SRC += peops_if.c gpu_peops.$(EXT): CFLAGS += -fno-strict-aliasing gpu_unai.$(EXT): SRC += unai_if.cpp ../gpu_unai/gpu_arm.s diff --git a/plugins/gpu_neon/Makefile.test b/plugins/gpu_neon/Makefile.test index 5ca8d18a..c2bcee07 100644 --- a/plugins/gpu_neon/Makefile.test +++ b/plugins/gpu_neon/Makefile.test @@ -3,9 +3,12 @@ CXX = $(CROSS_COMPILE)g++ CC_ = $(CROSS_COMPILE)gcc ARCH = $(shell $(CC) -v 2>&1 | grep -i 'target:' | awk '{print $$2}' | awk -F '-' '{print $$1}') +HAVE_NEON = $(shell $(CC_) -E -dD $(CFLAGS) gpu.h | grep -q '__ARM_NEON__ 1' && echo 1) CFLAGS += -ggdb -Wall -DTEST +ifndef DEBUG CFLAGS += -O2 +endif ifeq "$(ARCH)" "arm" CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp endif @@ -13,17 +16,21 @@ ifeq "$(ARCH)" "x86_64" CFLAGS += -m32 endif -# test_neon TARGETS = test_peops test_unai +ifeq "$(HAVE_NEON)" "1" +TARGETS += test_neon +endif + SRC += test.c all: $(TARGETS) -test_neon: SRC += psx_gpu_if.c -test_neon: CFLAGS += -fno-strict-aliasing +test_neon: SRC += psx_gpu_if.c psx_gpu/psx_gpu_arm_neon.S +test_neon: psx_gpu_if.c psx_gpu/*.c +test_neon: CFLAGS += -DNEON_BUILD -DTEXTURE_CACHE_4BPP -DTEXTURE_CACHE_8BPP test_peops: SRC += peops_if.c test_peops: CFLAGS += -fno-strict-aliasing -test_unai: SRC += unai_if.cpp +test_unai: SRC += unai_if.cpp ../gpu_unai/gpu_arm.s test_unai: CC_ = $(CXX) $(TARGETS): $(SRC) diff --git a/plugins/gpu_neon/psx_gpu_if.c b/plugins/gpu_neon/psx_gpu_if.c new file mode 100644 index 00000000..8907ac02 --- /dev/null +++ b/plugins/gpu_neon/psx_gpu_if.c @@ -0,0 +1,53 @@ +/* + * (C) Gražvydas "notaz" Ignotas, 2011 + * + * This work is licensed under the terms of any of these licenses + * (at your option): + * - GNU GPL, version 2 or later. + * - GNU LGPL, version 2.1 or later. + * See the COPYING file in the top-level directory. + */ + +#include + +#if 1 +#include "psx_gpu/psx_gpu.c" +#else +#define printf xprintf +#define xprintf(...) +#include "psx_gpu/psx_gpu_standard.c" +#endif +#include "psx_gpu/psx_gpu_parse.c" +#include "gpu.h" + +static psx_gpu_struct egpu __attribute__((aligned(256))); + +void do_cmd_list(uint32_t *list, int count) +{ + gpu_parse(&egpu, list, count * 4); +} + +int renderer_init(void) +{ + initialize_psx_gpu(&egpu, gpu.vram); + return 0; +} + +void renderer_sync_ecmds(uint32_t *ecmds) +{ + gpu_parse(&egpu, ecmds + 1, 6 * 4); +} + +void renderer_invalidate_caches(int x, int y, int w, int h) +{ + invalidate_texture_cache_region(&egpu, x, y, x + w - 1, y + h - 1); +} + +void renderer_flush_queues(void) +{ + flush_render_block_buffer(&egpu); +} + +void renderer_set_config(const struct rearmed_cbs *cbs) +{ +} -- 2.39.2