flyinghead / flycast

Flycast is a multiplatform Sega Dreamcast, Naomi, Naomi 2 and Atomiswave emulator
GNU General Public License v2.0
1.5k stars 176 forks source link

[Libretro] Using CHDs instead of CUE/BIN/GDI/CDI has a noticeable impact #1755

Open vanfanel opened 6 hours ago

vanfanel commented 6 hours ago

Please Note: This form is the minimum required information for submitting bugs.
Removing this form may lead to your issue being closed until it is completed.

Platform / OS / Hardware: GNU/Linux

Flycast version: latest GIT code

Hardware: Intel 12th Gen + Iris XE graphics

Description of the Issue

Using compressed images (CHD) has a performance impact on this core, causing audio dropouts if ALSA sound backend is used or cracking if ALSATHREAD is used instead. This is the only core where I see this (PPSSPP or LRPS2 don't show this small problem), hence my report/question.

So my question is: May it be that the core doesn't use threaded disk access like the rest of the CD based cores?

flyinghead commented 5 hours ago

I doubt using CHDs would cause any performance issue (and thus audio cracking). Any decent machine is way faster at reading and decompressing a CHD than original hardware can read a GD-ROM. I don't think anybody has ever reported this issue with CHDs, particularly on a modern desktop machine. Are you using an insanely small audio buffer size/latency setting?

CHDs are an issue for arcade games because the entire disk is read, decompressed and decrypted into memory before the game starts. I changed this so that the CHD is loaded by chunks on demand (dev branch). But this is only arcade games.

vanfanel commented 3 hours ago

@flyinghead I'm using 32ms audio latency, which isn't insanely small at all and doesn't seem to cause any problems at all with other 3D cores. Of course increasing the audio buffer size will "mask" this issue, but it will also increase the audio latency when compared to the real machine, which I know very well (as a player! :D).

About other latency related settings, well, runahead is of course disabled, and aside of that I haven't set anything special.

Note that most users use PipeWire or (God forbids) PulseAudio which won't obey a 32ms audio buffer setting even if they set it.

flyinghead commented 2 hours ago

Which game(s) do you have issues with? Can you also indicate when does the audio dropout/cracking happen?

vanfanel commented 1 hour ago

Which game(s) do you have issues with? Can you also indicate when does the audio dropout/cracking happen?

Yes. SoulCalibur: Just as you start the game, when the "Nnnaaaamcowwww" voice plays along with a strong winding sound, you can hear the crackling if you use ALSATHREAD or the dropout if you use ALSA.

It only happens with CHD, not with CUE+BINs.

Also, it can be "worked around" when using CHDs by activating "GD-ROM Fast Loading", in case it rings a bell.

flyinghead commented 31 minutes ago

Are you using HLE BIOS?

The only way I was able to produce some cracking was to use HLE BIOS. Because it reads all sectors requested by the game in one shot. In Soulcalibur I see read times of ~50 ms for 500 to 700 sectors at once, which is a lot.

When using real BIOS, max 32 sectors are read at once with read times ~3 ms each, which is fine.