gpu_neon: rework buffer selection
[pcsx_rearmed.git] / jni / Android.mk
1 LOCAL_PATH := $(call my-dir)
2
3 $(shell cd "$(LOCAL_PATH)" && ((git describe --always || echo) | sed -e 's/.*/#define REV "\0"/' > ../frontend/revision.h_))
4 $(shell cd "$(LOCAL_PATH)" && (diff -q ../frontend/revision.h_ ../frontend/revision.h > /dev/null 2>&1 || cp ../frontend/revision.h_ ../frontend/revision.h))
5 $(shell cd "$(LOCAL_PATH)" && (rm ../frontend/revision.h_))
6
7 HAVE_CHD ?= 1
8 USE_LIBRETRO_VFS ?= 0
9
10 ROOT_DIR     := $(LOCAL_PATH)/..
11 CORE_DIR     := $(ROOT_DIR)/libpcsxcore
12 SPU_DIR      := $(ROOT_DIR)/plugins/dfsound
13 GPU_DIR      := $(ROOT_DIR)/plugins/gpulib
14 CDR_DIR      := $(ROOT_DIR)/plugins/cdrcimg
15 INPUT_DIR    := $(ROOT_DIR)/plugins/dfinput
16 FRONTEND_DIR := $(ROOT_DIR)/frontend
17 NEON_DIR     := $(ROOT_DIR)/plugins/gpu_neon
18 UNAI_DIR     := $(ROOT_DIR)/plugins/gpu_unai
19 PEOPS_DIR    := $(ROOT_DIR)/plugins/dfxvideo
20 DYNAREC_DIR  := $(ROOT_DIR)/libpcsxcore/new_dynarec
21 DEPS_DIR     := $(ROOT_DIR)/deps
22 LIBRETRO_COMMON := $(DEPS_DIR)/libretro-common
23 EXTRA_INCLUDES :=
24
25 # core
26 SOURCES_C := $(CORE_DIR)/cdriso.c \
27              $(CORE_DIR)/cdrom.c \
28              $(CORE_DIR)/cheat.c \
29              $(CORE_DIR)/database.c \
30              $(CORE_DIR)/decode_xa.c \
31              $(CORE_DIR)/mdec.c \
32              $(CORE_DIR)/misc.c \
33              $(CORE_DIR)/plugins.c \
34              $(CORE_DIR)/ppf.c \
35              $(CORE_DIR)/psxbios.c \
36              $(CORE_DIR)/psxcommon.c \
37              $(CORE_DIR)/psxcounters.c \
38              $(CORE_DIR)/psxdma.c \
39              $(CORE_DIR)/psxhle.c \
40              $(CORE_DIR)/psxhw.c \
41              $(CORE_DIR)/psxinterpreter.c \
42              $(CORE_DIR)/psxmem.c \
43              $(CORE_DIR)/r3000a.c \
44              $(CORE_DIR)/sio.c \
45              $(CORE_DIR)/spu.c \
46              $(CORE_DIR)/gte.c \
47              $(CORE_DIR)/gte_nf.c \
48              $(CORE_DIR)/gte_divider.c
49
50 # spu
51 SOURCES_C += $(SPU_DIR)/dma.c \
52              $(SPU_DIR)/freeze.c \
53              $(SPU_DIR)/registers.c \
54              $(SPU_DIR)/spu.c \
55              $(SPU_DIR)/out.c \
56              $(SPU_DIR)/nullsnd.c
57
58 # gpu
59 SOURCES_C += $(GPU_DIR)/gpu.c \
60              $(GPU_DIR)/vout_pl.c
61
62 # cdrcimg
63 SOURCES_C += $(CDR_DIR)/cdrcimg.c
64
65 # dfinput
66 SOURCES_C += $(INPUT_DIR)/main.c \
67              $(INPUT_DIR)/pad.c \
68              $(INPUT_DIR)/guncon.c
69
70 # frontend
71 SOURCES_C += $(FRONTEND_DIR)/main.c \
72              $(FRONTEND_DIR)/plugin.c \
73              $(FRONTEND_DIR)/cspace.c \
74              $(FRONTEND_DIR)/libretro.c
75
76 # libchdr
77 SOURCES_C += \
78              $(DEPS_DIR)/libchdr/deps/lzma-19.00/src/Alloc.c \
79              $(DEPS_DIR)/libchdr/deps/lzma-19.00/src/Bra86.c \
80              $(DEPS_DIR)/libchdr/deps/lzma-19.00/src/BraIA64.c \
81              $(DEPS_DIR)/libchdr/deps/lzma-19.00/src/CpuArch.c \
82              $(DEPS_DIR)/libchdr/deps/lzma-19.00/src/Delta.c \
83              $(DEPS_DIR)/libchdr/deps/lzma-19.00/src/LzFind.c \
84              $(DEPS_DIR)/libchdr/deps/lzma-19.00/src/Lzma86Dec.c \
85              $(DEPS_DIR)/libchdr/deps/lzma-19.00/src/LzmaDec.c \
86              $(DEPS_DIR)/libchdr/deps/lzma-19.00/src/LzmaEnc.c \
87              $(DEPS_DIR)/libchdr/deps/lzma-19.00/src/Sort.c \
88              $(DEPS_DIR)/libchdr/src/libchdr_bitstream.c \
89              $(DEPS_DIR)/libchdr/src/libchdr_cdrom.c \
90              $(DEPS_DIR)/libchdr/src/libchdr_chd.c \
91              $(DEPS_DIR)/libchdr/src/libchdr_flac.c \
92              $(DEPS_DIR)/libchdr/src/libchdr_huffman.c
93 SOURCES_ASM :=
94
95 COREFLAGS := -ffast-math -funroll-loops -DHAVE_LIBRETRO -DNO_FRONTEND -DFRONTEND_SUPPORTS_RGB565 -DANDROID -DREARMED
96 COREFLAGS += -DP_HAVE_MMAP=1 -DP_HAVE_PTHREAD=1 -DP_HAVE_POSIX_MEMALIGN=1 -DHAVE_CHD -D_7ZIP_ST
97
98 ifeq ($(USE_LIBRETRO_VFS),1)
99 SOURCES_C += \
100              $(LIBRETRO_COMMON)/compat/compat_posix_string.c \
101              $(LIBRETRO_COMMON)/compat/fopen_utf8.c \
102              $(LIBRETRO_COMMON)/encodings/compat_strl.c \
103              $(LIBRETRO_COMMON)/encodings/encoding_utf.c \
104              $(LIBRETRO_COMMON)/file/file_path.c \
105              $(LIBRETRO_COMMON)/streams/file_stream.c \
106              $(LIBRETRO_COMMON)/streams/file_stream_transforms.c \
107              $(LIBRETRO_COMMON)/string/stdstring.c \
108              $(LIBRETRO_COMMON)/time/rtime.c \
109              $(LIBRETRO_COMMON)/vfs/vfs_implementation.c
110 COREFLAGS += -DUSE_LIBRETRO_VFS
111 endif
112
113 HAVE_ARI64=0
114 HAVE_LIGHTREC=0
115 LIGHTREC_CUSTOM_MAP=0
116 LIGHTREC_THREADED_COMPILER=0
117 HAVE_GPU_NEON=0
118 ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
119   HAVE_ARI64=1
120   HAVE_GPU_NEON=1
121 else ifeq ($(TARGET_ARCH_ABI),armeabi)
122   HAVE_ARI64=1
123 else ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
124   HAVE_ARI64=1
125   HAVE_GPU_NEON=1
126 else ifeq ($(TARGET_ARCH_ABI),x86_64)
127   HAVE_LIGHTREC=1
128   HAVE_GPU_NEON=1
129 else ifeq ($(TARGET_ARCH_ABI),x86)
130   HAVE_LIGHTREC=1
131   HAVE_GPU_NEON=1
132 else
133   COREFLAGS   += -DDRC_DISABLE
134 endif
135   COREFLAGS   += -DLIGHTREC_CUSTOM_MAP=$(LIGHTREC_CUSTOM_MAP)
136   COREFLAGS   += -DLIGHTREC_ENABLE_THREADED_COMPILER=$(LIGHTREC_THREADED_COMPILER)
137
138 ifeq ($(HAVE_ARI64),1)
139   SOURCES_C   += $(DYNAREC_DIR)/new_dynarec.c \
140                  $(DYNAREC_DIR)/pcsxmem.c
141   ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
142     SOURCES_ASM += $(DYNAREC_DIR)/linkage_arm64.S
143   else
144     SOURCES_ASM += $(CORE_DIR)/gte_arm.S \
145                    $(SPU_DIR)/arm_utils.S \
146                    $(DYNAREC_DIR)/linkage_arm.S
147   endif
148 endif
149   SOURCES_C   += $(DYNAREC_DIR)/emu_if.c
150   SOURCES_C   += $(DYNAREC_DIR)/events.c
151
152 ifeq ($(HAVE_LIGHTREC),1)
153   COREFLAGS   += -DLIGHTREC -DLIGHTREC_STATIC
154   EXTRA_INCLUDES += $(DEPS_DIR)/lightning/include \
155                     $(DEPS_DIR)/lightrec \
156                     $(DEPS_DIR)/lightrec/tlsf \
157                     $(ROOT_DIR)/include/lightning \
158                     $(ROOT_DIR)/include/lightrec
159   SOURCES_C   += $(DEPS_DIR)/lightrec/blockcache.c \
160                                           $(DEPS_DIR)/lightrec/constprop.c \
161                                           $(DEPS_DIR)/lightrec/disassembler.c \
162                                           $(DEPS_DIR)/lightrec/emitter.c \
163                                           $(DEPS_DIR)/lightrec/interpreter.c \
164                                           $(DEPS_DIR)/lightrec/lightrec.c \
165                                           $(DEPS_DIR)/lightrec/memmanager.c \
166                                           $(DEPS_DIR)/lightrec/optimizer.c \
167                                           $(DEPS_DIR)/lightrec/regcache.c \
168                                           $(DEPS_DIR)/lightrec/recompiler.c \
169                                           $(DEPS_DIR)/lightrec/reaper.c
170   SOURCES_C   += $(DEPS_DIR)/lightning/lib/jit_disasm.c \
171                                           $(DEPS_DIR)/lightning/lib/jit_memory.c \
172                                           $(DEPS_DIR)/lightning/lib/jit_names.c \
173                                           $(DEPS_DIR)/lightning/lib/jit_note.c \
174                                           $(DEPS_DIR)/lightning/lib/jit_print.c \
175                                           $(DEPS_DIR)/lightning/lib/jit_size.c \
176                                           $(DEPS_DIR)/lightning/lib/lightning.c
177   SOURCES_C   += $(CORE_DIR)/lightrec/plugin.c $(DEPS_DIR)/lightrec/tlsf/tlsf.c
178 ifeq ($(LIGHTREC_CUSTOM_MAP),1)
179   SOURCES_C   += $(CORE_DIR)/lightrec/mem.c
180 endif
181 endif
182
183
184 ifeq ($(HAVE_GPU_NEON),1)
185   COREFLAGS   += -DNEON_BUILD -DTEXTURE_CACHE_4BPP -DTEXTURE_CACHE_8BPP -DGPU_NEON
186   ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
187     COREFLAGS   += -DHAVE_bgr555_to_rgb565 -DHAVE_bgr888_to_x
188     SOURCES_ASM += $(CORE_DIR)/gte_neon.S \
189                    $(NEON_DIR)/psx_gpu/psx_gpu_arm_neon.S \
190                    $(FRONTEND_DIR)/cspace_neon.S
191   else
192     COREFLAGS   += -DSIMD_BUILD
193     SOURCES_C   += $(NEON_DIR)/psx_gpu/psx_gpu_simd.c
194   endif
195   SOURCES_C   += $(NEON_DIR)/psx_gpu_if.c
196 else ifeq ($(TARGET_ARCH_ABI),armeabi)
197   COREFLAGS   += -DUSE_GPULIB=1 -DGPU_UNAI
198   COREFLAGS   += -DHAVE_bgr555_to_rgb565
199   SOURCES_ASM += $(UNAI_DIR)/gpu_arm.S \
200                  $(FRONTEND_DIR)/cspace_arm.S
201   SOURCES_C += $(UNAI_DIR)/gpulib_if.cpp
202 else
203   COREFLAGS += -fno-strict-aliasing -DGPU_PEOPS
204   SOURCES_C += $(PEOPS_DIR)/gpulib_if.c
205 endif
206
207 GIT_VERSION := " $(shell git rev-parse --short HEAD || echo unknown)"
208 ifneq ($(GIT_VERSION)," unknown")
209   COREFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
210 endif
211
212 include $(CLEAR_VARS)
213 LOCAL_MODULE        := retro
214 LOCAL_SRC_FILES     := $(SOURCES_C) $(SOURCES_ASM)
215 LOCAL_CFLAGS        := $(COREFLAGS)
216 LOCAL_C_INCLUDES    := $(ROOT_DIR)/include
217 LOCAL_C_INCLUDES    += $(DEPS_DIR)/crypto $(DEPS_DIR)/libchdr/deps/lzma-19.00/include $(DEPS_DIR)/libchdr/include $(DEPS_DIR)/libchdr/include/libchdr
218 LOCAL_C_INCLUDES    += $(LIBRETRO_COMMON)/include
219 LOCAL_C_INCLUDES    += $(EXTRA_INCLUDES)
220 LOCAL_LDFLAGS       := -Wl,-version-script=$(FRONTEND_DIR)/link.T
221 LOCAL_LDLIBS        := -lz -llog
222 LOCAL_ARM_MODE      := arm
223
224 ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
225   LOCAL_ARM_NEON  := true
226 endif
227
228 include $(BUILD_SHARED_LIBRARY)