f2e-spec icon indicating copy to clipboard operation
f2e-spec copied to clipboard

OpenGL ES 2.0 + EGL port

Open tapio opened this issue 12 years ago • 28 comments

The new rendering engine in 0.7.0 should make this rather straight-forward. Implementing this would allow us to try porting the game to new embedded and mobile platforms such as the Raspberry Pi (which has been requested a few times; performance might become an obstacle but it's worth a try).

tapio avatar Dec 11 '12 13:12 tapio

WIP @ branch egl

tapio avatar Dec 11 '12 20:12 tapio

Current status for Raspberry Pi:

  • Main menu opens, there is more or less correct graphical output, including the changing background color
  • Audio is horribly distorted
  • Input does not work at all
  • Framerate is horrible

In short, progress is being made, but it is not yet playable (and it's not actually clear if it ever will be performant enough).

tapio avatar Dec 20 '12 12:12 tapio

Some results from profiling the menu screen on an overclocked RPi; the changes were made on top of each other:

  1. Vanilla: 160 ms, 6.5 FPS
  2. Remove all three(!) glFinish() calls: 130 ms, 8 FPS
  3. Disable background music: 100 ms, 11.5 FPS
  4. Disable menu option drawing (so only bg and comment): 50 ms, 23 FPS
  5. Reduce graphics window size from full HD to 800x600: 40ms, 24.5 FPS

I also tried these, but without an effect:

  • Remove colorMatrix
  • Reduce shader float precision
  • Remove glError calls

Some conclusions:

  • It seems we are not shader bound: decreasing pixels to about a quarter gave only a minor improvement in performance and simplifying shaders did not have any effect. Also, we have a trivial amount of vertices to process.
  • It is worrying that simply playing music takes so much milliseconds
  • I looked into our surface rendering code and it doesn't seem particularly efficient: creating new vertex arrays each loop as well as not caching attribute locations. However, disabling all actual drawing in intro screen (leaving the logo and fps counter) together with the other changes above only got us to 25 FPS.

tapio avatar Dec 20 '12 16:12 tapio

Is the conclusion that RPi cannot be supported? How about other GLES devices? Android phones in particular would be very interesting. If GLES porting itself is complete and no longer actively being worked on, I suggest closing this bug.

Tronic avatar Jan 23 '13 22:01 Tronic

I'm not quite ready to throw in the towel regarding RPi, but been too busy to work on this. While the GLES porting is mostly done, the EGL side is still incomplete: window surface creation is only implemented for RPi (which needs some special interfacing with its GPU blob) - I'm not sure if there exists a generic way that would be supported by a good chunk of other devices, though some might allow (desktops should at least) hooking up to an X Window. An even bigger problem is the lack of keyboard (or joystick) input as no X Window is created.

For devices which have X Server available, it might be possible to create an invisible window to capture input, but I'd like to find a way to do without because it would be nice to free the memory and cpu resources required by the server to use for the game itself.

tapio avatar Jan 24 '13 07:01 tapio

The best way would be to write another input driver that reads evdev input directly. IIRC, this also circumvents some issues we have with the joysticks (not being able to tell drums and guitar apart or whatnot). The drawback is that root access or manually adjusting event device permissions might be required.

Tronic avatar Jan 24 '13 07:01 Tronic

Hi,

I have tried to get this to work with my Raspbmc without luck. I have cloned the egl branch, compiled installed and

.... ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name ALSA lib conf.c:4241:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:4720:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM dmix Segmentation fault

and running as sudo...

ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM dmix Client is not authorized to connect to Server ^Cvideo/warning: Error setting GLattr 7: requested 8, got 0 video/warning: Error setting GLattr 6: requested 24, got 0 video/warning: Error setting GLattr 4: requested 32, got 0 video/warning: Error setting GLattr 3: requested 8, got 0 video/warning: Error setting GLattr 2: requested 8, got 0 video/warning: Error setting GLattr 1: requested 8, got 0 video/warning: Error setting GLattr 0: requested 8, got 0 FATAL ERROR: SDL_SetVideoMode failed: OpenGL not available

Both of these attempts where from a remote shell which I am guessing may not work as opengl es cannot display to client via ssh. How do I test (or can i) on top of the raspbmc interface or do I need to have a regular x session running on RPi to test?

Thanks, Pete.

ear9mrn avatar May 01 '13 22:05 ear9mrn

I'm not familiar with peculiarities of Raspbmc, but X should not be needed. If you think ssh might be the culprit, you should try without it. Note, however, that unless you plan on developing it, there isn't much to see apart from a laggy menu with choppy sound, missing all interaction.

tapio avatar May 02 '13 05:05 tapio

Thanks. After a little more effort I was able to get it to work. I am now running Raspbian (Raspbmc runs rasbian with XBMC on top). I need to install the following to get it to work (not sure which was the key one) :

apt-get install libgl1-mesa-glx libglapi-mesa libgles2-mesa libgles2-mesa-dev libgl1-mesa-swras

So I do not get as far as the menu:

ALSA lib pcm_dmix.c:1018:(snd_pcm_dmix_open) unable to open slave audio/error: Audio device 'dev="USBMIC" mics="blue,red"': No such device. audio/error: Audio device 'dev="Microphone" mics="*"': No such device. audio/error: Audio device 'out=2': Device doesn't have enough output channels Attempting to set video mode opengl/error: Invalid enum in Shader::bind precondition opengl/error: Invalid enum in Shader::bind precondition

It takes a while then just stop saying no audio devices are connected, I am sure I can get that fixed.

What is the plan for this branch? My vision would be to have Performous run on top of http://www.raspbmc.com/ which is a full fledged media server front end. There is a plugin (add on) capability but I think a simpler approach would be just to get Performous working stand alone and run it via the "advanced launcher" add on. I would not consider myself a hard core coder but know enough to be dangerous. Is there anything simple I can help with so I can dip my toes in the water as it were?

Thanks,

Pete.

ear9mrn avatar May 03 '13 07:05 ear9mrn

The goal of this branch is to get it running on RasPi with enough performance and features to be useful, while trying to be generic so that support for other GLES devices could be added with ease.

There are major issues however. First one is that it currently has very bad performance as I detailed earlier, and it is unclear if the RasPi can ever cope with all the threads Performous spawns.

Second big problem which also hinders testing is lack of any kind of input. This would be relatively straight forward to fix by implementing the RawInput_PollEvent function in raw_input.cc by borrowing some raw linux keyboard reading code from e.g. https://github.com/chriscamacho/gles2framework.

PS. Missing audio devices should not prevent graphics from appearing.

tapio avatar May 03 '13 09:05 tapio

there's a new SDL2 version: http://gamingonlinux.com/articles/sdl-development-library-202-released-adds-experimental-wayland-mir-support.3244

and it comes with quite an interesting feature:

  • EGL can now create/manage OpenGL and OpenGL ES 1.x/2.x contexts, and share them using SDL_GL_SHARE_WITH_CURRENT_CONTEXT

nieknooijens avatar Mar 11 '14 09:03 nieknooijens

So... the new raspberry 2 type B is now out and comes with more RAM, a faster CPU and ARM7 support. Any chance to see another go at this issue? Like others here, I'd love to be able to play around with performous on a rpi.

fpoirotte avatar Feb 26 '15 20:02 fpoirotte

As I already own a Raspberry Pi 2, I will play around with this. The switch from GLEW to libepoxy was the first step to get this working without too much "extra" code.

TobiX avatar Feb 27 '15 10:02 TobiX

Could this port work on http://www.banana-pi.org/m3.html ?

wellumies avatar Apr 11 '16 10:04 wellumies

If the GL stack isn't broken like on most distributions I tried last year on the Raspberry Pi 2, you might want to give it a try. There are probably still a lot of places in the code to fix and the shaders might need some tuning...

TobiX avatar Apr 11 '16 10:04 TobiX

I tested it a month ago on the last raspbian but the RPi2 openGL driver is very, very unstable, unfortunately we need it because performous depends on GLX.

nieknooijens avatar Apr 11 '16 14:04 nieknooijens

Yes, but the GLX dependency is very light nowadays (I think). We don't link against GLX directly, but to even start squashing the bugs in our GLES suport, you need to disable webcam support, since OpenCV links to libGL directly...

TobiX avatar Apr 11 '16 18:04 TobiX

obsolete since we use libepoxy and raspbian offers experimental "fat" openGL support.

nieknooijens avatar Jan 22 '17 14:01 nieknooijens

We still have no proper EGL support...

TobiX avatar Jan 23 '17 01:01 TobiX

@TobiX it runs on a Pi2 using libepoxy, see: https://www.dropbox.com/s/7o8ar3lumqzlsb4/VID_20170124_100548.mp4?dl=0

nieknooijens avatar Jan 24 '17 09:01 nieknooijens

Tried running on a Pi3:

  • I have (latest master without webcam) running under X, using OpenGL, but I had to compile libSDL2 (2.0.5) without opengles. Another bug is fixed using master checkout of libepoxy. There are still some minor bugs present, but it works, although it constantly fully uses all cores.
  • running with libSDL2 from repository (using performous from repo and also latest from git) under X gives me: "SDL_SetVideoMode failed: Could not get EGL display"
  • running from tty, using libSDL2 from repository (with EGL support I assume), gives me "OpenGL 2.1 is required but not available".
    • After disabling this check: "performous: Couldn't find current GLX or EGL context."
    • Using libepoxy from master it gives me: "FATAL ERROR: core.vert: Couldn't create shader."

tatankat avatar Jan 26 '17 22:01 tatankat

Using libepoxy from master it gives me: "FATAL ERROR: core.vert: Couldn't create shader."

That is the missing GLES support in Performous' code (which would also be nice for Android support...) - Maybe someone with more GL experience then me could take a look at the shaders and make them compatible with GLES... The egl branch might have some hints.

(Be aware that "fat" OpenGL support on RPi is not much better then a software renderer, since it falls back to software rendering for many operations - alas, it might be enough for Performous...)

TobiX avatar Jan 29 '17 16:01 TobiX

to be honest. is EGL still a thing? the nvidia shield and some other android devices can already run "fat openGL" and the Raspberry pi 2 can run it as well. isn't it a better idea to port to vulkan instead?

nieknooijens avatar Jan 31 '17 09:01 nieknooijens

I just found https://github.com/p3/regal which might help with this and perhaps https://github.com/performous/performous/issues/482 as it apparently can emulate OpenGL on OpenGL/GL ES, without the full performance drag from emulation (6–8 fps on Thinkpad X61, Core2duo 2 GHz, with llvmpipe software rendering).

Might be useful to try whether it works, perhaps even without code changes (LD_LIBRARY_PATH is mentioned).

mirabilos avatar Aug 20 '19 00:08 mirabilos

Reviving the old thread I don't own a Raspberry so can't quite test it. Current status is that it still doesn't work as mentioned in discord

Build + install went fine, but then a runtime failure appeared:

video/warning: Error setting GLattr m_attr: requested 1, got 0
video/warning: Error setting GLattr m_attr: requested 24, got 0
video/warning: Error setting GLattr m_attr: requested 32, got 0
video/warning: Error setting GLattr m_attr: requested 8, got 0
video/warning: Error setting GLattr m_attr: requested 8, got 0
video/warning: Error setting GLattr m_attr: requested 8, got 0
video/warning: Error setting GLattr m_attr: requested 8, got 0
video/warning: Error setting GLattr m_attr: requested 1, got 0
core/notice: More details might be available in "/home/jl/.cache/performous/infolog.txt".
logger/info: Exiting normally.
FATAL ERROR: SDL_GL_CreateContext failed with error: Could not create GL context: GLXBadFBConfig
core/error: SDL_GL_CreateContext failed with error: Could not create GL context: GLXBadFBConfig

Baklap4 avatar Aug 14 '23 09:08 Baklap4

@Baklap4 try running with MESA_GL_VERSION_OVERRIDE=4.3 - works for me on a RP4 running Raspbian.

Sound is still borked, though.

izar avatar Sep 01 '23 20:09 izar

@izar That's great to know! What do you mean that the sound is borked? Are there sound devices messed up, or no output over HDMI, or something similar? Do you happen to have like a Behringer or MobilePRE USB interface you could try it with? I won't be able to get to it for a few days, but I will give this a try also. I end up using a Behringer Uphoria most of the time anyway on my x86 hardware. Will keep you posted

ooshlablu avatar Sep 07 '23 18:09 ooshlablu

hi @ooshlablu - sorry for the brevity of the description. I was going between ultradx, pykaraoke and performous. Got to a point where ultradx works, after some juggling of alsa and pulseaudio configs. Performous, unfortunately, exits with alsa error messages that I cannot make go away. I am not close to my RP4 right now, but as soon as I am I'll try to collect the exact information and open a different ticket just for it.

izar avatar Sep 07 '23 18:09 izar