Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Slow performance with Raspberry PI 3B  (Read 3681 times)

0 Members and 1 Guest are viewing this topic.

bluszcz

  • Newbie
  • *
  • Posts: 5
    • View Profile
Slow performance with Raspberry PI 3B
« on: October 18, 2019, 11:12:40 pm »
Hello,

I have recently updated Raspbian on my Pi3B, and I have noticed that libsfml is included in the repositories.

I have managed to compile my project pretty much without any hustle, but then I noticed dramatic decrease of performance - game is not responsive at all, latency events/mouse clicks can be around 0.5s, and it pushed me to measure frames - and I got ~5fps... On laptop the game has few hundres fps, on workstation with Nvidia 1030 2-3k.

And this is not some sophisticated game - pretty simple board game, with main code happening here: https://github.com/deerportal/deerportal/blob/master/src/game.cpp

Does someone have experience with porting sfml projects to Pi and how they work?

Any help/comments appreciated.

bluszcz


eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10800
    • View Profile
    • development blog
    • Email
Re: Slow performance with Raspberry PI 3B
« Reply #1 on: October 19, 2019, 01:18:01 am »
Are you using OpenGL ES? The Raspberry Pi only really supports OpenGL ES and if you run OpenGL it will have to emulate the calls in software if it can't translate them to OpenGL ES.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

bluszcz

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Slow performance with Raspberry PI 3B
« Reply #2 on: October 19, 2019, 02:38:22 pm »
So, I checked and actually it was using default OpenGL - it seems a default libfsfml packages configuration on Raspbian.

I am trying to compile sfml with OpenGL ES, but for now it is crashing:

[ 16%] Built target sfml-system
Scanning dependencies of target sfml-window
[ 17%] Building CXX object src/SFML/Window/CMakeFiles/sfml-window.dir/GlContext.cpp.o
In file included from /tmp/libsfml-2.5.1+dfsg/src/SFML/Window/GlContext.cpp:73:
/tmp/libsfml-2.5.1+dfsg/src/SFML/Window/EglContext.hpp:165:12: error: ‘XVisualInfo’ does not name a type
     static XVisualInfo selectBestVisual(::Display* display, unsigned int bitsPerPixel, const ContextSettings& settings);
            ^~~~~~~~~~~
