TASEmulators / fceux

FCEUX, a NES Emulator
http://fceux.com
GNU General Public License v2.0
1.23k stars 253 forks source link

Vsync ON=Audio with crackle | Vsync OFF=Tearing #428

Open IPeluchito opened 2 years ago

IPeluchito commented 2 years ago

Vsync=ON: (win64 no Qt/SDL)

https://user-images.githubusercontent.com/64821708/145899581-74dc9e4b-f795-4430-9bc3-a1adf6b457bc.mp4

When Vsync is disabled the audio problem is solved but the image is displayed with tearing... :S Latest Win64 dev build (Not Qt/SDL) Windows 11 Nvidia GTX 1660Ti Video & Sound by hdmi...

In the case of the Qt/SDL version there is no audio problem, but the image loses synchronization at times and is a bit annoying...

Qt/SDL Version:

https://user-images.githubusercontent.com/64821708/145900370-02cd3bd6-f0fb-4504-a828-aa13f5773793.mp4

mjbudd77 commented 2 years ago

Which port are you running? Win32 or Qt/SDL?

mjbudd77 commented 2 years ago

Would you try the Qt/SDL version and let me know if you have screen tearing or audio crackling?

IPeluchito commented 2 years ago

I just tried it and I see that the Qt/SDL version doesn't have Vsync so it doesn't present audio problems but the video loses sync at times and it's a bit annoying... I don't know how this issue will be in Linux but in Windows, Vsync is mandatory...

mjbudd77 commented 2 years ago

The OpenGL video driver in the Qt GUI should have always defaulted vsync on. The SDL video driver was defaulted off however. I just added a checkbox to the video config window so that this can no be controlled. Please try the vsync again. If it doesn't work for the OpenGL video driver please try the SDL one. Note that changing video drivers can sometimes require an application restart. Please try the latest Qt/SDL dev build let me know how it goes. As for audio, the Qt/SDL runs the GUI and emulation in separate threads, so the emulation thread will not be halted by the GUI thread waiting a little for the vertical sync. Because of the non-interruption of the emulation thread, I do not think the audio player will be starved of data.

mjbudd77 commented 2 years ago

The link you provided takes me to a site that keeps trying to install stuff to my browser. I'm not going to download it. Just tell me your findings.

mjbudd77 commented 2 years ago

I watched the video. I’m having trouble seeing what the issue is

IPeluchito commented 2 years ago

With Nestopia:

https://user-images.githubusercontent.com/64821708/145761536-e543ae2c-e26c-42c8-be93-9b56cb2bb518.mp4

mjbudd77 commented 2 years ago

I did find some sync issues with the video data when its passed from the emulation thread to the Qt GUI thread. I added a video buffering scheme to help this. I also added a vertical sync test pattern that can be turned on from the video config window. Please try the latest Qt GUI dev build again and provide feedback.

IPeluchito commented 2 years ago

Using OpenGL:

https://user-images.githubusercontent.com/64821708/146492632-26391d2e-548b-4fe4-abe9-f2dca108bcc7.mp4

Using SDL it works fine but there is tremendous lag in the whole interface and keyboard input...

mjbudd77 commented 2 years ago

I was able to replicate the SDL input lag (which only occurred in windows, linux did not have this issue). I added code to ensure that the inputs are processed before screen rendering occurs which seems to have fixed the input lag. I also increased the video transfer buffer size which I hope will help with the OpenGL rendering. Beyond that, I'm out of ideas on what can be done with the OpenGL (much of that code is internal to Qt). If the SDL video driver works for you, then just use that one. I made the video driver a selectable option just for this reason. Give latest dev build another try please.

IPeluchito commented 2 years ago

SDL input lag fixed but sync issues with OpenGL rendering remain... Now I understand why emulators like melonDS and Nin that also use Qt and OpenGL also have synchronization problems...

Please don't stop updating the noQT versions, if you could also add Triple Buffering and fix the sound and gamepad disconfiguration (I'll open another thread about this) it would be excellent .....

Thank you for your effort!

mjbudd77 commented 2 years ago

I’m only focused on the Qt Version. If you want to leave this bug open in hopes that someone else will eventually fix the win32 version, that is fine but it may be a while before someone gets to it (maybe never)