Snes9x gives sub 60fps under opengl/software/Xvideo in Linux

If you're having problems with Snes9x, or think you've found a bug, this is the place to be.
Xenphor
Snes9x White Belt
Posts: 15
Joined: Fri Feb 11, 2011 5:48 am

Snes9x gives sub 60fps under opengl/software/Xvideo in Linux

Post by Xenphor »

I'm using 1.52 version 81. For some reason, I can not achieve a constant 60fps in either opengl or software. Using "none" as a filter helps somewhat; although, it does dip to 59 every now and then with an occasional sound crackle. If I do anything like simple2x,3x,ntsc then I get around 55fps with lots of sound crackling.

I tried changing my audio to Alsa, Portaudio, Pulseaudio (isn't that a sound server?) and SDL and all had the same problems. I also tried adjusting both input rate and buffer size but still got frame rate issues and crackling.

I would say XVideo gave slightly better performance than Opengl and software but I still got the occasional framedrop and sound crackle.

I have the latest xorg drivers from intel (using an 915gm integrated graphics) and my pc is 1.6ghz Centrino with 1 gig of ram. I'm on Ubuntu 10.10.

I'm able to run this emulator fine in windows (directdraw) with no framedrops or crackling so I don't know why I can't in Linux, especially with OpenGL.
User avatar
BearOso
Official GTK/Linux Porter/Dev
Posts: 460
Joined: Tue Oct 02, 2007 12:50 am

Post by BearOso »

Xenphor wrote:I'm using 1.52 version 81. For some reason, I can not achieve a constant 60fps in either opengl or software. Using "none" as a filter helps somewhat; although, it does dip to 59 every now and then with an occasional sound crackle. If I do anything like simple2x,3x,ntsc then I get around 55fps with lots of sound crackling.
The "dip to 59 every now and then" is normal. Few computer displays actually run at exactly 60hz, so you'll experience this if you're running with vsync enabled. You have to lower the input rate slightly to compensate for it to eliminate the crackle, but too low may also drop the frame rate slightly.

Using any of the filters quadruples the upload to the video card, so this can be a big performance hit on weaker drivers and/or graphics chips. The Intel X11 drivers for chipsets before 945G are notoriously slow, and aside from bug fixes and compatibility, it seems they are no longer being updated. :-(
I tried changing my audio to Alsa, Portaudio, Pulseaudio (isn't that a sound server?) and SDL and all had the same problems. I also tried adjusting both input rate and buffer size but still got frame rate issues and crackling.
As long as the buffer size is over around 32ms, it won't make much difference. Lowering the input rate will help more if you ensure "Synchronize with Sound" is enabled. If you are still getting crackling, you might need to investigate to see if some background process is hitting the CPU or I/O.

Since you're running Ubuntu, PulseAudio is running unless you took steps to kill it. It's likely intercepting the audio, resampling it, and eating a lot of CPU time. If you can, disable it; otherwise try to match the server's output frequency (usually 44100hz) to reduce its CPU usage.
Xenphor
Snes9x White Belt
Posts: 15
Joined: Fri Feb 11, 2011 5:48 am

Post by Xenphor »

Well I tried removing Pulseaudio (in Fedora 14 now) with this command:

su -c "yum remove alsa-plugins-pulseaudio" (removes the plugin that calls pulseaudio)

This seems to have had an effect because now at least I can use software or opengl at larger resolutions and maintain a fairly high level of performance, although still not anywhere as solid as Windows.

However, having supposedly removed pulseaudio, I have no idea what exactly I'm using to output sound; is it alsa? I can select either ALSA, SDL, Portaudio, or Pulseaudio and still receive sound so I don't know if I have actually changed anything or not; although I'm positive performance has improved greatly by doing the above command.
Xenphor
Snes9x White Belt
Posts: 15
Joined: Fri Feb 11, 2011 5:48 am

Post by Xenphor »

Well I've also tried setting the sound frequency in Snes9x to 44100khz while using Pulseaudio and that also seems to have helped.

One of the main problems I'm noticing now is that Snes9x's screen is having some syncing issues with my monitor. Tearing isn't really a problem, but a sort of violent stuttering is constantly happening, which has a very noticeable affect on horizontal scrolling games. I experienced this issue in Windows as well but I was able to use Triple Buffering and V-Sync in conjunction with Fullscreen mode at 60hz to minimize stuttering. I still got an occasional stutter but nothing as bad as on Linux.

I've tried using all the video modes and also experimented with Sync to Vblank in OpenGL in fullscreen but nothing seems to alleviate the violent stuttering.

I've also noticed a very violent stuttering effect (almost as if the screen was constantly slowing and speeding up) using visualboyadvance so I don't know if it's some problem in Linux or what. Even trying different distributions doesn't seem to resolve the problem.
SparroHawc
Official Android Porter
Posts: 303
Joined: Mon Feb 07, 2011 9:20 pm
Location: All up in your business

Post by SparroHawc »

I think a big reason for the difference between the two OSes is because the graphical environment in Linux is somewhat less efficient (and significantly less supported) than the same in Windows. As much as it has been a focus of development, Microsoft's spent a -lot- more man-hours on it, and graphics card manufacturers especially don't seem to want to spend much time making the drivers efficient.

I know this doesn't solve the issue, but I thought it might help a little to know the potential reasons.

There are some additional steps you might try, though.

You mentioned that you can still get audio output by going through PulseAudio - you could try tracking down why it still works and see if you can wipe out the last traces of it. Since your audio isn't crackling any more, it might not be the first thing you'd want to try though.

Try turning off stretching and filtering. See if you get consistent framerates that way. Switch between rendering methods with these turned off as well. If you can't get rid of the stuttering that way, open an xterm and use 'top' to see if anything's occasionally stealing all the CPU time.

I'm worried the underlying problem is the Intel graphics chip. They're not especially known for putting out good video hardware.
User avatar
Camo_Yoshi
Snes9x Purple belt
Posts: 922
Joined: Thu Nov 08, 2007 7:59 pm

Post by Camo_Yoshi »

Well, for Linux at least, yeah. On windows the Intel Graphics Adapters can pack quite a punch; it's pretty impressive.
Snes9x FAQs | Forum Rules
What operating system are you using? 32 or 64bit? Version of Snes9x? Is the text at the bottom of the window white when you load the game?
These suggestions are usually the solution to your issue!
Xenphor
Snes9x White Belt
Posts: 15
Joined: Fri Feb 11, 2011 5:48 am

Post by Xenphor »

Ya Intel integrated graphics is pretty bad regardless of OS but I was under the impression that Intel's open source efforts were actually somewhat legitimate because of their stake in projects such as Meego, etc. At least they seem more dedicated than Ati or Nvidia.

I should also mention that I have tried out other programs such as Dosbox, mame, quake 3, Unreal Tournament, and have gotten decent performance in those. Dosbox and mame both seem to run about on par with Windows (no heavy stuttering or anything).

I guess if Pulseaudio is really the culprit then I'm not sure exactly how to proceed because it seems to be embedded quite heavily in Fedora and Ubuntu.

I did try Snes9x in Opensuse which, as far as I could tell, did not install Pulseaudio at all and performance seemed somewhat better than Fedora or Ubuntu. Of course it is really hard to tell what exactly is the cause of any of the performance gains or increases or if it's just all in my head.
Xenphor
Snes9x White Belt
Posts: 15
Joined: Fri Feb 11, 2011 5:48 am

Post by Xenphor »

Well I think I've succeeded in removing Pulseaudio. I prevented it from starting by removing it from Startup Applications and I also created a file in ~/.pulse to prevent it from autospawning. Now when I select Pulseaudio in Snes9x I don't receive any sound.

Since I removed Pulseaudio, I'm assuming that I now get sound through ALSA? I selected it in Snes9x and received sound although I still get stuttering. It's about the same as it was with Pulse - perhaps a little better.

Now I guess my question is, should I try getting SDL or Portaudio to work? I tried using SDL and got sound with ALSA but I'm assuming that is not the ideal way to use SDL. Can I install SDL sound alongside ALSA? How about Portaudio? Are either of these good alternatives?
SparroHawc
Official Android Porter
Posts: 303
Joined: Mon Feb 07, 2011 9:20 pm
Location: All up in your business

Post by SparroHawc »

Xenphor wrote:Well I think I've succeeded in removing Pulseaudio. I prevented it from starting by removing it from Startup Applications and I also created a file in ~/.pulse to prevent it from autospawning. Now when I select Pulseaudio in Snes9x I don't receive any sound.

Since I removed Pulseaudio, I'm assuming that I now get sound through ALSA? I selected it in Snes9x and received sound although I still get stuttering. It's about the same as it was with Pulse - perhaps a little better.
Congrats! ALSA should work alright - at least, it's been standard for a while. I'd try fiddling with the input rate at this point to see if you can clear out the remaining crackling, etc.

Is there an option for changing the rendering method being used in the video settings? If there's some extra hardware acceleration we can make use of, it's possible that would clear up the rest of the stuttering troubles. Failing that, I'm about as far as I can go troubleshooting wise, not having a Linux machine on hand to test it on myself. :P
Xenphor
Snes9x White Belt
Posts: 15
Joined: Fri Feb 11, 2011 5:48 am

Post by Xenphor »

SparroHawc wrote:
Xenphor wrote:Well I think I've succeeded in removing Pulseaudio. I prevented it from starting by removing it from Startup Applications and I also created a file in ~/.pulse to prevent it from autospawning. Now when I select Pulseaudio in Snes9x I don't receive any sound.

Since I removed Pulseaudio, I'm assuming that I now get sound through ALSA? I selected it in Snes9x and received sound although I still get stuttering. It's about the same as it was with Pulse - perhaps a little better.
Congrats! ALSA should work alright - at least, it's been standard for a while. I'd try fiddling with the input rate at this point to see if you can clear out the remaining crackling, etc.

Is there an option for changing the rendering method being used in the video settings? If there's some extra hardware acceleration we can make use of, it's possible that would clear up the rest of the stuttering troubles. Failing that, I'm about as far as I can go troubleshooting wise, not having a Linux machine on hand to test it on myself. :P
Well I have 3 different options for video: Software, OpenGL, and XvideoHardwareBlitter. Software seems to give consistently the worst display, causing lots of stutter and occasional sound hiccups.

OpenGL without Sync to Vblank and Sync'd audio gives fairly consistent performance but has stutter throughout. Now what I'm not sure about is how things change when I enable either Vblank, Sync'd audio, or both. I think I can achieve less stutter but enabling both Vblank and Sync audio but then the sound starts to skip a lot. I've tried adjusting the Input Rate slider both ways and nothing seems to totally eliminate it.

Xvideo gives a fairly good output with pretty minimal stutter - the only problem is that it places a nasty overlay on the image that makes everything pretty blurry. Overall I'd say that Xvideo without Sync'd audio gives the best overall performance but I would prefer to use OpenGL.
SparroHawc
Official Android Porter
Posts: 303
Joined: Mon Feb 07, 2011 9:20 pm
Location: All up in your business

Post by SparroHawc »

I'm afraid the only advice I can give past that is to upgrade your hardware. SNES9x isn't the most efficient of programs out there (though it is pretty fast at doing the actual hardware emulation), and the graphical system in Linux tends to be even worse. :/ Sorry I haven't been able to help much.
the_randomizer
Snes9x Orange Belt
Posts: 222
Joined: Sat Oct 17, 2009 4:18 am

Post by the_randomizer »

SparroHawc wrote:I'm afraid the only advice I can give past that is to upgrade your hardware. SNES9x isn't the most efficient of programs out there (though it is pretty fast at doing the actual hardware emulation), and the graphical system in Linux tends to be even worse. :/ Sorry I haven't been able to help much.
So, in other words, if I decided to use something like the cr48 (Chrome Notebook) with Ubuntu 10.10, it wouldn't have a snowball's chance in hell of ever running Snes9x, with vsync/async at full speed?
Lisa: "I hope you all know you're sponsoring a murderous pirate!"
Sponsor: "A pirate!!? Well, that's hardly the image we need for Long John Silvers!"
SparroHawc
Official Android Porter
Posts: 303
Joined: Mon Feb 07, 2011 9:20 pm
Location: All up in your business

Post by SparroHawc »

the_randomizer wrote:
SparroHawc wrote:I'm afraid the only advice I can give past that is to upgrade your hardware. SNES9x isn't the most efficient of programs out there (though it is pretty fast at doing the actual hardware emulation), and the graphical system in Linux tends to be even worse. :/ Sorry I haven't been able to help much.
So, in other words, if I decided to use something like the cr48 (Chrome Notebook) with Ubuntu 10.10, it wouldn't have a snowball's chance in hell of ever running Snes9x, with vsync/async at full speed?
My guess would be no. My wife does have a netbook with similar specs, though - I might be able to test on that if I can convince her to let me run Ubuntu on it for a bit.
the_randomizer
Snes9x Orange Belt
Posts: 222
Joined: Sat Oct 17, 2009 4:18 am

Post by the_randomizer »

While Vsync does work (i.e. the games run 60/60 fps 100% of the time), the audio will skip every 5-7 seconds, regardless of the buffer size/frequency. OpenGL is the only mode that offers vsync.

Edit 4:22PM - I should mention that Kega Fusion runs full speed with vsync on which is something I find to be very odd. I know it's a completely different system (not to mention emulating a faster CPU), but the fact that full speed can be achieved on Fusion, with overdrive, Super HQ and vsync is something I find baffling.
Lisa: "I hope you all know you're sponsoring a murderous pirate!"
Sponsor: "A pirate!!? Well, that's hardly the image we need for Long John Silvers!"
the_randomizer
Snes9x Orange Belt
Posts: 222
Joined: Sat Oct 17, 2009 4:18 am

Post by the_randomizer »

Still no reply, huh? :?
Lisa: "I hope you all know you're sponsoring a murderous pirate!"
Sponsor: "A pirate!!? Well, that's hardly the image we need for Long John Silvers!"
the_randomizer
Snes9x Orange Belt
Posts: 222
Joined: Sat Oct 17, 2009 4:18 am

Post by the_randomizer »

This is getting ridiculous ...Seriously, are people really that oblivious to my posts?
Lisa: "I hope you all know you're sponsoring a murderous pirate!"
Sponsor: "A pirate!!? Well, that's hardly the image we need for Long John Silvers!"
User avatar
BearOso
Official GTK/Linux Porter/Dev
Posts: 460
Joined: Tue Oct 02, 2007 12:50 am

Post by BearOso »

It's not that people are oblivious, it's that they simply aren't here. I know I probably don't visit often enough.

Unfortunately, all the applicable advice has probably been given. The fact is that various quirks in hardware setups, operating systems, and sound systems cause differences that can't be ironed out without direct access to a similar configuration. The sound frequency, buffer size, input rate, and driver options are there to help alleviate these problems, but there is always going to be cases where they don't help.

If you've exhausted all available options inside the program, it's probably time to look outside of it.
the_randomizer
Snes9x Orange Belt
Posts: 222
Joined: Sat Oct 17, 2009 4:18 am

Post by the_randomizer »

How? What should I do?
Lisa: "I hope you all know you're sponsoring a murderous pirate!"
Sponsor: "A pirate!!? Well, that's hardly the image we need for Long John Silvers!"
User avatar
BearOso
Official GTK/Linux Porter/Dev
Posts: 460
Joined: Tue Oct 02, 2007 12:50 am

Post by BearOso »

Ok, we'll try a few things.

First run in a terminal:

Code: Select all

ps -A | grep pulse
and ensure that nothing shows up in order to make sure there are no pulseaudio processes running.

Now, run "glxgears" in the terminal. Let the computer sit while it runs for a couple rounds to get a measure of the refresh rate. If it runs without vsync, you need to get "driconf" from your package manager, run it, and turn vsync on. This should give you an "actual" refresh rate for your display. For instance, my display runs at 1920x1200 and CVT reduced blanking timings for this mode define only a 59.95hz vertical refresh rate. Post the result here. From this we can calculate an ideal input rate. FYI, the formula is "refresh_rate * 32040 / 60.0988138974405".

Run "glxinfo" in a terminal and copy/paste the output here. Just the extensions are necessary. This should give me an idea what your display driver supports.
the_randomizer
Snes9x Orange Belt
Posts: 222
Joined: Sat Oct 17, 2009 4:18 am

Post by the_randomizer »

BearOso wrote:Ok, we'll try a few things.

First run in a terminal:

Code: Select all

ps -A | grep pulse
and ensure that nothing shows up in order to make sure there are no pulseaudio processes running.

Now, run "glxgears" in the terminal. Let the computer sit while it runs for a couple rounds to get a measure of the refresh rate. If it runs without vsync, you need to get "driconf" from your package manager, run it, and turn vsync on. This should give you an "actual" refresh rate for your display. For instance, my display runs at 1920x1200 and CVT reduced blanking timings for this mode define only a 59.95hz vertical refresh rate. Post the result here. From this we can calculate an ideal input rate. FYI, the formula is "refresh_rate * 32040 / 60.0988138974405".

Run "glxinfo" in a terminal and copy/paste the output here. Just the extensions are necessary. This should give me an idea what your display driver supports.
Wow. I can see that actually helping me getting this to run! Thanks! I'll give it a whirl! Oh, and when you mentioned "you need to get "driconf" from your package manager" you mean getting it from here ( https://launchpad.net/ubuntu/maverick/armel/driconf ), right? If for some reason Pulse Audio is enabled, then I might have to force it to uninstall...I think.


EDIT 10:03 PM - glxgear results -

Crap. Pulse audio is installed on the system; gonna have to find a way to delete it.

Refresh rate numbers -

342 Frames in 5.0 seconds = 68.392 FPS
300 Frames in 5.0 seconds = 59.556 FPS
300 Frames in 5.0 seconds = 59.554 FPS
300 Frames in 5.0 seconds = 59.556 FPS
300 Frames in 5.0 seconds = 59.556 FPS
300 Frames in 5.0 seconds = 59.555 FPS
300 Frames in 5.0 seconds = 59.557 FPS

I stopped after a few rounds.
The 3D Accelerator program was installed but it will not open, "XDrilInfo returned with non-zero exit code" WTF? Unless there's another way to force-enable vsync.

Edit 10:56: Looks like I'm SOL; installed/re-installed it multiple times but to no avail. I go to Snes9x to find that OpenGL isn't in the menu anymore.
Looks like I can't install this, or can I? Crap.
Lisa: "I hope you all know you're sponsoring a murderous pirate!"
Sponsor: "A pirate!!? Well, that's hardly the image we need for Long John Silvers!"
Post Reply