Aloshi / EmulationStation

A flexible emulator front-end supporting keyboardless navigation and custom system themes.
MIT License
2.04k stars 897 forks source link

MALI support #199

Open unixunion opened 10 years ago

unixunion commented 10 years ago

Hi,

Can you please support the mali series GPU's via framebuffer.

/K

Aloshi commented 10 years ago

ES uses SDL2 for windowing and OpenGL ES 1.1 for drawing. The Linux framebuffer is not directly involved. What problem are you having?

unixunion commented 10 years ago

I am trying to run emulationstation direct on the framebuffer on a cubieboard, similarly to how it runs on the pi, without X.

Aha, so it uses OpenGL ES 1,1. then it could be my SDL patch which is causing issues. I will try vanilla SDL2 and get back with results.

/K

unixunion commented 9 years ago

I get the following error:

root@debian-armhf:/opt/retropie/supplementary/EmulationStation# ./emulationstation --debug
lvl2:   EmulationStation - v2.0.0-rc1, built Jul 19 2014 - 07:01:38
lvl2:   Creating surface...
lvl0:   Error initializing SDL!
        No available video device
lvl0:   Renderer failed to initialize!
lvl0:   Window failed to initialize!

output from sunxi-mali test

root@debian-armhf:/opt/retropie/supplementary/sunxi-mali# ./test/test 
EGL Version: "1.4 Linux-r3p0-04rel0"
EGL Vendor: "ARM"
EGL Extensions: "EGL_KHR_image EGL_KHR_image_base EGL_KHR_image_pixmap EGL_KHR_gl_texture_2D_image EGL_KHR_gl_texture_cubemap_image EGL_KHR_gl_renderbuffer_image EGL_KHR_reusable_sync EGL_KHR_fence_sync EGL_KHR_lock_surface EGL_KHR_lock_surface2 "
Surface size: 480x480
GL Vendor: "ARM"
GL Renderer: "Mali-400 MP"
GL Version: "OpenGL ES 2.0"
GL Extensions: "GL_OES_texture_npot GL_OES_compressed_ETC1_RGB8_texture GL_OES_standard_derivatives GL_OES_EGL_image GL_OES_depth24 GL_ARM_rgba8 GL_ARM_mali_shader_binary GL_OES_depth_texture GL_OES_packed_depth_stencil GL_EXT_texture_format_BGRA8888 GL_EXT_blend_minmax GL_OES_EGL_image_external GL_OES_EGL_sync GL_EXT_multisampled_render_to_texture GL_EXT_discard_framebuffer GL_OES_get_program_binary GL_EXT_shader_texture_lod "

SDL2 build log: http://pastebin.com/gDsekYJW SDL1 build log: http://pastebin.com/SwAF74Dp ES 2 build log: http://pastebin.com/b1nuew6B

/K

Aloshi commented 9 years ago

