FrodeSolheim / fs-uae

Cross-platform Amiga emulator with a slight focus on gaming, but also with solid support for productivity apps including just-in-time (JIT) compilation.
https://fs-uae.net/
GNU General Public License v2.0
475 stars 95 forks source link

Building for SDL2 without specific OpenGL #262

Open vanfanel opened 3 years ago

vanfanel commented 3 years ago

Hi there

I have been trying to build current fs-uae GIT against SDL2, so I can test it on the KMSDRM backend SDL2 has, so no X11 involved or available on the system.

I am trying to remove all unnecessary dependencies on this build.

To get that, I have manually disabled X11 support in config.h, and OpenAL (there's ALSA)... But it seems that OpenGL is still being used and needed directly by the emulator, as I can see in https://github.com/FrodeSolheim/fs-uae/blob/master/fsemu/src/fsemu-sdlwindow.c

Thus, disabling OpenGL results in undefined symbols on building.

So, why would the emulator use OpenGL directly instead of simply letting SDL2 do the scaling, etc? After all, SDL2 uses OpenGL/GLES under the hood. If OpenGL is mandatory for some reason, how can I specify GLES usage for non-X11 builds?

Thanks!

FrodeSolheim commented 3 years ago

FS-UAE can run without OpenGL (probably) and use the SDL2 video functions, but there is no support for building without it. No reason why it couldn't be implemented.

FS-UAE uses OpenGL directly by default, because it gives a bit better control of swapping/timing than what SDL2 provides.

The SDL2 graphics backend in FS-UAE might lag a bit behind the OpenGL one, and I'm not 100% sure if it works properly in the master branch (it might though).

vanfanel commented 3 years ago

@FrodeSolheim I tried to build without OpenGL (by disabling it manually in config.h) and it results on undefined symbols on linking. Any other thing I have to do to test the plain SDL2 renderer?

Also, how would OpenGL give a better control on frame swapping over SDL2 on KMS/DRM?

Anyway, it seems that GLES is also supported, isn't it?

FrodeSolheim commented 3 years ago

As I mentioned, I've not made any effort to make it build without OpenGL.

OpenGL lets you use glFlush/glFinish/fences to give (a bit) more control on when graphics operations are done. Also, with OpenGL you can turn on/off vsync dynamically (relevant when the Amiga switches between 50/60 Hz internally for example). SDL2 does not allow to change vsync after window creation.

vanfanel commented 3 years ago

@FrodeSolheim Ah! interesting. So, all in all, FS-UAE should work on a Pi4 without X11, which would normally use GLES, right?

And while we are at it, how can I turn off bezels? I have tried all kind of commandline parameters from the online docs. (I have some more questions about the emulator, is it right if I ask you here? I tried discord but it seems to be silent)

solskogen commented 3 years ago

You'll probably have a better time with amiberry instead of FS-UAE on the Pi.

FrodeSolheim commented 3 years ago

@vanfanel The master branch works very well with OpenGL / KMS without X11 on Raspberry Pi4. It works better than on X11 actually, there is some occasional microstuttering there.

(Though, I needed to use the git version of SDL2 at when I tested - around new year, because the latest stable SDL2 version at that time had a vsync issue which had been fixed in their official repo, not sure if there's been a new SDL2 version since then).

vanfanel commented 3 years ago

@FrodeSolheim Latest GIT SDL2 with KMSDRM works very well now. I did some fixes last year, and other developers also did very good work on that. What about the bezels? How can I disable them?

@solskogen Thanks for your input. The thing is that Amiberry doesn't seem to have latest WINUAE emulation corrections (it seems to be based on an older UAE version, if I am not mistaken) and also it seems that Amiberry doesn't sync emulation to host refresh rate (FS-UAE seems to be able of that) resulting on small hiccups even when emulating a PAL machine on a 50Hz physical mode or an NTSC machine on a 60Hz physical mode.

FrodeSolheim commented 3 years ago

@vanfanel There will be option and shortcut to toggle the bezel / background. Right now, it can be disabled by a simple patch:

diff --git a/fsemu/src/fsemu-background.c b/fsemu/src/fsemu-background.c
index 8b9a5ce76..76c6411f3 100644
--- a/fsemu/src/fsemu-background.c
+++ b/fsemu/src/fsemu-background.c
@@ -13,7 +13,6 @@

 #define module fsemu_background

-#define FSEMU_WITH_BACKGROUND 1
 #ifdef FSEMU_WITH_BACKGROUND

 // ----------------------------------------------------------------------------
vanfanel commented 3 years ago

@FrodeSolheim Ah, thanks. The option is a good idea, yes! :)