drfiemost / Hurrican

A fork of Hurrican, freeware jump and shoot game created by Poke53280, with SDL2 enabled by default, support for libopenmpt and CRT simulation
MIT License
7 stars 2 forks source link

Hurrican has became very slow on Raspberry Pi 4 #25

Closed vanfanel closed 1 year ago

vanfanel commented 1 year ago

Hi there @drfiemost

I hadn't updated Hurrican since last year or so, and now that I have updated to the latest sources on your repository and rebuilt on the Pi 4 (Debian 11, aarch64) I am seeing the game runs at like 5FPS.

This is the game log, where everything looks fine: Game_Log.txt

This is how I always configure it:

cmake -DCMAKE_BUILD_TYPE=Release -DRENDERER=GLES2 \
-DCMAKE_C_FLAGS="-march=native -mtune=native" \
-DCMAKE_CXX_FLAGS="-march=native -mtune=native" ..

Any idea on what could have changed in the last year to make it so slow on GLES2??

All my other GLES2 software performs normally.

vanfanel commented 1 year ago

Tried buiding with -DRENDERER=GL2 instead, and it's equally slow :( (Yes, the Pi supports OpenGL too, not only GLES)

drfiemost commented 1 year ago

This repository is no longer updated, use the official one: https://github.com/HurricanGame/Hurrican

Anyway, can you try build using the option -DPLATFORM=RPI ? Also, by overriding the cmake flags, I think you're disabling optimizations.

vanfanel commented 1 year ago

Ok, I hadn't noticed the change of the repository. I have built the latest sources in the new repo, with the same results.

As for building with -DPLATFORM=RPI, it results on an error:

[  0%] Building CXX object CMakeFiles/hurrican.dir/src/DX8Graphics.cpp.o
In file included from /root/src/Hurrican/Hurrican/src/SDLPort/SDL_port.hpp:41,
                 from /root/src/Hurrican/Hurrican/src/DX8Graphics.hpp:21,
                 from /root/src/Hurrican/Hurrican/src/DX8Graphics.cpp:17:
/root/src/Hurrican/Hurrican/src/SDLPort/opengl.hpp:20: warning: "glClearDepth" redefined
   20 | #define glClearDepth glClearDepthf
      | 
In file included from /usr/local/include/epoxy/gl.h:89,
                 from /root/src/Hurrican/Hurrican/src/SDLPort/opengl.hpp:4:
/usr/local/include/epoxy/gl_generated.h:16870: note: this is the location of the previous definition
16870 | #define glClearDepth epoxy_glClearDepth
      | 
/root/src/Hurrican/Hurrican/src/DX8Graphics.cpp:29:10: fatal error: eglport.h: No such file or directory
   29 | #include "eglport.h"
      |          ^~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/hurrican.dir/build.make:524: CMakeFiles/hurrican.dir/src/DX8Graphics.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/hurrican.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

Note that the Raspberry Pi is an standard GNU/Linux system by now: it supports the same APIs that any other system (OpenGL or GLES on KMS/DRM or Wayland).

Also, the game was perfectly fine like a year ago using -DRENDERER=GLES2 I will try to bisect the commit that broke it's performance, but can you give me any clues on possible candidate commits, please?

drfiemost commented 1 year ago

Fixed the error above but there might still be linking problems. There have been a lot of changes in the last year but none looks suspicious to me. Unless you're using the CRT emulation it should run fine... If you can bisect the offending commit it would be good.

Maybe -DFAST_TRIG=ON can help a bit, not sure what kind of CPU the raspberry have.

vanfanel commented 1 year ago

Hurrican (using your old repo code) was running perfectly fullspeed on the Pi 4 last year, even with CRT simulation (game doesn't look very good without it). The CPU on the Pi 4 is a 4-core A76. CPU usage, even now, is around 20%. Whatever destroyed performance, it's related to GPU.

Again, using specific Pi build options has never been needed...:(

I will try to find the offending commit, but can you give me an estimate of drastic or suspicious OPENGL/GLES related changes from this year, please? Building is slow, so repeated building isn't exactly pleasant...

drfiemost commented 1 year ago

I will try to find the offending commit, but can you give me an estimate of drastic or suspicious OPENGL/GLES related changes from this year, please? Building is slow, so repeated building isn't exactly pleasant...

https://github.com/HurricanGame/Hurrican/commit/92ad898255ad76c189a4117dc5e189ce6853aa1d is the commit introducing CRT effects other than scanlines (dated Nov 16, 2020). After that I cannot spot anything that could have an effect on GPU usage.

vanfanel commented 1 year ago

Thanks.

-I went as far as building the latest 2020 code and the performance problem is there already so it's something else, not the CRT simulation code.

-With -DPLATFORM=RPI I still get:

/usr/bin/ld: /tmp/ccE7v81d.ltrans9.ltrans.o: in function `GameInit()':
<artificial>:(.text+0x4c8): undefined reference to `EGL_Open'
/usr/bin/ld: /tmp/ccE7v81d.ltrans9.ltrans.o: in function `main':
<artificial>:(.text.startup+0xf3c): undefined reference to `EGL_Close'
/usr/bin/ld: /tmp/ccE7v81d.ltrans21.ltrans.o: in function `DirectGraphicsClass::ShowBackBuffer() [clone .constprop.0]':
<artificial>:(.text+0x3380): undefined reference to `EGL_SwapBuffers'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/hurrican.dir/build.make:3013: hurrican] Error 1
make[2]: Leaving directory '/root/src/Hurrican/Hurrican/b4'
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/hurrican.dir/all] Error 2
make[1]: Leaving directory '/root/src/Hurrican/Hurrican/b4'
make: *** [Makefile:136: all] Error 2

-With -DRENDERER=GLES1, speed is as it usdd to be! No CRT effect, though. I guess it uses shaders, which are not available on GLES1. With -DRENDERER=GL2, speed is again slooooow. So maybe it's shaders, but then.. why wasn't that a problem a year ago?

Maybe I should try older SDL2, older MESA and/or older libepoxy...

vanfanel commented 1 year ago

Ok, I found out that the issue starts at MESA 23.0.0 exactly (immediate previous version 22.3.7 is fine).

So I have opened an issue on MESA:

https://gitlab.freedesktop.org/mesa/mesa/-/issues/9316

I will keep this one open in case it's something with the game after all.

drfiemost commented 1 year ago

It seems a driver specific regression, no problems here on mesa 23.0.4 with a radeon card.

I'll close this one, if there's something wrong with the game please report it on the official page https://github.com/HurricanGame/Hurrican/issues