From 5514a050f4e936f5c333fa1271b11bf5a6a9ea39 Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 4 Jan 2015 01:43:23 +0200 Subject: spu: start offload code to TI C64x DSP --- plugins/dfsound/reverb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'plugins/dfsound/reverb.c') diff --git a/plugins/dfsound/reverb.c b/plugins/dfsound/reverb.c index bb5ee8e..b7bcf12 100644 --- a/plugins/dfsound/reverb.c +++ b/plugins/dfsound/reverb.c @@ -32,11 +32,11 @@ INLINE void StartREVERB(int ch) { - if(s_chan[ch].bReverb && (spu.spuCtrl&0x80)) // reverb possible? + if(spu.s_chan[ch].bReverb && (spu.spuCtrl&0x80)) // reverb possible? { - s_chan[ch].bRVBActive=!!spu_config.iUseReverb; + spu.s_chan[ch].bRVBActive=!!spu_config.iUseReverb; } - else s_chan[ch].bRVBActive=0; // else -> no reverb + else spu.s_chan[ch].bRVBActive=0; // else -> no reverb } //////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 3bd31caf9e9f5ddab2bf4fbdb5a129f4972c45f3 Mon Sep 17 00:00:00 2001 From: notaz Date: Sat, 10 Jan 2015 01:55:24 +0200 Subject: spu: support multiple pending buffers for threaded implementation --- plugins/dfsound/reverb.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'plugins/dfsound/reverb.c') diff --git a/plugins/dfsound/reverb.c b/plugins/dfsound/reverb.c index b7bcf12..7e32b8e 100644 --- a/plugins/dfsound/reverb.c +++ b/plugins/dfsound/reverb.c @@ -39,15 +39,6 @@ INLINE void StartREVERB(int ch) else spu.s_chan[ch].bRVBActive=0; // else -> no reverb } -//////////////////////////////////////////////////////////////////////// -// HELPER FOR NEILL'S REVERB: re-inits our reverb mixing buf -//////////////////////////////////////////////////////////////////////// - -INLINE void InitREVERB(int ns_to) -{ - memset(spu.sRVBStart,0,ns_to*sizeof(spu.sRVBStart[0])*2); -} - //////////////////////////////////////////////////////////////////////// INLINE int rvb2ram_offs(int curr, int space, int iOff) @@ -73,7 +64,7 @@ INLINE int rvb2ram_offs(int curr, int space, int iOff) //////////////////////////////////////////////////////////////////////// // portions based on spu2-x from PCSX2 -static void MixREVERB(int ns_to) +static void MixREVERB(int *SSumLR, int *RVB, int ns_to) { int l_old = rvb.iRVBLeft; int r_old = rvb.iRVBRight; @@ -87,8 +78,8 @@ static void MixREVERB(int ns_to) int ACC0, ACC1, FB_A0, FB_A1, FB_B0, FB_B1; int mix_dest_a0, mix_dest_a1, mix_dest_b0, mix_dest_b1; - int input_L = spu.sRVBStart[ns] * rvb.IN_COEF_L; - int input_R = spu.sRVBStart[ns+1] * rvb.IN_COEF_R; + int input_L = RVB[ns] * rvb.IN_COEF_L; + int input_R = RVB[ns+1] * rvb.IN_COEF_R; int IIR_INPUT_A0 = ((g_buffer(IIR_SRC_A0) * rvb.IIR_COEF) + input_L) >> 15; int IIR_INPUT_A1 = ((g_buffer(IIR_SRC_A1) * rvb.IIR_COEF) + input_R) >> 15; @@ -158,7 +149,7 @@ static void MixREVERB(int ns_to) rvb.CurrAddr = curr_addr; } -static void MixREVERB_off(int ns_to) +static void MixREVERB_off(int *SSumLR, int ns_to) { int l_old = rvb.iRVBLeft; int r_old = rvb.iRVBRight; @@ -236,7 +227,7 @@ static void prepare_offsets(void) rvb.dirty = 0; } -INLINE void REVERBDo(int ns_to) +INLINE void REVERBDo(int *SSumLR, int *RVB, int ns_to) { if (!rvb.StartAddr) // reverb is off { @@ -249,14 +240,14 @@ INLINE void REVERBDo(int ns_to) if (unlikely(rvb.dirty)) prepare_offsets(); - MixREVERB(ns_to); + MixREVERB(SSumLR, RVB, ns_to); } else if (rvb.VolLeft || rvb.VolRight) { if (unlikely(rvb.dirty)) prepare_offsets(); - MixREVERB_off(ns_to); + MixREVERB_off(SSumLR, ns_to); } else // -> reverb off { -- cgit v1.2.3 From 05c7cec77522f04857f655474574469a5e66661d Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 11 Jan 2015 03:35:32 +0200 Subject: spu: put reverb on the thread too and more stuff to work struct --- plugins/dfsound/reverb.c | 147 +++++++++++++++++++---------------------------- 1 file changed, 59 insertions(+), 88 deletions(-) (limited to 'plugins/dfsound/reverb.c') diff --git a/plugins/dfsound/reverb.c b/plugins/dfsound/reverb.c index 7e32b8e..2ff6edc 100644 --- a/plugins/dfsound/reverb.c +++ b/plugins/dfsound/reverb.c @@ -50,41 +50,40 @@ INLINE int rvb2ram_offs(int curr, int space, int iOff) // get_buffer content helper: takes care about wraps #define g_buffer(var) \ - ((int)(signed short)spu.spuMem[rvb2ram_offs(curr_addr, space, rvb.n##var)]) + ((int)(signed short)spu.spuMem[rvb2ram_offs(curr_addr, space, rvb->n##var)]) // saturate iVal and store it as var #define s_buffer(var, iVal) \ ssat32_to_16(iVal); \ - spu.spuMem[rvb2ram_offs(curr_addr, space, rvb.n##var)] = iVal + spu.spuMem[rvb2ram_offs(curr_addr, space, rvb->n##var)] = iVal #define s_buffer1(var, iVal) \ ssat32_to_16(iVal); \ - spu.spuMem[rvb2ram_offs(curr_addr, space, rvb.n##var + 1)] = iVal + spu.spuMem[rvb2ram_offs(curr_addr, space, rvb->n##var + 1)] = iVal //////////////////////////////////////////////////////////////////////// // portions based on spu2-x from PCSX2 -static void MixREVERB(int *SSumLR, int *RVB, int ns_to) +static void MixREVERB(int *SSumLR, int *RVB, int ns_to, int curr_addr) { - int l_old = rvb.iRVBLeft; - int r_old = rvb.iRVBRight; - int curr_addr = rvb.CurrAddr; - int space = 0x40000 - rvb.StartAddr; - int l = 0, r = 0, ns; + const REVERBInfo *rvb = spu.rvb; + int IIR_ALPHA = rvb->IIR_ALPHA; + int IIR_COEF = rvb->IIR_COEF; + int space = 0x40000 - rvb->StartAddr; + int l, r, ns; for (ns = 0; ns < ns_to * 2; ) { - int IIR_ALPHA = rvb.IIR_ALPHA; int ACC0, ACC1, FB_A0, FB_A1, FB_B0, FB_B1; int mix_dest_a0, mix_dest_a1, mix_dest_b0, mix_dest_b1; - int input_L = RVB[ns] * rvb.IN_COEF_L; - int input_R = RVB[ns+1] * rvb.IN_COEF_R; + int input_L = RVB[ns] * rvb->IN_COEF_L; + int input_R = RVB[ns+1] * rvb->IN_COEF_R; - int IIR_INPUT_A0 = ((g_buffer(IIR_SRC_A0) * rvb.IIR_COEF) + input_L) >> 15; - int IIR_INPUT_A1 = ((g_buffer(IIR_SRC_A1) * rvb.IIR_COEF) + input_R) >> 15; - int IIR_INPUT_B0 = ((g_buffer(IIR_SRC_B0) * rvb.IIR_COEF) + input_L) >> 15; - int IIR_INPUT_B1 = ((g_buffer(IIR_SRC_B1) * rvb.IIR_COEF) + input_R) >> 15; + int IIR_INPUT_A0 = ((g_buffer(IIR_SRC_A0) * IIR_COEF) + input_L) >> 15; + int IIR_INPUT_A1 = ((g_buffer(IIR_SRC_A1) * IIR_COEF) + input_R) >> 15; + int IIR_INPUT_B0 = ((g_buffer(IIR_SRC_B0) * IIR_COEF) + input_L) >> 15; + int IIR_INPUT_B1 = ((g_buffer(IIR_SRC_B1) * IIR_COEF) + input_R) >> 15; int iir_dest_a0 = g_buffer(IIR_DEST_A0); int iir_dest_a1 = g_buffer(IIR_DEST_A1); @@ -96,30 +95,34 @@ static void MixREVERB(int *SSumLR, int *RVB, int ns_to) int IIR_B0 = iir_dest_b0 + ((IIR_INPUT_B0 - iir_dest_b0) * IIR_ALPHA >> 15); int IIR_B1 = iir_dest_b1 + ((IIR_INPUT_B1 - iir_dest_b1) * IIR_ALPHA >> 15); + preload(SSumLR + ns + 64*2/4 - 4); + s_buffer1(IIR_DEST_A0, IIR_A0); s_buffer1(IIR_DEST_A1, IIR_A1); s_buffer1(IIR_DEST_B0, IIR_B0); s_buffer1(IIR_DEST_B1, IIR_B1); - ACC0 = (g_buffer(ACC_SRC_A0) * rvb.ACC_COEF_A + - g_buffer(ACC_SRC_B0) * rvb.ACC_COEF_B + - g_buffer(ACC_SRC_C0) * rvb.ACC_COEF_C + - g_buffer(ACC_SRC_D0) * rvb.ACC_COEF_D) >> 15; - ACC1 = (g_buffer(ACC_SRC_A1) * rvb.ACC_COEF_A + - g_buffer(ACC_SRC_B1) * rvb.ACC_COEF_B + - g_buffer(ACC_SRC_C1) * rvb.ACC_COEF_C + - g_buffer(ACC_SRC_D1) * rvb.ACC_COEF_D) >> 15; + preload(RVB + ns + 64*2/4 - 4); + + ACC0 = (g_buffer(ACC_SRC_A0) * rvb->ACC_COEF_A + + g_buffer(ACC_SRC_B0) * rvb->ACC_COEF_B + + g_buffer(ACC_SRC_C0) * rvb->ACC_COEF_C + + g_buffer(ACC_SRC_D0) * rvb->ACC_COEF_D) >> 15; + ACC1 = (g_buffer(ACC_SRC_A1) * rvb->ACC_COEF_A + + g_buffer(ACC_SRC_B1) * rvb->ACC_COEF_B + + g_buffer(ACC_SRC_C1) * rvb->ACC_COEF_C + + g_buffer(ACC_SRC_D1) * rvb->ACC_COEF_D) >> 15; FB_A0 = g_buffer(FB_SRC_A0); FB_A1 = g_buffer(FB_SRC_A1); FB_B0 = g_buffer(FB_SRC_B0); FB_B1 = g_buffer(FB_SRC_B1); - mix_dest_a0 = ACC0 - ((FB_A0 * rvb.FB_ALPHA) >> 15); - mix_dest_a1 = ACC1 - ((FB_A1 * rvb.FB_ALPHA) >> 15); + mix_dest_a0 = ACC0 - ((FB_A0 * rvb->FB_ALPHA) >> 15); + mix_dest_a1 = ACC1 - ((FB_A1 * rvb->FB_ALPHA) >> 15); - mix_dest_b0 = FB_A0 + (((ACC0 - FB_A0) * rvb.FB_ALPHA - FB_B0 * rvb.FB_X) >> 15); - mix_dest_b1 = FB_A1 + (((ACC1 - FB_A1) * rvb.FB_ALPHA - FB_B1 * rvb.FB_X) >> 15); + mix_dest_b0 = FB_A0 + (((ACC0 - FB_A0) * rvb->FB_ALPHA - FB_B0 * rvb->FB_X) >> 15); + mix_dest_b1 = FB_A1 + (((ACC1 - FB_A1) * rvb->FB_ALPHA - FB_B1 * rvb->FB_X) >> 15); s_buffer(MIX_DEST_A0, mix_dest_a0); s_buffer(MIX_DEST_A1, mix_dest_a1); @@ -129,73 +132,60 @@ static void MixREVERB(int *SSumLR, int *RVB, int ns_to) l = (mix_dest_a0 + mix_dest_b0) / 2; r = (mix_dest_a1 + mix_dest_b1) / 2; - l = (l * rvb.VolLeft) >> 15; // 15? - r = (r * rvb.VolRight) >> 15; + l = (l * rvb->VolLeft) >> 15; // 15? + r = (r * rvb->VolRight) >> 15; - SSumLR[ns++] += (l + l_old) / 2; - SSumLR[ns++] += (r + r_old) / 2; SSumLR[ns++] += l; SSumLR[ns++] += r; - - l_old = l; - r_old = r; + SSumLR[ns++] += l; + SSumLR[ns++] += r; curr_addr++; - if (curr_addr >= 0x40000) curr_addr = rvb.StartAddr; + if (curr_addr >= 0x40000) curr_addr = rvb->StartAddr; } - - rvb.iRVBLeft = l; - rvb.iRVBRight = r; - rvb.CurrAddr = curr_addr; } -static void MixREVERB_off(int *SSumLR, int ns_to) +static void MixREVERB_off(int *SSumLR, int ns_to, int curr_addr) { - int l_old = rvb.iRVBLeft; - int r_old = rvb.iRVBRight; - int curr_addr = rvb.CurrAddr; - int space = 0x40000 - rvb.StartAddr; - int l = 0, r = 0, ns; + const REVERBInfo *rvb = spu.rvb; + int space = 0x40000 - rvb->StartAddr; + int l, r, ns; for (ns = 0; ns < ns_to * 2; ) { + preload(SSumLR + ns + 64*2/4 - 4); + l = (g_buffer(MIX_DEST_A0) + g_buffer(MIX_DEST_B0)) / 2; r = (g_buffer(MIX_DEST_A1) + g_buffer(MIX_DEST_B1)) / 2; - l = (l * rvb.VolLeft) >> 15; - r = (r * rvb.VolRight) >> 15; + l = (l * rvb->VolLeft) >> 15; + r = (r * rvb->VolRight) >> 15; - SSumLR[ns++] += (l + l_old) / 2; - SSumLR[ns++] += (r + r_old) / 2; SSumLR[ns++] += l; SSumLR[ns++] += r; - - l_old = l; - r_old = r; + SSumLR[ns++] += l; + SSumLR[ns++] += r; curr_addr++; - if (curr_addr >= 0x40000) curr_addr = rvb.StartAddr; + if (curr_addr >= 0x40000) curr_addr = rvb->StartAddr; } - - rvb.iRVBLeft = l; - rvb.iRVBRight = r; - rvb.CurrAddr = curr_addr; } -static void prepare_offsets(void) +static void REVERBPrep(void) { - int space = 0x40000 - rvb.StartAddr; + REVERBInfo *rvb = spu.rvb; + int space = 0x40000 - rvb->StartAddr; int t; #define prep_offs(v) \ - t = rvb.v; \ + t = rvb->v; \ while (t >= space) \ t -= space; \ - rvb.n##v = t + rvb->n##v = t #define prep_offs2(d, v1, v2) \ - t = rvb.v1 - rvb.v2; \ + t = rvb->v1 - rvb->v2; \ while (t >= space) \ t -= space; \ - rvb.n##d = t + rvb->n##d = t prep_offs(IIR_SRC_A0); prep_offs(IIR_SRC_A1); @@ -224,37 +214,18 @@ static void prepare_offsets(void) #undef prep_offs #undef prep_offs2 - rvb.dirty = 0; + rvb->dirty = 0; } -INLINE void REVERBDo(int *SSumLR, int *RVB, int ns_to) +INLINE void REVERBDo(int *SSumLR, int *RVB, int ns_to, int curr_addr) { - if (!rvb.StartAddr) // reverb is off - { - rvb.iRVBLeft = rvb.iRVBRight = 0; - return; - } - if (spu.spuCtrl & 0x80) // -> reverb on? oki { - if (unlikely(rvb.dirty)) - prepare_offsets(); - - MixREVERB(SSumLR, RVB, ns_to); - } - else if (rvb.VolLeft || rvb.VolRight) - { - if (unlikely(rvb.dirty)) - prepare_offsets(); - - MixREVERB_off(SSumLR, ns_to); + MixREVERB(SSumLR, RVB, ns_to, curr_addr); } - else // -> reverb off + else if (spu.rvb->VolLeft || spu.rvb->VolRight) { - // reverb runs anyway - rvb.CurrAddr += ns_to / 2; - while (rvb.CurrAddr >= 0x40000) - rvb.CurrAddr -= 0x40000 - rvb.StartAddr; + MixREVERB_off(SSumLR, ns_to, curr_addr); } } -- cgit v1.2.3