[Tutorial] How to get the best performance from LÖVE on Raspberry Pi
Posted: Tue Sep 25, 2018 9:03 am
EDIT: the project I had to build LÖVE on Raspberry for.
Hi there! I thought I'd share how I recently built LÖVE for the Raspberry Pi with the best performance (or at least the best I've been able to achieve). I did this on a Raspberry Pi 2B running Raspbian Jessie Lite (command prompt only).
I'm working on an emulator (Retroarch) frontend for Raspbian, so it runs fullscreen when the RPi boots (link to the project at the beginning of this post). Instead of a step by step guide, I'll tell all the things I tried until I reached the best results. I might miss some small problems I had during the process but the most important is here.
FIRST ATTEMPT
The first time, I was using Raspbian Jessie (with graphical UI) and just followed LÖVE's build guide: https://love2d.org/wiki/Building_L%C3%96VE
The demo worked horribly (choppy framerate, no baloon, clouds as white pixelated textures...).
I then read that you could enable some experimental OpenGL drivers to make it work better (https://eltechs.com/how-to-enable-openg ... pberry-pi/). The demo worked very well. My app, not that well (and it's been pretty optimized in the last months). I tried overclocking as well. Didn't get to more than 45FPS on windowed mode.
Then I tried on fullscreen. It was worse as the app was 1280x720 and was upscaling to 1920x1080. I had to change the Raspberry Pi HDMI output resolution to 1280x720.
SECOND ATTEMPT: RASPBIAN JESSIE LITE
Before changing resolution, I decided to switch to Raspbian Jessie Lite, just in case it helps performance a bit (not sure, honestly). I followed the building LÖVE guide again and enabled the OpenGL driver again. Still not very good performance.
Went to change output to 1280x720.
Advanced Settings->Resolution. I chose "CEA Mode 4 1280x720 60Hz 16:9", then rebooted.
THIRD ATTEMPT: BUILD LÖVE TO USE OPENGLES
By this time I read somewhere in the forums that building LÖVE like:
would add the variable to the binary so you don't need to set it when you run love. I'm not sure if this is right as I was testing a few things at the same time, but I certainly didn't have to run LÖVE like "LOVE_GRAPHICS_USE_OPENGLES=1 love myapp.love" anymore, and that's the only way it could have happened.
After this, I think I reached ~53fps. Not enough yet. Then I tried running retroarch. It wouldn't run with the OpenGL driver enabled, so I need another solution without it.
FOURTH ATTEMPT: BUILD SDL TO USE OPENGLES
A friend of mine told me my problem could be that the LibSDL I got with apt-get wasn't built to use OpenGLES backend. So I uninstalled it and followed this tutorial to get SDL built to use OpenGLES:
https://solarianprogrammer.com/2015/01/ ... ted-sdl-2/
When the author explains how to get SDL:
I replaced SDL2-2.0.3.tar.gz with the latest (currently SDL2-2.0.8.tar.gz), found here: https://www.libsdl.org/download-2.0.php
Once finished building, I kept following the tutorial to build SDL_image, SDL_ttf and SDL_mixer, although I haven't checked if it's actually necessary.
The next part of the tutorial was writing a simple SDL program to test if everything went ok. You can skip this and directly build LÖVE, then test if it works.
But now I had another problem:
To fix this, I found this link (https://bitbucket.org/rude/love/issues/ ... gic-failed) which said I only had to create a file "ditlist" in "/usr/share/aclocal/" containing only "/usr/local/share/aclocal".
So I built LÖVE and tried the demo, and it was perfectly smooth. I then tried my app and I could get 100fps disabling vsync.
I could also launch Retroarch as I wasn't using the experimental OpenGL driver. Now it was just a matter of making my app run retroarch and load a game through command line.
EPILOGUE: BUILDING RETROARCH WITH THE BEST PERFORMANCE
I followed this guide to download and build Retroarch for the Raspberry Pi with the best results: https://gist.github.com/AlexMax/32e5d03 ... ea75736805
At
I changed "https://github.com/libretro/RetroArch/a ... 3.6.tar.gz" to "https://github.com/libretro/RetroArch/a ... 7.4.tar.gz", found here: https://github.com/libretro/RetroArch/releases
The most important thing is the configure step:
Retroarch worked fine, although some Mega Drive games had occasional intense fps drops. I fixed that by enabling "Video threaded" option and making sure the RPi was overclocked. From then, I could even use the "crt-pi.glslp" CRT shader and performance was perfect. Of course, having the output set to 1280x720 helped.
Hi there! I thought I'd share how I recently built LÖVE for the Raspberry Pi with the best performance (or at least the best I've been able to achieve). I did this on a Raspberry Pi 2B running Raspbian Jessie Lite (command prompt only).
I'm working on an emulator (Retroarch) frontend for Raspbian, so it runs fullscreen when the RPi boots (link to the project at the beginning of this post). Instead of a step by step guide, I'll tell all the things I tried until I reached the best results. I might miss some small problems I had during the process but the most important is here.
FIRST ATTEMPT
The first time, I was using Raspbian Jessie (with graphical UI) and just followed LÖVE's build guide: https://love2d.org/wiki/Building_L%C3%96VE
The demo worked horribly (choppy framerate, no baloon, clouds as white pixelated textures...).
I then read that you could enable some experimental OpenGL drivers to make it work better (https://eltechs.com/how-to-enable-openg ... pberry-pi/). The demo worked very well. My app, not that well (and it's been pretty optimized in the last months). I tried overclocking as well. Didn't get to more than 45FPS on windowed mode.
Then I tried on fullscreen. It was worse as the app was 1280x720 and was upscaling to 1920x1080. I had to change the Raspberry Pi HDMI output resolution to 1280x720.
SECOND ATTEMPT: RASPBIAN JESSIE LITE
Before changing resolution, I decided to switch to Raspbian Jessie Lite, just in case it helps performance a bit (not sure, honestly). I followed the building LÖVE guide again and enabled the OpenGL driver again. Still not very good performance.
Went to change output to 1280x720.
Code: Select all
sudo raspi-config
THIRD ATTEMPT: BUILD LÖVE TO USE OPENGLES
By this time I read somewhere in the forums that building LÖVE like:
Code: Select all
LOVE_GRAPHICS_USE_OPENGLES=1 sudo make -j4
After this, I think I reached ~53fps. Not enough yet. Then I tried running retroarch. It wouldn't run with the OpenGL driver enabled, so I need another solution without it.
FOURTH ATTEMPT: BUILD SDL TO USE OPENGLES
A friend of mine told me my problem could be that the LibSDL I got with apt-get wasn't built to use OpenGLES backend. So I uninstalled it and followed this tutorial to get SDL built to use OpenGLES:
https://solarianprogrammer.com/2015/01/ ... ted-sdl-2/
When the author explains how to get SDL:
Code: Select all
1 cd ~
2 wget https://www.libsdl.org/release/SDL2-2.0.3.tar.gz
3 tar zxvf SDL2-2.0.3.tar.gz
4 cd SDL2-2.0.3 && mkdir build && cd build
Once finished building, I kept following the tutorial to build SDL_image, SDL_ttf and SDL_mixer, although I haven't checked if it's actually necessary.
The next part of the tutorial was writing a simple SDL program to test if everything went ok. You can skip this and directly build LÖVE, then test if it works.
But now I had another problem:
Code: Select all
configure.ac:49: error: possibly undefined macro: AM_PATH_SDL2
So I built LÖVE and tried the demo, and it was perfectly smooth. I then tried my app and I could get 100fps disabling vsync.
I could also launch Retroarch as I wasn't using the experimental OpenGL driver. Now it was just a matter of making my app run retroarch and load a game through command line.
EPILOGUE: BUILDING RETROARCH WITH THE BEST PERFORMANCE
I followed this guide to download and build Retroarch for the Raspberry Pi with the best results: https://gist.github.com/AlexMax/32e5d03 ... ea75736805
At
Code: Select all
wget 'https://github.com/libretro/RetroArch/archive/v1.3.6.tar.gz'
tar zxvf RetroArch-1.3.6.tar.gz
cd RetroArch-1.3.6
The most important thing is the configure step:
Code: Select all
./configure --enable-alsa --enable-udev --enable-floathard --enable-neon --enable-dispmanx