From: notaz Date: Tue, 22 Oct 2024 16:29:26 +0000 (+0300) Subject: arm: provide bgr888_to_rgb565 for v6 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b06f78f199f6fe13fd91f97db9d6c2465c4b6f68;p=pcsx_rearmed.git arm: provide bgr888_to_rgb565 for v6 --- diff --git a/Makefile b/Makefile index 1219b097..25cbbdf2 100644 --- a/Makefile +++ b/Makefile @@ -285,7 +285,7 @@ CFLAGS += -DHAVE_CHD -I$(LCHDR)/include OBJS += frontend/cspace.o ifeq "$(HAVE_NEON_ASM)" "1" OBJS += frontend/cspace_neon.o -frontend/cspace.o: CFLAGS += -DHAVE_bgr555_to_rgb565 -DHAVE_bgr888_to_x +frontend/cspace.o: CFLAGS += -DHAVE_bgr555_to_rgb565 else ifeq "$(ARCH)" "arm" OBJS += frontend/cspace_arm.o diff --git a/frontend/cspace.c b/frontend/cspace.c index a3e3301f..b4e4a710 100644 --- a/frontend/cspace.c +++ b/frontend/cspace.c @@ -10,6 +10,7 @@ #include #include "cspace.h" +#include "compiler_features.h" /* * note: these are intended for testing and should be avoided @@ -111,9 +112,7 @@ void bgr555_to_rgb565(void *dst_, const void *src_, int bytes) #endif -#ifndef HAVE_bgr888_to_x - -void bgr888_to_rgb565(void *dst_, const void *src_, int bytes) +void attr_weak bgr888_to_rgb565(void *dst_, const void *src_, int bytes) { const unsigned char *src = src_; unsigned int *dst = dst_; @@ -140,8 +139,6 @@ void bgr888_to_rgb565(void *dst_, const void *src_, int bytes) void rgb888_to_rgb565(void *dst, const void *src, int bytes) {} void bgr888_to_rgb888(void *dst, const void *src, int bytes) {} -#endif // __ARM_NEON__ - /* YUV stuff */ static int yuv_ry[32], yuv_gy[32], yuv_by[32]; static unsigned char yuv_u[32 * 2], yuv_v[32 * 2]; diff --git a/frontend/cspace_arm.S b/frontend/cspace_arm.S index 177b0858..3ef5083b 100644 --- a/frontend/cspace_arm.S +++ b/frontend/cspace_arm.S @@ -68,3 +68,52 @@ FUNCTION(bgr555_to_rgb565): @ void *dst, const void *src, int bytes bgt 2b pop {r4-r11,pc} + + +#ifdef HAVE_ARMV6 /* v6-only due to potential misaligned reads */ + +# r1b0g0r0 g2r2b1g1 b3g3r3b2 +FUNCTION(bgr888_to_rgb565): + pld [r1] + push {r4-r10,lr} + + mov r10, #0x001f @ b mask + mov r12, #0x07e0 @ g mask + mov lr, #0xf800 @ r mask + +0: + ldr r3, [r1], #4 @ may be unaligned + ldr r4, [r1], #4 + ldr r5, [r1], #4 + pld [r1, #32*1] + and r6, r10,r3, lsr #16+3 @ b0 + and r7, r12,r3, lsr #5 @ g0 + and r8, lr, r3, lsl #8 @ r0 + and r9, lr, r3, lsr #16 @ r1 + orr r6, r6, r7 + orr r6, r6, r8 @ r0g0b0 + + and r7, r12,r4, lsl #3 @ g1 + and r8, r10,r4, lsr #11 @ b1 + orr r9, r9, r7 + orr r9, r9, r8 @ r1g1b1 + and r7, lr, r4, lsr #8 @ r2 + and r8, r12,r4, lsr #21 @ g2 + pkhbt r9, r6, r9, lsl #16 + str r9, [r0], #4 + + and r6, r10,r5, lsr #3 @ b2 + orr r7, r7, r8 + orr r6, r6, r7 @ r2g2b2 + and r7, lr, r5 @ r3 + and r8, r12,r5, lsr #13 @ g3 + orr r7, r7, r5, lsr #27 @ r3b3 + orr r7, r7, r8 @ r3g3b3 + pkhbt r7, r6, r7, lsl #16 + str r7, [r0], #4 + subs r2, r2, #12 + bgt 0b + + pop {r4-r10,pc} + +#endif /* HAVE_ARMV6 */ diff --git a/include/compiler_features.h b/include/compiler_features.h index 0ab8468b..d6983632 100644 --- a/include/compiler_features.h +++ b/include/compiler_features.h @@ -8,11 +8,13 @@ # define noinline __attribute__((noinline,noclone)) # endif # define attr_unused __attribute__((unused)) +# define attr_weak __attribute__((weak)) #else # define likely(x) (x) # define unlikely(x) (x) # define noinline # define attr_unused +# define attr_weak #endif #ifndef __has_builtin