pjasicek / OpenClaw

Reimplementation of Captain Claw (1997) platformer
GNU General Public License v3.0
345 stars 40 forks source link

Segfault under gl4es under Maemo-Leste. #167

Open clort81 opened 3 years ago

clort81 commented 3 years ago

Hi pjasicek! AWESOME work! So well done. \o/

Even runs on my Motorola Droid 4 (2011 phone) under Maemo-Leste!

[In-game. not menu] Gets about 4fps with mesa software rendering. Switching to opengl, with gl4es the start menu runs fine, but as soon as game is started gl4es segfaults. captain_claw_leste1

INFO: "/level_metadata/level3.xml": level metadata file successfully loaded.
INFO: "/level_metadata/level7.xml": level metadata file successfully loaded.
INFO: "/level_metadata/level6.xml": level metadata file successfully loaded.
INFO: Display changed. New Width-Height: 960-540
INFO: Changing to: 3
ERROR: [MEMORY_PROFILER] Memory profiler not supported on this platform !

Thread 1 "openclaw" received signal SIGSEGV, Segmentation fault.
0xb4e2c9a4 in glGenerateMipmap () from /usr/lib/arm-linux-gnueabihf/libGLESv2.so
(gdb) bt
#0  0xb4e2c9a4 in glGenerateMipmap () from /usr/lib/arm-linux-gnueabihf/libGLESv2.so
#1  0xb4d4cc1e in realize_textures (drawing=drawing@entry=1)
    at /big/src/gl4es/src/gl/texture_params.c:911
#2  0xb4d1cf88 in draw_renderlist (list=<optimized out>, list@entry=0x6459858)
    at /big/src/gl4es/src/gl/listdraw.c:689
#3  0xb4d134ee in gl4es_flush () at /big/src/gl4es/src/gl/gl4es.c:1010
#4  0xb4d4b2b4 in gl4es_glBindTexture (target=34037, texture=<optimized out>)
    at /big/src/gl4es/src/gl/texture_params.c:192
#5  0xb6ef8138 in ?? () from /usr/lib/arm-linux-gnueabihf/libSDL2-2.0.so.0
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) 

Perhaps it's a simple fix since menu code works fine. Possibly related to mipmap? I don't see a need for mipmaps.

[EDIT] export LIBGL_MIPMAP=3 gets me past the segfault but white-screen in-game :)

[PLANE CREATION]: Elapsed microseconds: 109283
[PLANE CREATION]: Elapsed microseconds: 528137
[PLANE CREATION]: Elapsed microseconds: 5279
WARN: [CalculatePatrolBorders] Did not find raycastResultLeft intersection for actor: Level13_BearSailor with position: [X: 11662.000000, Y: 865.999981]
WARN: [CalculatePatrolBorders] Did not find raycastResultLeft intersection for actor: Level13_BearSailor with position: [X: 7784.000000, Y: 994.000023]
WARN: [CalculatePatrolBorders] Did not find raycastResultLeft intersection for actor: Level13_BearSailor with position: [X: 12383.000000, Y: 738.000023]
WARN: [CalculatePatrolBorders] Did not find raycastResultLeft intersection for actor: Level13_RedTailPirate with position: [X: 11981.000000, Y: 738.000023]
INFO: Level loaded !
INFO: Level name: Level - 13
INFO: Level author: Monolith Productions Inc.
INFO: Level created date: July 8, 1997
INFO: Loading startup ingame commands...
[GAME LOADING]: Elapsed microseconds: 22891021
INFO: Changing to: 4
INFO: Changing to: 5
ERROR: [AmmoUpdatedDelegate] Unknown ammo type: 1
ERROR: [AmmoUpdatedDelegate] Unknown ammo type: 2
fluidsynth: error: Unable to open file "/usr/share/sounds/sf3/FluidR3Mono_GM.sf3"
fluidsynth: error: Couldn't load soundfont file
fluidsynth: error: Failed to load SoundFont "/usr/share/sounds/sf3/FluidR3Mono_GM.sf3"
fluidsynth: warning: Failed to pin the sample data to RAM; swapping is possible.
fluidsynth: warning: Failed to pin the sample data to RAM; swapping is possible.

looks like it's running - 94% cpu.

pjasicek commented 3 years ago

Hello.

First of all, impressive work !

Some hints what I'd try:

1) Try to build SDL2 on linux host with GLES backend and use software rendering, to "emulate" the device's environment on a build host. If you encounter the same problem on the host, it will be much easier to debug.

2) Try to lower the resolution to e.g. 320x240 to reduce the amount of pixels drawn, maybe it will load that way

But 4 fps in the menu screen (where there are just a few drawn primitives and no logic) is abit awkward :smile:

Good luck !

clort81 commented 3 years ago

Nothing impressive by me. Maemo-leste runs the same devuan OS as my desktop. :1st_place_medal: I just set the resolution to 960x540 in the config and compiled with no changes. You did a good job making menu UI fit the varying resolutions.

I didn't know you had a gles backend! Woo Woo! :dancers:

The 4fps was running the actual game with mesa software rasterization.

pjasicek commented 3 years ago

Well, OpenClaw does not use any lower layer GL backend directly - it uses SDL2 which can use OpenGL (generic linux), DirectX (generic windows) backends, so my guess is it can be compiled with GLES backend also

clort81 commented 3 years ago

Does this mean the compositing of sprites in-game is done by cpu?

I have a build running in-game now but fps is around 4. I tried profiling but appear to run out of memory.

pjasicek commented 3 years ago

No no, both OpenClaw desktop and web builds use graphics card for rendering - on my PC I get 1800 FPS :-)

What I meant is that you can build SDL2 library in different ways - on windows it is by default with DirectX rendering backend, on Linux it is by default with OpenGL rendering backend (maybe you can select Vulkan renderer now also) and for embedded devices it should be GLES rendering backend by default.

clort81 commented 3 years ago

Our drivers only natively support opengl-es 2. Opengl is provided by ptitSeb's gl4es shim.

I think SDL2 is prioritizing opengl over opengl-es backend, and this ought to be overridable by an envvar - but it isn't. I think Sam Latinga assumed opengl would always be preferable to -es.

[edit] libSDL2 has this: SDL_HINT_RENDER_DRIVER="opengles2" https://wiki.libsdl.org/SDL_HINT_RENDER_DRIVER

I guess this is not an OpenClaw issue anymore but it was nice to chat with you.

pjasicek commented 3 years ago

Interesting. As you say, this is most likely device+platform specific issue which I unfortunately can be of little help.

If you run into any other problem with which I may help you in some way, feel free to message me or create another issue :-)

I'd also be glad if you could share your progress, I'm always happy when people get it running on some exotic platform :smile: