Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNES Performance Issue: Slow Emulation #1916

Open
RetroPl4yer opened this issue Nov 19, 2024 · 15 comments
Open

SNES Performance Issue: Slow Emulation #1916

RetroPl4yer opened this issue Nov 19, 2024 · 15 comments

Comments

@RetroPl4yer
Copy link

Hi , I want to thank you for your amazing work on this project, it's truly impressive! I'm reaching out to share some feedback and report an issue that might already be on your radar.

I'm experiencing performance issues with SNES emulation. Here's what I noticed:

  • On an older setup, SNES games run slowly.
  • On a newer setup, I tested Super Mario World without frameskip, and it runs at around 40 FPS.
  • Enabling software filters makes the performance even worse.

I checked SNES9X code and noticed it might be buffering tiles for reuse instead of recalculating them. Could this be why the current version is using so much CPU?

Thanks for looking into this!

@barbudreadmon
Copy link
Collaborator

Could you be more specific about the 2 setups ? Afaik it's supposed to run full speed on a 10+ years old desktop computer.

@dinkc64
Copy link
Collaborator

dinkc64 commented Nov 19, 2024

The snes emulator is super accurate, but it runs fine on my p4 3ghz and i7, both are ancient garbage computers (no kidding, the I7 was collected from the garbage......)

The only advice I can give:

  1. use at least the DirectX 9 blitters, they respond the quickest to drawing - giving more time to the emulator
  2. disable all shaders, video effects, etc
  3. on night before garbage collection, keep a look out for pc's near the curb :)
    (# 3 is not a joke)

best regards,

  • dink

@Neildark
Copy link

Neildark commented Nov 19, 2024

I’ve tried them out of curiosity, and Super Mario World (USA), (EUR), and (JAP) work perfectly. However, for some reason, the hacks Super Mario World SA-1 Pack (Hack, v1.40) and Super Mario World - 30th Anniversary Edition (Hack) do show slowdowns. I have a powerful computer, so I don’t think that’s the issue.
In any case, as I always say in all my comments, an exceptional job, it doesn't matter

@dinkc64
Copy link
Collaborator

dinkc64 commented Nov 19, 2024

Hi Neildark,
The SA1 hack has an extra 10.74mhz processor ontop of the usual snes cpu, I can emulate it here @ fullspeed (or 150-210fps for fast forward) with my garbage pc, curiously: where do you see the slowdowns at?
With SA-1 games, I recommend turning Runahead off

edit: try turning Run Ahead off? If that don't help, please post your fbneo.ini file and I'll try to see what's wrong.

best regards,

  • dink

@barbudreadmon
Copy link
Collaborator

Isn't SA-1 supposed to be 10.74mhz ?

@dinkc64
Copy link
Collaborator

dinkc64 commented Nov 19, 2024

@barbudreadmon, Oops, you're right - I was thinking about CX4 for some reason

@RetroPl4yer
Copy link
Author

RetroPl4yer commented Nov 20, 2024

I wanted to add more details about the issue. On my side, I'm starting the emulation using the command line (to skip Rom scaning 😭):
fbneo64.exe supermarioworld

I've noticed that running the game this way seems to result in more frame drops compared to a normal run through opening the EXE. Here are my settings:

  • Auto Frameskip: OFF
  • Filter: AdvanceMAME Scale3x (SoftFX)

With this performance drop sometimes to 40 FPS

For comparison, other systems like NeoGeo, Midway, or CPS3 perform much better. This suggests that SNES emulation has performance issues, especially when using more demanding filters. Considering how FBNeo RetroArch Core might run on devices like Android through RetroArch, this could become a bigger problem.

I think adopting SNES9X tile caching solution (https://github.com/snes9xgit/snes9x/blob/master/tile.cpp), could significantly improve performance by avoiding the need to decode tiles repeatedly.

Regards,

@dinkc64
Copy link
Collaborator

dinkc64 commented Nov 20, 2024

Hi,
First, let's address the rom scanning issue - there's no need for this irritation:
uncheck: Misc -> Options -> Scan roms at startup (if needed)

The snes emulator doesn't have performance issues, it was designed to be highly accurate, and by that means, it's going to be a bit heavy on cpu. Hell, when I first started working on it, it used 99% of an i7/2600-era core on Demon's Crest, now it's down to half that :)

For the softfx filter, use Double Pixels (3d hardware), any softfx is going to steal cpu from the emulator
and make sure Video -> Runahead is off

Also, to help me better understand what I'm dealing with: please go to Help -> System Information, and paste everything up to and including the "Input Settings" block.

best regards,

  • dink

@Neildark
Copy link

Sorry for the delay. Yes, I just tried both games by deactivating runhead and now they are perfect. Say that I use 4xbr, maximum resolution, maximum graphic options, and now there is no type of slowdown either on the big screen or on Windows. Congratulations and sorry for the inconvenience.

@petran79
Copy link

The most demanding softfx filter is the crt 4x4 1080. Even with run ahead off, there is delay and distorted sound. While 720 mode runs fine even with runahead. Same for the other softfx filters.

@barbudreadmon
Copy link
Collaborator

Considering how FBNeo RetroArch Core might run on devices like Android through RetroArch, this could become a bigger problem.

That's not a problem and never will, FBNeo is written first and foremost for desktop computers. It'd be extremely delusional to expect every game we support running full speed on every devices that can install retroarch, which include ultra-low-end devices.

There are plenty of other snes emulators for users that can't run highly accurate snes emulation, and there are also snes emulators with higher requirements than ours.

As for implementing caching mecanisms, why not if there are no drawbacks ? But you should first start by answering the questions you have been asked.

@RetroPl4yer
Copy link
Author

It runs correctly without runahead and filters, especially with the misc option you mentioned. However, SNES seems to have the lowest performance among the drives in FBNeo, currently running at ~250 FPS max when I run the emulator at maximum speed to see the FPS limit, compared to NeoGeo (~1200 FPS max, if I remember correctly, similar to SNES9X). I think SNES has by far the lowest FPS delta when compared to NeoGeo as a reference, especially considering SNES is supposed to be a lower-spec machine than NeoGeo. Implementing optimizations like tile caching and monitoring performance across drives could help bring SNES closer to the performance of other drives.

NeoGeo and other drives (besides SNES and MIDWAY) in FBNeo are so optimized that they run smoothly on a Raspberry Pi (and without a doubt could run on my smart toaster 😂). Establishing a minimum acceptable delta (NeoGeo as FPS max reference) through benchmarking ensures that all drives maintain consistent performance, regardless of the hardware, preserving FBNeo's historical reputation for delivering minimalist high-quality emulation 🚀.

Here my infos report:

`FinalBurn Neo v1.0.0.03 system information (Mon Nov 25 11:04:49 2024).


System information:

OS: Microsoft Windows 10 Professional (build 19045)
CPU: Intel(R) Core(TM) i3-2100 CPU @ 3.10GHz

Physical RAM: 16351,13 MB (15,97 GB) total, 8708,51 MB (8,50 GB) avail
PageFile RAM: 32735,13 MB (31,97 GB) total, 23739,74 MB (23,18 GB) avail
FinalBurn Neo: 135,78 MB in use (140,58 MB peak, 227,95 MB virtual)

Installed displays and display adapters:
@oem147.inf,%benq%;BenQ @oem147.inf,%xl2411_digital%;ZOWIE XL LCD (Digital) on NVIDIA GeForce GTX 750 Ti (primary)
Display size ~53x30cm, Gamma 2,20
Preferred mode 1920x1080, 60,000 Hz (531x298mm, 148,500 MHz)
Max. bandwidth 330 MHz, H sync 30-160 KHz, V sync 56-144 Hz


FinalBurn Neo information:

Built on Nov 11 2024, 02:11:33, using GCC 14.2.0.
Optimised for X64 CPUs.
Using Unicode for all text.
Debug functionality absent.

MMX optimisations disabled.
Musashi emulation core enabled for MC680x0 family emulation.

Not emulating any game.

Video settings:
Selected module: DirectDraw7 Software Effects video output
Interface settings: Running in windowed mode, 1194x896, 0bpp
Source image 304x224, 32bpp
Module settings: Using Blt() to transfer the image
Prescaling using AdvanceMAME Scale2x (2x zoom)
Using video memory for effect buffers

Audio settings:
Selected module: DirectSound3 audio output
Interface settings: Playback at 44100Hz, 100% volume
Module settings: Audio is delayed by approx. 83ms

Input settings:
Selected module: DirectInput8 input
Interface settings: keyboard 0 System keyboard: Clavier
mouse 0 System mouse: Souris
joystick 0 Controller (Razer Raion Fightpad for PC)

Profiling settings:
Interface settings: Profiling module not initialised


Detailed process information about fbneo64.exe:

fbneo64.exe (base address 0x00007FF637690000, size 219148 KB)

Modules loaded by fbneo64.exe:
ntdll.dll (base address 0x00007FFFC3010000, size 2016 KB)
aswhook.dll (base address 0x00007FFF83CC0000, size 104 KB)
KERNEL32.DLL (base address 0x00007FFFC2F00000, size 776 KB)
KERNELBASE.dll (base address 0x00007FFFC06B0000, size 3064 KB)
ADVAPI32.dll (base address 0x00007FFFC2110000, size 708 KB)
msvcrt.dll (base address 0x00007FFFC29F0000, size 632 KB)
sechost.dll (base address 0x00007FFFC22B0000, size 636 KB)
RPCRT4.dll (base address 0x00007FFFC1060000, size 1164 KB)
bcrypt.dll (base address 0x00007FFFC0B50000, size 156 KB)
comdlg32.dll (base address 0x00007FFFC21D0000, size 872 KB)
combase.dll (base address 0x00007FFFC2630000, size 3404 KB)
ucrtbase.dll (base address 0x00007FFFC0F30000, size 1024 KB)
shcore.dll (base address 0x00007FFFC1190000, size 692 KB)
COMCTL32.dll (base address 0x00007FFFAB810000, size 2664 KB)
USER32.dll (base address 0x00007FFFC1430000, size 1652 KB)
GDI32.dll (base address 0x00007FFFC1030000, size 172 KB)
win32u.dll (base address 0x00007FFFC09B0000, size 136 KB)
gdi32full.dll (base address 0x00007FFFC0D80000, size 1116 KB)
SHLWAPI.dll (base address 0x00007FFFC1370000, size 340 KB)
msvcp_win.dll (base address 0x00007FFFC0CE0000, size 628 KB)
SHELL32.dll (base address 0x00007FFFC1800000, size 7604 KB)
ole32.dll (base address 0x00007FFFC1240000, size 1196 KB)
SETUPAPI.dll (base address 0x00007FFFC2A90000, size 4536 KB)
cfgmgr32.dll (base address 0x00007FFFC09E0000, size 312 KB)
WINMM.dll (base address 0x00007FFFB7710000, size 156 KB)
WININET.dll (base address 0x00007FFFA0680000, size 4960 KB)
MSVFW32.dll (base address 0x00007FFF75E60000, size 172 KB)
AVIFIL32.dll (base address 0x00007FFF75E30000, size 132 KB)
MSACM32.dll (base address 0x00007FFF82890000, size 120 KB)
winmmbase.dll (base address 0x00007FFFB0F80000, size 152 KB)
IMM32.DLL (base address 0x00007FFFC1F70000, size 188 KB)
CRYPTBASE.DLL (base address 0x00007FFFC00D0000, size 48 KB)
bcryptPrimitives.dll (base address 0x00007FFFC0EA0000, size 520 KB)
dsound.dll (base address 0x00007FFF3E6F0000, size 624 KB)
powrprof.dll (base address 0x00007FFFC0460000, size 300 KB)
UMPDC.dll (base address 0x00007FFFC0240000, size 72 KB)
dinput8.dll (base address 0x00007FFF75DE0000, size 276 KB)
ddraw.dll (base address 0x00007FFFA7DD0000, size 1004 KB)
kernel.appcore.dll (base address 0x00007FFFBEEF0000, size 72 KB)
dxgi.dll (base address 0x00007FFFBEF40000, size 984 KB)
DCIMAN32.dll (base address 0x00007FFFBC840000, size 36 KB)
d3d9.dll (base address 0x00007FFF502A0000, size 1860 KB)
windows.storage.dll (base address 0x00007FFFBE730000, size 7824 KB)
dwmapi.dll (base address 0x00007FFFBE050000, size 188 KB)
Wldp.dll (base address 0x00007FFFC0060000, size 184 KB)
OLEAUT32.dll (base address 0x00007FFFC16A0000, size 820 KB)
D3DX9_43.dll (base address 0x00007FFF3E480000, size 2444 KB)
inputhost.dll (base address 0x00007FFFAA910000, size 1352 KB)
wintypes.dll (base address 0x00007FFFBCEC0000, size 1372 KB)
PROPSYS.dll (base address 0x00007FFFBD6E0000, size 984 KB)
CoreUIComponents.dll (base address 0x00007FFFBC920000, size 3436 KB)
CoreMessaging.dll (base address 0x00007FFFBCC80000, size 968 KB)
WS2_32.dll (base address 0x00007FFFC20A0000, size 428 KB)
ntmarta.dll (base address 0x00007FFFBF8E0000, size 204 KB)
uxtheme.dll (base address 0x00007FFFBDF00000, size 632 KB)
FencesMenu64.dll (base address 0x00007FFF7A4E0000, size 1924 KB)
gdiplus.dll (base address 0x00007FFFB0810000, size 1684 KB)
WTSAPI32.dll (base address 0x00007FFFBC160000, size 80 KB)
USERENV.dll (base address 0x00007FFFC05A0000, size 184 KB)
MSCTF.dll (base address 0x00007FFFC2500000, size 1108 KB)
TextShaping.dll (base address 0x00007FFFA80F0000, size 696 KB)
HID.DLL (base address 0x00007FFFBEEE0000, size 52 KB)
DEVOBJ.dll (base address 0x00007FFFC0260000, size 204 KB)
WINTRUST.dll (base address 0x00007FFFC0AE0000, size 420 KB)
CRYPT32.dll (base address 0x00007FFFC0B80000, size 1392 KB)
MSASN1.dll (base address 0x00007FFFC0200000, size 72 KB)
clbcatq.dll (base address 0x00007FFFC15F0000, size 676 KB)
MMDevApi.dll (base address 0x00007FFFB7070000, size 532 KB)
AUDIOSES.DLL (base address 0x00007FFFA6510000, size 1540 KB)
resourcepolicyclient.dll (base address 0x00007FFFBE030000, size 80 KB)
VERSION.dll (base address 0x00007FFFB8A90000, size 40 KB)
cryptnet.dll (base address 0x00007FFFB8A50000, size 196 KB)
drvstore.dll (base address 0x00007FFFB8900000, size 1308 KB)
imagehlp.dll (base address 0x00007FFFC15D0000, size 116 KB)
CRYPTSP.dll (base address 0x00007FFFBFFC0000, size 96 KB)
rsaenh.dll (base address 0x00007FFFBF690000, size 208 KB)
nvspcap64.dll (base address 0x00007FFF640C0000, size 2880 KB)
profapi.dll (base address 0x00007FFFC05E0000, size 144 KB)
gpapi.dll (base address 0x00007FFFBEF10000, size 140 KB)
nvppex.dll (base address 0x00007FFF799C0000, size 1364 KB)
dxcore.dll (base address 0x00007FFFBB3B0000, size 236 KB)
TextInputFramework.dll (base address 0x00007FFFAAA70000, size 996 KB)
nvldumdx.dll (base address 0x00007FFFB7FE0000, size 784 KB)
nvgpucomp64.dll (base address 0x00007FFFB1D10000, size 46144 KB)
nvd3dumx.dll (base address 0x00007FFF46C30000, size 30256 KB)
Windows.UI.dll (base address 0x00007FFFAAB70000, size 1276 KB)
WindowManagementAPI.dll (base address 0x00007FFFBA0B0000, size 644 KB)
twinapi.appcore.dll (base address 0x00007FFFB9EA0000, size 2060 KB)
avrt.dll (base address 0x00007FFFBA470000, size 40 KB)

----------------------------------------------------------------------`

@barbudreadmon
Copy link
Collaborator

especially considering SNES is supposed to be a lower-spec machine than NeoGeo

That's irrelevant as far as emulation is concerned, you should try playing the arcade version of pong, or hundreds of pre-16bits systems tbh.

On a sidenote, i tested runahead in bsnes (which is about 40% slower than us) and noticed it doesn't affect performance much, i'm wondering what's the trick behind it.

@dinkc64
Copy link
Collaborator

dinkc64 commented Nov 25, 2024

I can at least recommend something here:
Try one of the DirectX9 blitters. The SoftFX/Basic/D3D7 blitters use 3-4x more time, time which is taken away from each emulated frame, just to draw stuff to the screen.

Regarding Audio: try XAudio2, it also gives better performance

Game: Super Mario World
PC: found in the garbage i7, 2600 (not K model), onboard video....
DirectX9 with XAudio2: 350-400fps
DirectX9 with DirectSound: 290fps
SoftFX blitter with XAudio2: 200fps
SoftFX blitter with DirectSound: 153fps avg

best regards,

  • dink

@petran79
Copy link

especially considering SNES is supposed to be a lower-spec machine than NeoGeo

That's irrelevant as far as emulation is concerned, you should try playing the arcade version of pong, or hundreds of pre-16bits systems tbh.

On a sidenote, i tested runahead in bsnes (which is about 40% slower than us) and noticed it doesn't affect performance much, i'm wondering what's the trick behind it.

I am not sure whether they use the same api, but there is a big difference between Windows and Linux regarding Ares run-ahead performance

ares-emulator/ares#1677

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants