From: notaz Date: Mon, 11 Dec 2023 21:31:40 +0000 (+0200) Subject: standalone: revive spu_c64x build X-Git-Tag: r24~16 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=42dde520a83b9c391b41b0eceecb1ce3eaed7e72;p=pcsx_rearmed.git standalone: revive spu_c64x build and some other minor pandora stuff --- diff --git a/Makefile b/Makefile index 6ded0df0..7a52cdb0 100644 --- a/Makefile +++ b/Makefile @@ -102,7 +102,7 @@ ifeq "$(ARCH)" "arm" OBJS += plugins/dfsound/arm_utils.o endif ifeq "$(HAVE_C64_TOOLS)" "1" -plugins/dfsound/spu.o: CFLAGS += -DC64X_DSP +plugins/dfsound/%.o: CFLAGS += -DC64X_DSP -DWANT_THREAD_CODE plugins/dfsound/spu.o: plugins/dfsound/spu_c64x.c frontend/menu.o: CFLAGS += -DC64X_DSP endif @@ -220,6 +220,8 @@ frontend/main.o frontend/menu.o: CFLAGS += -include frontend/pandora/ui_feat.h frontend/libpicofe/linux/plat.o: CFLAGS += -DPANDORA USE_PLUGIN_LIB = 1 USE_FRONTEND = 1 +CFLAGS += -gdwarf-3 -ffunction-sections -fdata-sections +LDFLAGS += -Wl,--gc-sections endif ifeq "$(PLATFORM)" "caanoo" OBJS += frontend/libpicofe/gp2x/in_gp2x.o frontend/warm/warm.o diff --git a/frontend/menu.c b/frontend/menu.c index 6705b639..6f74d451 100644 --- a/frontend/menu.c +++ b/frontend/menu.c @@ -1720,6 +1720,7 @@ static const char h_confirm_save[] = "Ask for confirmation when overwriting s static const char h_restore_def[] = "Switches back to default / recommended\n" "configuration"; static const char h_frameskip[] = "Warning: frameskip sometimes causes glitches\n"; +static const char h_sputhr[] = "Warning: has some known bugs\n"; static menu_entry e_menu_options[] = { @@ -1730,9 +1731,9 @@ static menu_entry e_menu_options[] = mee_enum ("Region", 0, region, men_region), mee_range ("CPU clock", MA_OPT_CPU_CLOCKS, cpu_clock, 20, 5000), #ifdef C64X_DSP - mee_onoff ("Use C64x DSP for sound", MA_OPT_SPU_THREAD, spu_config.iUseThread, 1), + mee_onoff_h ("Use C64x DSP for sound", MA_OPT_SPU_THREAD, spu_config.iUseThread, 1, h_sputhr), #else - mee_onoff ("Threaded SPU", MA_OPT_SPU_THREAD, spu_config.iUseThread, 1), + mee_onoff_h ("Threaded SPU", MA_OPT_SPU_THREAD, spu_config.iUseThread, 1, h_sputhr), #endif mee_handler_id("[Display]", MA_OPT_DISP_OPTS, menu_loop_gfx_options), mee_handler ("[BIOS/Plugins]", menu_loop_plugin_options), diff --git a/frontend/plugin_lib.c b/frontend/plugin_lib.c index 43216c67..1cbfdb0e 100644 --- a/frontend/plugin_lib.c +++ b/frontend/plugin_lib.c @@ -338,7 +338,7 @@ static void pl_vout_flip(const void *vram, int stride, int bgr24, doffs = xoffs + y * dstride; if (dims_changed) - flip_clear_counter = 2; + flip_clear_counter = 3; if (flip_clear_counter > 0) { if (pl_plat_clear) diff --git a/plugins/dfsound/Makefile.c64p b/plugins/dfsound/Makefile.c64p index 5b977810..5942017e 100644 --- a/plugins/dfsound/Makefile.c64p +++ b/plugins/dfsound/Makefile.c64p @@ -1,6 +1,9 @@ ifndef C64_TOOLS_DSP_ROOT $(error need C64_TOOLS_DSP_ROOT) endif +ifndef TI_CGTOOLS +$(error need TI_CGTOOLS and stuff, source c64_tools/dsp/setenv.sh) +endif include $(C64_TOOLS_DSP_ROOT)/install.mk diff --git a/plugins/dfsound/externals.h b/plugins/dfsound/externals.h index e85c191b..2b593ec7 100644 --- a/plugins/dfsound/externals.h +++ b/plugins/dfsound/externals.h @@ -253,13 +253,17 @@ typedef struct sample_buf sb[MAXCHAN]; int interpolation; - sample_buf sb_thread[MAXCHAN]; + +#if P_HAVE_PTHREAD || defined(WANT_THREAD_CODE) + sample_buf * sb_thread; + sample_buf sb_thread_[MAXCHAN]; +#endif } SPUInfo; #define regAreaGet(offset) \ - spu.regArea[((offset) - 0xc00)>>1] + spu.regArea[((offset) - 0xc00) >> 1] #define regAreaGetCh(ch, offset) \ - spu.regArea[((ch<<4)|(offset))>>1] + spu.regArea[(((ch) << 4) | (offset)) >> 1] /////////////////////////////////////////////////////////// // SPU.C globals diff --git a/plugins/dfsound/gauss_i.h b/plugins/dfsound/gauss_i.h index 012cf701..e754347e 100644 --- a/plugins/dfsound/gauss_i.h +++ b/plugins/dfsound/gauss_i.h @@ -308,4 +308,4 @@ const int gauss[]={ 0xffffffff, 0x1307, 0x59b3, 0x12c7, }; -#endif \ No newline at end of file +#endif diff --git a/plugins/dfsound/spu.c b/plugins/dfsound/spu.c index 6671e3ed..0e4b154e 100644 --- a/plugins/dfsound/spu.c +++ b/plugins/dfsound/spu.c @@ -1490,6 +1490,8 @@ static void init_spu_thread(void) { int ret; + spu.sb_thread = spu.sb_thread_; + if (sysconf(_SC_NPROCESSORS_ONLN) <= 1) return; diff --git a/plugins/dfsound/spu_c64x.c b/plugins/dfsound/spu_c64x.c index e0aa0da2..cb0d0b58 100644 --- a/plugins/dfsound/spu_c64x.c +++ b/plugins/dfsound/spu_c64x.c @@ -162,7 +162,7 @@ static void thread_work_wait_sync(struct work_item *work, int force) preload(work->SSumLR); preload(work->SSumLR + 64/4); - f.stale_caches = 1; // SB, spuMem + f.stale_caches = 1; // sb, spuMem if (limit == 0) printf("dsp: wait timeout\n"); @@ -188,7 +188,7 @@ static void thread_work_wait_sync(struct work_item *work, int force) static void thread_sync_caches(void) { if (f.stale_caches) { - f.dsp_cache_inv_virt(spu.SB, sizeof(spu.SB[0]) * SB_SIZE * 24); + f.dsp_cache_inv_virt(spu.sb_thread, sizeof(spu.sb_thread[0]) * MAXCHAN); f.dsp_cache_inv_virt(spu.spuMemC + 0x800, 0x800); if (spu.rvb->StartAddr) { int left = 0x40000 - spu.rvb->StartAddr; @@ -281,8 +281,7 @@ static void init_spu_thread(void) // override default allocations free(spu.spuMemC); spu.spuMemC = mem->spu_ram; - free(spu.SB); - spu.SB = mem->SB; + spu.sb_thread = mem->sb_thread; free(spu.s_chan); spu.s_chan = mem->in.s_chan; free(spu.rvb); @@ -326,7 +325,7 @@ static void exit_spu_thread(void) f.dsp_close(); spu.spuMemC = NULL; - spu.SB = NULL; + spu.sb_thread = spu.sb_thread_; spu.s_chan = NULL; spu.rvb = NULL; worker = NULL; diff --git a/plugins/dfsound/spu_c64x.h b/plugins/dfsound/spu_c64x.h index 56ede38d..dd07da1b 100644 --- a/plugins/dfsound/spu_c64x.h +++ b/plugins/dfsound/spu_c64x.h @@ -1,6 +1,9 @@ #ifndef __P_SPU_C64X_H__ #define __P_SPU_C64X_H__ +#include "externals.h" +#include "spu_config.h" + #define COMPONENT_NAME "pcsxr_spu" enum { @@ -10,10 +13,10 @@ enum { struct region_mem { unsigned char spu_ram[512 * 1024]; - int SB[SB_SIZE * 24]; + sample_buf sb_thread[MAXCHAN]; // careful not to lose ARM writes by DSP overwriting // with old data when it's writing out neighbor cachelines - int _pad1[128/4 - ((SB_SIZE * 24) & (128/4 - 1))]; + int _pad1[128/4 - ((sizeof(sample_buf) * MAXCHAN / 4) & (128/4 - 1))]; struct spu_in { // these are not to be modified by DSP SPUCHAN s_chan[24 + 1]; diff --git a/plugins/dfsound/spu_c64x_dspcode.c b/plugins/dfsound/spu_c64x_dspcode.c index 570da5ed..709519c1 100644 --- a/plugins/dfsound/spu_c64x_dspcode.c +++ b/plugins/dfsound/spu_c64x_dspcode.c @@ -114,7 +114,7 @@ static void do_processing(void) // nothing to do? Write out non-critical caches if (dirty) { syscalls.cache_wb(spu.spuMemC + 0x800, 0x800, 1); - syscalls.cache_wb(spu.SB, sizeof(spu.SB[0]) * SB_SIZE * 24, 1); + syscalls.cache_wb(spu.sb_thread, sizeof(spu.sb_thread[0]) * MAXCHAN, 1); if (had_rvb) { left = 0x40000 - spu.rvb->StartAddr; syscalls.cache_wb(spu.spuMem + spu.rvb->StartAddr, left * 2, 1); @@ -143,7 +143,7 @@ static unsigned int exec(dsp_component_cmd_t cmd, InitADSR(); spu.spuMemC = mem->spu_ram; - spu.SB = mem->SB; + spu.sb_thread = mem->sb_thread; spu.s_chan = mem->in.s_chan; spu.rvb = &mem->in.rvb; worker = &mem->worker; @@ -169,7 +169,7 @@ static unsigned int exec(dsp_component_cmd_t cmd, do_processing(); - syscalls.cache_inv(&mem->SB, sizeof(mem->SB), 0); + syscalls.cache_inv(&mem->sb_thread, sizeof(mem->sb_thread), 0); syscalls.cache_inv(&mem->in, sizeof(mem->in), 0); break; diff --git a/plugins/dfsound/stdafx.h b/plugins/dfsound/stdafx.h index ff082bc8..71921a92 100644 --- a/plugins/dfsound/stdafx.h +++ b/plugins/dfsound/stdafx.h @@ -32,7 +32,7 @@ #define INLINE static inline #endif -#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ +#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ #define HTOLE16(x) __builtin_bswap16(x) #define LE16TOH(x) __builtin_bswap16(x) #else