aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/dfxvideo/draw_fb.c2
-rw-r--r--plugins/dfxvideo/gpulib_if.c (renamed from plugins/gpu_neon/peops_if.c)6
-rw-r--r--plugins/gpu_neon/Makefile59
-rw-r--r--plugins/gpu_neon/psx_gpu_if.c2
-rw-r--r--plugins/gpu_unai/Makefile41
-rw-r--r--plugins/gpu_unai/gpu.cpp2
-rw-r--r--plugins/gpu_unai/gpulib_if.cpp (renamed from plugins/gpu_neon/unai_if.cpp)2
-rw-r--r--plugins/gpulib/Makefile38
-rw-r--r--plugins/gpulib/Makefile.test (renamed from plugins/gpu_neon/Makefile.test)9
-rw-r--r--plugins/gpulib/cspace.c21
-rw-r--r--plugins/gpulib/cspace.h12
-rw-r--r--plugins/gpulib/cspace_neon.s132
-rw-r--r--plugins/gpulib/gpu.c (renamed from plugins/gpu_neon/gpu.c)0
-rw-r--r--plugins/gpulib/gpu.h (renamed from plugins/gpu_neon/gpu.h)0
-rw-r--r--plugins/gpulib/gpulib.mak54
-rw-r--r--plugins/gpulib/test.c (renamed from plugins/gpu_neon/test.c)0
-rw-r--r--plugins/gpulib/vout_fb.c (renamed from plugins/gpu_neon/vout_fb.c)2
-rw-r--r--plugins/gpulib/vout_sdl.c (renamed from plugins/gpu_neon/vout_sdl.c)0
18 files changed, 295 insertions, 87 deletions
diff --git a/plugins/dfxvideo/draw_fb.c b/plugins/dfxvideo/draw_fb.c
index 8814da8..22351a4 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
index 191fce1..82bc38d 100644
--- a/plugins/gpu_neon/peops_if.c
+++ b/plugins/dfxvideo/gpulib_if.c
@@ -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"
/////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/gpu_neon/Makefile b/plugins/gpu_neon/Makefile
index 2d942f8..93839d2 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 1c462e1..3ff6e48 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 e4b6e6b..dd9e4ca 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 f0539c0..5a0ad2c 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
index 8917f2a..22fe31e 100644
--- a/plugins/gpu_neon/unai_if.cpp
+++ b/plugins/gpu_unai/gpulib_if.cpp
@@ -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
index 0000000..a244524
--- /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
index 114f86e..196b1f9 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/plugins/gpulib/cspace.c b/plugins/gpulib/cspace.c
new file mode 100644
index 0000000..eee56ce
--- /dev/null
+++ b/plugins/gpulib/cspace.c
@@ -0,0 +1,21 @@
+#include "cspace.h"
+
+void bgr555_to_rgb565(void *dst_, const void *src_, int bytes)
+{
+ unsigned int *src = (unsigned int *)src_;
+ unsigned int *dst = (unsigned int *)dst_;
+ unsigned int p;
+ int x;
+
+ for (x = 0; x < bytes / 4; x++) {
+ p = src[x];
+ p = ((p & 0x7c007c00) >> 10) | ((p & 0x03e003e0) << 1)
+ | ((p & 0x001f001f) << 11);
+ dst[x] = p;
+ }
+}
+
+// TODO?
+void bgr888_to_rgb888(void *dst, const void *src, int bytes) {}
+void bgr888_to_rgb565(void *dst, const void *src, int bytes) {}
+
diff --git a/plugins/gpulib/cspace.h b/plugins/gpulib/cspace.h
new file mode 100644
index 0000000..644143b
--- /dev/null
+++ b/plugins/gpulib/cspace.h
@@ -0,0 +1,12 @@
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+void bgr555_to_rgb565(void *dst, const void *src, int bytes);
+void bgr888_to_rgb888(void *dst, const void *src, int bytes);
+void bgr888_to_rgb565(void *dst, const void *src, int bytes);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/plugins/gpulib/cspace_neon.s b/plugins/gpulib/cspace_neon.s
new file mode 100644
index 0000000..abc0381
--- /dev/null
+++ b/plugins/gpulib/cspace_neon.s
@@ -0,0 +1,132 @@
+/*
+ * (C) GraÅžvydas "notaz" Ignotas, 2010
+ *
+ * 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.
+ */
+
+.text
+.align 2
+
+.global bgr555_to_rgb565
+bgr555_to_rgb565:
+ pld [r1]
+ mov r3, #0x07c0
+ vdup.16 q15, r3
+ subs r2, r2, #64
+ blt btr16_end64
+0:
+ pld [r1, #64*2]
+ vldmia r1!, {q0-q3}
+ vshl.u16 q4, q0, #11
+ vshl.u16 q5, q1, #11
+ vshl.u16 q6, q2, #11
+ vshl.u16 q7, q3, #11
+ vsri.u16 q4, q0, #10
+ vsri.u16 q5, q1, #10
+ vsri.u16 q6, q2, #10
+ vsri.u16 q7, q3, #10
+ vshl.u16 q0, q0, #1
+ vshl.u16 q1, q1, #1
+ vshl.u16 q2, q2, #1
+ vshl.u16 q3, q3, #1
+ vbit q4, q0, q15
+ vbit q5, q1, q15
+ vbit q6, q2, q15
+ vbit q7, q3, q15
+ vstmia r0!, {q4-q7}
+ subs r2, r2, #64
+ bge 0b
+
+btr16_end64:
+ adds r2, r2, #64
+ bxeq lr
+ subs r2, r2, #16
+ blt btr16_end16
+
+ @ handle the remainder (reasonably rare)
+0:
+ vld1.16 {q0}, [r1]!
+ vshl.u16 q1, q0, #11
+ vshl.u16 q2, q0, #1
+ vsri.u16 q1, q0, #10
+ vbit q1, q2, q15
+ subs r2, r2, #16
+ vst1.16 {q1}, [r0]!
+ bge 0b
+
+btr16_end16:
+ adds r2, r2, #16
+ bxeq lr
+ subs r2, r2, #8
+ bxlt lr
+
+ @ very rare
+ vld1.16 d0, [r1]!
+ vshl.u16 d1, d0, #11
+ vshl.u16 d2, d0, #1
+ vsri.u16 d1, d0, #10
+ vbit d1, d2, d30
+ vst1.16 d1, [r0]!
+ bx lr
+
+
+.global bgr888_to_rgb888
+bgr888_to_rgb888:
+ pld [r1]
+ @ r2 /= 48
+ mov r2, r2, lsr #4
+ movw r3, #0x5556
+ movt r3, #0x5555
+ umull r12,r2, r3, r2
+0:
+ pld [r1, #48*3]
+ vld3.8 {d0-d2}, [r1, :64]!
+ vld3.8 {d3-d5}, [r1, :64]!
+ vswp d0, d2
+ vswp d3, d5
+ vst3.8 {d0-d2}, [r0, :64]!
+ vst3.8 {d3-d5}, [r0, :64]!
+ subs r2, r2, #1
+ bne 0b
+
+ bx lr
+
+
+.global bgr888_to_rgb565
+bgr888_to_rgb565:
+ pld [r1]
+ @ r2 /= 48
+ mov r2, r2, lsr #4
+ movw r3, #0x5556
+ movt r3, #0x5555
+ umull r12,r2, r3, r2
+
+ mov r3, #0x07e0
+ vdup.16 q15, r3
+0:
+ pld [r1, #48*3]
+ vld3.8 {d1-d3}, [r1, :64]!
+ vld3.8 {d5-d7}, [r1, :64]!
+
+ vshll.u8 q8, d2, #3 @ g
+ vshll.u8 q9, d6, #3
+ vshr.u8 d0, d3, #3 @ b
+ vshr.u8 d4, d7, #3
+ vzip.8 d0, d1 @ rb
+ vzip.8 d4, d5
+ vbit q0, q8, q15
+ vbit q2, q9, q15
+
+ vstmia r0!, {d0,d1}
+ vstmia r0!, {d4,d5}
+ subs r2, r2, #1
+ bne 0b
+
+ bx lr
+
+
+@ vim:filetype=armasm
diff --git a/plugins/gpu_neon/gpu.c b/plugins/gpulib/gpu.c
index 5b16cd4..5b16cd4 100644
--- a/plugins/gpu_neon/gpu.c
+++ b/plugins/gpulib/gpu.c
diff --git a/plugins/gpu_neon/gpu.h b/plugins/gpulib/gpu.h
index d9ad416..d9ad416 100644
--- a/plugins/gpu_neon/gpu.h
+++ b/plugins/gpulib/gpu.h
diff --git a/plugins/gpulib/gpulib.mak b/plugins/gpulib/gpulib.mak
new file mode 100644
index 0000000..cec6f5a
--- /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
index e523e20..e523e20 100644
--- a/plugins/gpu_neon/test.c
+++ b/plugins/gpulib/test.c
diff --git a/plugins/gpu_neon/vout_fb.c b/plugins/gpulib/vout_fb.c
index 20c8ff3..021efa7 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
index db1ae96..db1ae96 100644
--- a/plugins/gpu_neon/vout_sdl.c
+++ b/plugins/gpulib/vout_sdl.c