make[2]: *** [src/SFML/Window/CMakeFiles/sfml-window.dir/build.make:102: src/SFML/Window/CMakeFiles/sfml-window.dir/GlContext.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:176: src/SFML/Window/CMakeFiles/sfml-window.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
 

I found XVisualInfo in several places in system libs:

/usr/include/X11/Xutil.h:} XVisualInfo;
/usr/include/X11/Xutil.h:extern XVisualInfo *XGetVisualInfo(
/usr/include/X11/Xutil.h:    XVisualInfo*       /* vinfo_template */,
/usr/include/X11/Xutil.h:    XVisualInfo*       /* vinfo_return */
/usr/include/GL/glx.h:extern XVisualInfo* glXChooseVisual( Display *dpy, int screen,
/usr/include/GL/glx.h:extern GLXContext glXCreateContext( Display *dpy, XVisualInfo *vis,
/usr/include/GL/glx.h:extern GLXPixmap glXCreateGLXPixmap( Display *dpy, XVisualInfo *visual,
/usr/include/GL/glx.h:extern int glXGetConfig( Display *dpy, XVisualInfo *visual,
/usr/include/GL/glx.h:extern XVisualInfo *glXGetVisualFromFBConfig( Display *dpy,
/usr/include/GL/glx.h:typedef XVisualInfo * (* PFNGLXGETVISUALFROMFBCONFIGPROC) (Display *dpy, GLXFBConfig config);
/usr/include/GL/glxext.h:typedef XVisualInfo *( *PFNGLXGETVISUALFROMFBCONFIGPROC) (Display *dpy, GLXFBConfig config);
/usr/include/GL/glxext.h:XVisualInfo *glXGetVisualFromFBConfig (Display *dpy, GLXFBConfig config);
/usr/include/GL/glxext.h:typedef GLXPixmap ( *PFNGLXCREATEGLXPIXMAPMESAPROC) (Display *dpy, XVisualInfo *visual, Pixmap pixmap, Colormap cmap);
/usr/include/GL/glxext.h:GLXPixmap glXCreateGLXPixmapMESA (Display *dpy, XVisualInfo *visual, Pixmap pixmap, Colormap cmap);
/usr/include/GL/glxext.h:typedef XVisualInfo *( *PFNGLXGETVISUALFROMFBCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config);
/usr/include/GL/glxext.h:typedef GLXFBConfigSGIX ( *PFNGLXGETFBCONFIGFROMVISUALSGIXPROC) (Display *dpy, XVisualInfo *vis);
/usr/include/GL/glxext.h:XVisualInfo *glXGetVisualFromFBConfigSGIX (Display *dpy, GLXFBConfigSGIX config);
/usr/include/GL/glxext.h:GLXFBConfigSGIX glXGetFBConfigFromVisualSGIX (Display *dpy, XVisualInfo *vis);
/usr/include/glvnd/libglxabi.h:     * for the XVisualInfo or GLXFBConfig that the context is created from.
 

but nothing in the special Raspberry drivers.

Including X11/Xutil.h results with:

[ 17%] Building CXX object src/SFML/Window/CMakeFiles/sfml-window.dir/GlContext.cpp.o
[ 18%] Building CXX object src/SFML/Window/CMakeFiles/sfml-window.dir/WindowImpl.cpp.o
[ 19%] Building CXX object src/SFML/Window/CMakeFiles/sfml-window.dir/EglContext.cpp.o
In file included from /usr/include/X11/Xlib.h:44,
                 from /usr/include/X11/Xutil.h:53,
                 from /tmp/libsfml-2.5.1+dfsg/src/SFML/Window/EGLCheck.hpp:34,                                                                                                                                                          
                 from /tmp/libsfml-2.5.1+dfsg/src/SFML/Window/EglContext.hpp:33,                                                                                                                                                        
                 from /tmp/libsfml-2.5.1+dfsg/src/SFML/Window/EglContext.cpp:29:                                    
/tmp/libsfml-2.5.1+dfsg/include/SFML/Window/WindowStyle.hpp:40:9: error: expected identifier before numeric constant
         None       = 0,      ///< No border / title bar (this flag and all others are mutually exclusive)
         ^~~~                                                                                                
/tmp/libsfml-2.5.1+dfsg/include/SFML/Window/WindowStyle.hpp:40:9: error: expected ‘}’ before numeric constant
In file included from /tmp/libsfml-2.5.1+dfsg/src/SFML/Window/Unix/CursorImpl.hpp:34,
                 from /tmp/libsfml-2.5.1+dfsg/src/SFML/Window/CursorImpl.hpp:39,
                 from /tmp/libsfml-2.5.1+dfsg/src/SFML/Window/WindowImpl.hpp:35,
                 from /tmp/libsfml-2.5.1+dfsg/src/SFML/Window/EglContext.cpp:30:        
/tmp/libsfml-2.5.1+dfsg/include/SFML/Window/WindowStyle.hpp:39:5: note: to match this{
     {
     ^                                          
In file included from /usr/include/X11/Xlib.h:44,
                 from /usr/include/X11/Xutil.h:53,                            
                 from /tmp/libsfml-2.5.1+dfsg/src/SFML/Window/EGLCheck.hpp:34,  
                 from /tmp/libsfml-2.5.1+dfsg/src/SFML/Window/EglContext.hpp:33,
                 from /tmp/libsfml-2.5.1+dfsg/src/SFML/Window/EglContext.cpp:29:                                                                                                                                                      
/tmp/libsfml-2.5.1+dfsg/include/SFML/Window/WindowStyle.hpp:40:9: error: expected unqualified-id before numeric constant                                                                                                              
         None       = 0,      ///< No border / title bar (this flag and all others are mutually exclusive)
         ^~~~                                                                        
In file included from /tmp/libsfml-2.5.1+dfsg/src/SFML/Window/Unix/CursorImpl.hpp:34,
                 from /tmp/libsfml-2.5.1+dfsg/src/SFML/Window/CursorImpl.hpp:39,
                 from /tmp/libsfml-2.5.1+dfsg/src/SFML/Window/WindowImpl.hpp:35,
                 from /tmp/libsfml-2.5.1+dfsg/src/SFML/Window/EglContext.cpp:30:                              
/tmp/libsfml-2.5.1+dfsg/include/SFML/Window/WindowStyle.hpp:50:1: error: expected declaration before ‘}’ token
 } // namespace sf
 ^                                                                                                                                                                                                                                    
make[2]: *** [src/SFML/Window/CMakeFiles/sfml-window.dir/build.make:271: src/SFML/Window/CMakeFiles/sfml-window.dir/EglContext.cpp.o] Error 1                                                                                          
make[1]: *** [CMakeFiles/Makefile2:176: src/SFML/Window/CMakeFiles/sfml-window.dir/all] Error 2
make: *** [Makefile:130: all] Error 2  
 

I will keep looking, but any help appreciated.

« Last Edit: October 19, 2019, 02:43:10 pm by bluszcz »

bluszcz

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Slow performance with Raspberry PI 3B
« Reply #3 on: October 19, 2019, 11:41:40 pm »
I managed to compile and install SFML with OpenGL ES, game compiles but crashing on the linking, any tips?:

[  2%] Linking CXX executable DeerPortal
/usr/bin/ld: /home/pi/SFML/lib/libsfml-window.so: undefined reference to `sf::priv::SensorImpl::cleanup()'
/usr/bin/ld: /home/pi/SFML/lib/libsfml-window.so: undefined reference to `sf::priv::SensorImpl::update()'

/usr/bin/ld: /home/pi/SFML/lib/libsfml-window.so: undefined reference to `sf::priv::JoystickImpl::getCapabilities() const'
/usr/bin/ld: /home/pi/SFML/lib/libsfml-window.so: undefined reference to `sf::priv::InputImpl::getTouchPosition(unsigned int, sf::Window const&)'

/usr/bin/ld: /home/pi/SFML/lib/libsfml-window.so: undefined reference to `sf::priv::SensorImpl::setEnabled(bool)'
/usr/bin/ld: /home/pi/SFML/lib/libsfml-window.so: undefined reference to `sf::priv::SensorImpl::initialize()'

/usr/bin/ld: /home/pi/SFML/lib/libsfml-window.so: undefined reference to `sf::priv::JoystickImpl::update()'
/usr/bin/ld: /home/pi/SFML/lib/libsfml-window.so: undefined reference to `sf::priv::CursorImpl::~CursorImpl()'

/usr/bin/ld: /home/pi/SFML/lib/libsfml-window.so: undefined reference to `sf::priv::JoystickImpl::isConnected(unsigned int)'
/usr/bin/ld: /home/pi/SFML/lib/libsfml-window.so: undefined reference to `sf::priv::WindowImplRPi::WindowImplRPi(unsigned long)'

/usr/bin/ld: /home/pi/SFML/lib/libsfml-window.so: undefined reference to `sf::priv::WindowImplRPi::WindowImplRPi(sf::VideoMode, sf::String const&, unsigned long, sf::ContextSettings const&)'                                        
/usr/bin/ld: /home/pi/SFML/lib/libsfml-window.so: undefined reference to `sf::priv::InputImpl::setMousePosition(sf::Vector2<int> const&, sf::Window const&)'

/usr/bin/ld: /home/pi/SFML/lib/libsfml-window.so: undefined reference to `sf::priv::InputImpl::setMousePosition(sf::Vector2<int> const&)'
/usr/bin/ld: /home/pi/SFML/lib/libsfml-window.so: undefined reference to `sf::priv::VideoModeImpl::getFullscreenModes()'

/usr/bin/ld: /home/pi/SFML/lib/libsfml-window.so: undefined reference to `sf::priv::InputImpl::isTouchDown(unsigned int)'
/usr/bin/ld: /home/pi/SFML/lib/libsfml-window.so: undefined reference to `sf::priv::CursorImpl::loadFromPixels(unsigned char const*, sf::Vector2<unsigned int>, sf::Vector2<unsigned int>)'
                                           
/usr/bin/ld: /home/pi/SFML/lib/libsfml-window.so: undefined reference to `sf::priv::JoystickImpl::close()'
/usr/bin/ld: /home/pi/SFML/lib/libsfml-window.so: undefined reference to `sf::priv::JoystickImpl::JoystickImpl()'

/usr/bin/ld: /home/pi/SFML/lib/libsfml-window.so: undefined reference to `sf::priv::InputImpl::setVirtualKeyboardVisible(bool)'
/usr/bin/ld: /home/pi/SFML/lib/libsfml-window.so: undefined reference to `sf::priv::JoystickImpl::initialize()'

/usr/bin/ld: /home/pi/SFML/lib/libsfml-window.so: undefined reference to `sf::priv::VideoModeImpl::getDesktopMode()'
/usr/bin/ld: /home/pi/SFML/lib/libsfml-window.so: undefined reference to `sf::priv::InputImpl::getMousePosition(sf::Window const&)'

/usr/bin/ld: /home/pi/SFML/lib/libsfml-window.so: undefined reference to `sf::priv::ClipboardImpl::getString()'
/usr/bin/ld: /home/pi/SFML/lib/libsfml-window.so: undefined reference to `sf::priv::SensorImpl::close()'

/usr/bin/ld: /home/pi/SFML/lib/libsfml-window.so: undefined reference to `sf::priv::SensorImpl::isAvailable(sf::Sensor::Type)'
/usr/bin/ld: /home/pi/SFML/lib/libsfml-window.so: undefined reference to `sf::priv::InputImpl::getMousePosition()'

/usr/bin/ld: /home/pi/SFML/lib/libsfml-window.so: undefined reference to `sf::priv::InputImpl::isMouseButtonPressed(sf::Mouse::Button)'
/usr/bin/ld: /home/pi/SFML/lib/libsfml-window.so: undefined reference to `sf::priv::JoystickImpl::cleanup()'

/usr/bin/ld: /home/pi/SFML/lib/libsfml-window.so: undefined reference to `sf::priv::InputImpl::getTouchPosition(unsigned int)'
/usr/bin/ld: /home/pi/SFML/lib/libsfml-window.so: undefined reference to `sf::priv::SensorImpl::open(sf::Sensor::Type)'

/usr/bin/ld: /home/pi/SFML/lib/libsfml-window.so: undefined reference to `sf::priv::InputImpl::isKeyPressed(sf::Keyboard::Key)'
/usr/bin/ld: /home/pi/SFML/lib/libsfml-window.so: undefined reference to `sf::priv::JoystickImpl::open(unsigned int)'

/usr/bin/ld: /home/pi/SFML/lib/libsfml-window.so: undefined reference to `sf::priv::ClipboardImpl::setString(sf::String const&)'
/usr/bin/ld: /home/pi/SFML/lib/libsfml-window.so: undefined reference to `sf::priv::JoystickImpl::getIdentification() const'

/usr/bin/ld: /home/pi/SFML/lib/libsfml-window.so: undefined reference to `sf::priv::CursorImpl::loadFromSystem(sf::Cursor::Type)'
/usr/bin/ld: /home/pi/SFML/lib/libsfml-window.so: undefined reference to `sf::priv::CursorImpl::CursorImpl()'

collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/DeerPortal.dir/build.make:584: DeerPortal] Error 1
make[1]: *** [CMakeFiles/Makefile2:73: CMakeFiles/DeerPortal.dir/all] Error 2
make: *** [Makefile:152: all] Error 2
 

bluszcz

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Slow performance with Raspberry PI 3B
« Reply #4 on: October 20, 2019, 11:31:19 am »
Okay, after advise on IRC I compiled master version. Performance jumped directly to min 25  fps! I needed only replace Quads with TriangleFan. Thanks.
« Last Edit: October 20, 2019, 11:33:50 am by bluszcz »