MAMEWorld >> News
View all threads Index   Threaded Mode Threaded  

Pages: 1

Vas Crabb
BOFH
Reged: 12/12/05
Posts: 4088
Loc: Melbourne, Australia
Send PM


Vas: Let's have fun with DSPs! (QSound WIP)
#374742 - 03/15/18 03:27 AM Attachment: qsound.wav 2826 KB (60 downloads)


The DSP16A is an interesting chip. It's like the great granddaddy of VLIW and EPIC.

  • The instruction set is explicitly parallel, and it can manage a 16*16->32 multiply, a 32+36->36 or 36+36->36 addition, a 12+12->12 addition, a 16+16->16 (9+9->9 on DSP16) addition, two 8-bit increments, a ROM fetch, and a RAM access in a single cycle. Yes, the word is "and", although there are limitations on the exact combinations you can use.
  • There are effectively no general-purpose registers - every register has an assigned role, although in some cases a few registers are interchangeable (e.g. the two accumulators and four RAM pointers).
  • It has dedicated silicon for saturation and rounding.
  • It doesn't actually have a fused multiply/add instruction (aka FMA, multiply/accumulate, MAC) - if you issue a multiply and an add in the same instruction, the add operates on the previous multiplication's product.
  • It has an on-board pseudorandom sequence generator.
  • It normally overlaps the ROM fetch for the next instruction with the current instruction, but it has a manually managed 15-instruction cache in the control unit. When executing from cache, it can overlap a ROM data fetch for the next instruction with the current instruction for higher throughput. By executing a tight loop from cache, you can make a very fast FIR filter with coefficients in ROM.
  • Although the DSP16 can only use internal program ROM or external program memory, but not both at the same time, the DSP16A can access external program memory while the internal ROM is enabled (QSound uses this to read sample data).
  • It supports multi-master time-division multiplexed synchronous serial protocols, making it ideal for processing circuit-switched voice calls in phone network switches.
  • The QSound DSP runs at 30MHz (60MHz clock input divided by two). On CPS2, it's already clocked at almost three times the speed of the main 68k CPU, it can issue an instruction every one or two cycles, and it can do up to four operations per instruction. The 68k main CPU takes several cycles to execute most instructions, and multiplies are particularly time-consuming. The QSound DSP is far more powerful than the main CPU - maybe 40 times the throughput.


The QSound program has been dumped for some time, and MAME has a DSP16 core. However, it doesn't implement all the functionality required to run the QSound program, and it isn't cycle-accurate, which is needed for the QSound DSP to output at a consistent sample rate. MAME's QSound device will show disassembly for the DSP program, but it won't do anything else with it. The only effects used are volume control and a simple panning table.

I've written a DSP16 core with enough functionality to run the QSound program that runs at machine cycle granularity and hooked it up in a private branch. The QSound program works, and effects are present. So what's the catch? Emulating a fast DSP costs performance - you'll need a fast computer to run it at full speed in its current form. I'm considering writing a recompiler for the DSP16 which would yield a large performance improvement.

If you want to try out the first emulator with real QSound support, the source is on github here. Be aware that it requires a fast computer to run CPS2 at full speed. It also prints some nasty validation errors, but they don't stop it from working The new QSound device source file has some notes on how it works at a high level.

I've attached a recording of the first thirty seconds of Street Fighter Zero 2 Alpha (Japan). The QSound jingle at about 8s plays all sixteen channels simultaneously with effects enabled. From about 18s you can hear the beginning of the attract loop music.



Firehawke
Manual Meister
Reged: 08/12/06
Posts: 661
Send PM


Re: Vas: Let's have fun with DSPs! (QSound WIP) new [Re: Vas Crabb]
#374744 - 03/15/18 04:29 AM


I put together a quick demo video of the new audio improvements: https://www.twitch.tv/videos/238950989
It goes SFA2 old, SFA2 with QSound, SFA1 old, then SFA1 with QSound. Seems like SFA2 is a lot more noticeable than SFA1, but I'd put that down to them having more time to work with QSound in general.



---
Try checking the MAME manual at http://docs.mamedev.org



ArcadeG
MAME Fan
Reged: 04/21/17
Posts: 25
Send PM


Re: Vas: Let's have fun with DSPs! (QSound WIP) new [Re: Vas Crabb]
#374758 - 03/15/18 03:38 PM


will it be added on the next mame?



MooglyGuy
Renegade MAME Dev
Reged: 09/01/05
Posts: 1989
Send PM


Re: Vas: Let's have fun with DSPs! (QSound WIP) new [Re: ArcadeG]
#374759 - 03/15/18 03:54 PM


> will it be added on the next mame?

No, never. Seriously?



Shoegazr
Rockstar
Reged: 01/21/06
Posts: 644
Send PM


Re: Vas: Let's have fun with DSPs! (QSound WIP) new [Re: Vas Crabb]
#374764 - 03/15/18 08:55 PM


Fantastic! I've been hoping for progress on Qsound for years, long before the DSP16A was even dumped. Thanks so much Vas. Awesome stuff.



John IVModerator
IV/Play, MAME, MAMEUI
Reged: 09/22/03
Posts: 1757
Loc: Snohomish, WA, USA
Send PM


Re: Vas: Let's have fun with DSPs! (QSound WIP) new [Re: Vas Crabb]
#374823 - 03/17/18 04:41 PM


Is this active in mainline in the current GIT? I'm still getting 2600% FPS in the cps2 games. What kind of hit was expected?



john iv
http://www.mameui.info/



Vas Crabb
BOFH
Reged: 12/12/05
Posts: 4088
Loc: Melbourne, Australia
Send PM


Re: Vas: Let's have fun with DSPs! (QSound WIP) new [Re: John IV]
#374826 - 03/17/18 06:11 PM


> Is this active in mainline in the current GIT? I'm still getting 2600% FPS in the
> cps2 games. What kind of hit was expected?

No, it's only enabled on vgmplay in mainline. You can edit one line in src/devices/qsound.h if you want to enable it for all drivers with QSound - see here: https://github.com/mamedev/mame/commit/3f67473bb42a6e8c5a47d73abe1ddbfb8118ee1c#r28107223

The performance varies depending on your CPU - memory controllers are king. You can get over 100% in CPS2 with QSound DSP on a Haswell-E or a Xeon E5v2, but a regular i7 without the amp'd memory controllers is likely to dip to around 70% or so.



John IVModerator
IV/Play, MAME, MAMEUI
Reged: 09/22/03
Posts: 1757
Loc: Snohomish, WA, USA
Send PM


Re: Vas: Let's have fun with DSPs! (QSound WIP) new [Re: Vas Crabb]
#374848 - 03/18/18 05:12 AM


Thanks. For a datapoint, I'm getting 149% on sfa2 -bench 90 on my
i7-6700K Skylake oc'ed to 4.5Ghz.

http://www.mameui.info/Bench.htm
For additional HW info.



john iv
http://www.mameui.info/


Pages: 1

MAMEWorld >> News
View all threads Index   Threaded Mode Threaded  

Extra information Permissions
Moderator:  John IV, Tafoid 
0 registered and 3 anonymous users are browsing this forum.
You cannot start new topics
You cannot reply to topics
HTML is enabled
UBBCode is enabled
Thread views: 1291