From what I know of SDL2, I think you will have to run ES through X to get it to work. The reason SDL2 works in the console on the Raspberry Pi is because there is a platform-specific video driver written for it (see SDL2/src/video/raspberry/*). ES doesn't draw directly to the framebuffer, it draws to an EGL window set up by that RPi driver.

It looks like SDL2 will still let you use OpenGL ES with the X11 driver.

You will probably need to set the GLSystem variable in the CMake config file to OpenGL ES to get EmulationStation to use the OpenGL ES-specific code. Something like cmake . -DGLSystem=OpenGL\ ES in the EmulationStation directory should do it (if you suspect this isn't working, you can hardcode it by editing CMakeLists.txt, line 14).

unixunion commented 9 years ago

Ok I'll give it a bash, I think though because the Mali is so popular, it would be awesome if someone coded up a direct driver for it too, X consumed so much resources that I cannot get retroarch to perform adequately, I have gotten retroarch to work directly with the Mali, and would love it if ES could also do that. Is it possible to perhaps build a KMS it Mali / limare driver for ES?

/K

On Saturday, July 19, 2014, Aloshi notifications@github.com wrote:

From what I know of SDL2, I think you will have to run ES through X to get it to work. The reason SDL2 works in the console on the Raspberry Pi is because there is a platform-specific video driver written for it (see SDL2/src/video/raspberry/*). ES doesn't draw directly to the framebuffer, it draws to an EGL window set up by that RPi driver.

It looks like SDL2 will still let you use OpenGL ES with the X11 driver.

You will probably need to set the GLSystem variable in the CMake config file to OpenGL ES to get EmulationStation to use the OpenGL ES-specific code. Something like cmake . -DGLSystem=OpenGL\ ES in the EmulationStation directory should do it (if you suspect this isn't working, you can hardcode it by editing CMakeLists.txt, line 14).

— Reply to this email directly or view it on GitHub https://github.com/Aloshi/EmulationStation/issues/199#issuecomment-49513000 .

gizmo98 commented 9 years ago

I get your error if i try to start emulationstation without X. Under X emulationstation starts but everything is slow as hell. If /usr/lib/libGL.so is present emulationstation uses MESA Software OpenGL. If i force OpenGL ES i get an error at startup.

I patched the unstable tree to force GLES. https://github.com/gizmo98/EmulationStation/commit/b208474ed5395da0a315d34349b97372c3208a4b

Aloshi commented 9 years ago

You'd have to build the driver for SDL2. You can copy a lot of the RPi driver (all the input handling code is probably going to be the same). The code to set up a window is usually pretty simple.

gizmo98 commented 9 years ago

Is it really necessary to modify the rpi driver?

Here is the error message if emulationstation is compiled with GLES.

console output:

olimex@a20-OLinuXino:/opt/retropie/supplementary/EmulationStation$ ./emulations$ terminate called after throwing an instance of 'std::logic_error' what(): basic_string::_S_construct null not valid Aborted olimex@a20-OLinuXino:/opt/retropie/supplementary/EmulationStation$

es_log.txt:

lvl2: EmulationStation - v2.0.0-rc1, built Jul 20 2014 - 19:18:03 lvl2: Creating surface... lvl2: Created window successfully. lvl2: Added unconfigured joystick HuiJia USB GamePad (GUID: 030000008f0e0000$ lvl2: Added unconfigured joystick HuiJia USB GamePad (GUID: 030000008f0e0000$

Aloshi commented 9 years ago

(I'm assuming that's run under X)

Try getting a backtrace with gdb. Use gdb /opt/retropie/supplementary/EmulationStation/emulationstation to load the executable and then, in the gdb prompt, r --debug --windowed to run ES in windowed mode. After it crashes alt-tab back to the terminal and type bt to print a backtrace.

gizmo98 commented 9 years ago

Starting program: /opt/retropie/supplementary/EmulationStation/emulationstation$ [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".

Program received signal SIGILL, Illegal instruction. 0xb6384788 in ?? () from /usr/lib/arm-linux-gnueabihf/libcrypto.so.1.0.0 (gdb) bt

0 0xb6384788 in ?? () from /usr/lib/arm-linux-gnueabihf/libcrypto.so.1.0.0

Cannot access memory at address 0x0

1 0xb638252c in OPENSSL_cpuid_setup ()

from /usr/lib/arm-linux-gnueabihf/libcrypto.so.1.0.0

2 0xb6febcd2 in ?? () from /lib/ld-linux-armhf.so.3

3 0xbefff64a in ?? ()

Cannot access memory at address 0x65642d24 (gdb) continue Continuing. lvl2: EmulationStation - v2.0.0-rc1, built Jul 20 2014 - 19:18:03 lvl2: Creating surface... lvl2: Created window successfully. terminate called after throwing an instance of 'std::logic_error' what(): basic_string::_S_construct null not valid

Program received signal SIGABRT, Aborted. 0xb68f5fa6 in ?? () from /lib/arm-linux-gnueabihf/libc.so.6 (gdb) bt

0 0xb68f5fa6 in ?? () from /lib/arm-linux-gnueabihf/libc.so.6

1 0xb690423a in raise () from /lib/arm-linux-gnueabihf/libc.so.6

2 0xb69066d8 in abort () from /lib/arm-linux-gnueabihf/libc.so.6

3 0xb6a9af3a in __gnu_cxx::__verbose_terminate_handler() ()

from /usr/lib/arm-linux-gnueabihf/libstdc++.so.6

4 0xb6a99a88 in ?? () from /usr/lib/arm-linux-gnueabihf/libstdc++.so.6

5 0xb6a99a88 in ?? () from /usr/lib/arm-linux-gnueabihf/libstdc++.so.6

Backtrace stopped: previous frame identical to this frame (corrupt stack?) (gdb) continue Continuing.

Program terminated with signal SIGABRT, Aborted. The program no longer exists. (gdb) bt No stack. (gdb)

Aloshi commented 9 years ago

The first break (SIGILL) is from OpenSSL. It traps the illegal instruction signal to figure out what instructions are supported on the current platform (weird, I know).

terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_S_construct null not valid

This seems to indicate that an std::string is being set to the value NULL (from a const char* assignment). The backtrace show where the exception occurred though. Maybe try again with catch throw (as per this)?

As a hunch, it might be from the OpenGL extension checking code. Try commenting out lines 169-171 from es-app/src/main.cpp (std::string glExts = ...) and see if that fixes it.

gizmo98 commented 9 years ago

Starting program: /opt/retropie/supplementary/EmulationStation/emulationstation$ [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".

Program received signal SIGILL, Illegal instruction. 0xb6384788 in ?? () from /usr/lib/arm-linux-gnueabihf/libcrypto.so.1.0.0 (gdb) bt

0 0xb6384788 in ?? () from /usr/lib/arm-linux-gnueabihf/libcrypto.so.1.0.0

Cannot access memory at address 0x0

1 0xb638252c in OPENSSL_cpuid_setup ()

from /usr/lib/arm-linux-gnueabihf/libcrypto.so.1.0.0

2 0xb6febcd2 in ?? () from /lib/ld-linux-armhf.so.3

3 0xbefff64a in ?? ()

Cannot access memory at address 0x65642d24 (gdb) continue Continuing. lvl2: EmulationStation - v2.0.0-rc1, built Jul 22 2014 - 20:13:16 lvl2: Creating surface... lvl2: Created window successfully. lvl0: Image texture is not initialized! lvl0: Error - tried to build TextCache with Font that has no texture loaded!

Program received signal SIGSEGV, Segmentation fault. 0x000febc2 in Window::renderLoadingScreen() () (gdb) bt

0 0x000febc2 in Window::renderLoadingScreen() ()

1 0x00000000 in ?? ()

(gdb) continue Continuing.

Program terminated with signal SIGSEGV, Segmentation fault. The program no longer exists. (gdb) bt No stack. (gdb)

gizmo98 commented 9 years ago

Any idea how to go on?

Aloshi commented 9 years ago

It looks like ES is crashing when it's rendering the loading screen. Specifically, it is failing to load any OpenGL textures ("Image texture is not initialized" for the image and "Tried to build TextCache with Font that has no texture loaded!" for the "LOADING..." text). The SIGSEGV is the text rendering code trying to render a NULL pointer, causing a crash (intentional, since it means something is really messed up). Even if you got past the loading screen I doubt you would see anything.

Not sure where to go from here. My first guess is that the OpenGL ES 1.1 context is not being set up by SDL2 correctly, but I'm not sure how you'd debug that.

gizmo98 commented 9 years ago

Is it possible to check if sdl2 was build with gles support? I use sdl2 from debian wheezy backports repo. I can also try to build sdl from source.

Aloshi commented 9 years ago

I think you can use the sdl2-config utility to check what SDL2 was built with. You can also try adding some debug output to the renderer initialization code.

gizmo98 commented 9 years ago

My problem is fixed. EmulationStation runs with gles if SDL2 is build with ./configure --disable-opengl. SDL2.0.1 will not build if /usr/include/GL, /usr/include/GLES and /usr/include/GLES2 are present at the same time. I just renamed /usr/include/GL and /usr/include/GLES during compilation and everything works fine.

mihailescu2m commented 9 years ago

@gizmo98 - you got it running under X11 or fbdev? was there any progress on fbdev mali? anyone tried to write a SDL video driver?

mihailescu2m commented 9 years ago

for those that get here, they can contact me for the SDL video driver. I got ES 2.0 running nicely on mali fbdev.

unixunion commented 9 years ago

Hi mihailescu2m,

Can you put up a gist of that?

Thanks /K

abibier commented 9 years ago

Hi @mihailescu2m , I'm trying to set up some game emulators on my Banana Pro (with this HowTo: http://forum.lemaker.org/thread-6212-1-1-1.html). It would be really nice if I could get the video drivers.

Thanks, abibier

mihailescu2m commented 9 years ago

http://paste.ubuntu.com/9881008/

i am pasting this here for those that want to start with something, i will make a proper patch sometime later. but basically this is SDL_malivideo.c I made, look in the video/raspberry folder on how to use it.

binarycounter commented 9 years ago

Hi @mihailescu2m , Any update on the patch? I tried inserting the file into the src/video folder but nothing is different after compiling and reinstalling sdl2

mihailescu2m commented 9 years ago

@felix3008 you can get more details here: http://forum.odroid.com/viewtopic.php?f=116&t=8659#p70694 including a link to download pre-build SDL2 package with the fbdev context driver. One of the issues I find with SDL2 for some boards (Odroid-C1 with amlogic/mali450) is alpha blending in 32bpp; in 16bpp it's ok; with Odroid-U3 (exynos/mali400) there is no blending issue. So I am still looking at why that happens.

mihailescu2m commented 9 years ago

and for those that want patches: check commit history at: https://github.com/mihailescu2m/libsdl2-2.0.2-dfsg1/tree/mali or just build on debian/ubuntu with: dpkg-buildpackage -us -uc -b or get ubuntu packages from: http://oph.mdrjr.net/memeka/downloads/

RPCS commented 8 years ago

I would like to contact mihailescu2m, because i have a need for running retroarch and something like emulation station on the cubieboard 2/3. I would much rather use a front end like cabrio, but i am so un-knowledgeable in regard to deep down linux stuff. I can follow tutorials well, but when it comes to true knowledge im lacking. If there is any support in the form of a tutorial that i can follow and get beat up by errors, im all for it. Thanks.

mihailescu2m commented 8 years ago

Sorry I cannot help with a cubieboard as I don't have one and I don't know if drivers/SDL work on it

Archangl7 commented 8 years ago

@mihailescu2m the above statement " for those that get here, they can contact me for the SDL video driver. I got ES 2.0 running nicely on mali fbdev." makes me believe you can help. the error i get is mesa-loader:malformed or no PCI ID libgl error: unable to load driver:mali_drm_dri.so libgl error:driver pointer missing libgl error:failed to load driver: mali_drm

I have done tons of research on this but my knowledge is limited, so some things dont all make sense to me. I think i have been working on this over a week pretty much every day. This situation is needed for me on a project, so any help is much appreciated!

and i have run lsmod and it shows those drivers, i have installed all prerequisites for emulation station, retroarch, and cabro. All 3 front ends throw the same error, except a window actually opens for cabrio, but is super slow. I assume due to no hardware acceleration. @abibier had the same problem as i looked at his blog and so many others. The cubieboard has a mali400 chip and an a20 dual core. From what i understand this is an error due to the video drivers not linking or compiling properly.