0

I migrated a small SDL2 project to my raspberry pi and the performance was just awful.

On frames with less textures to render, it runs beyond 60fps. Otherwise, the CPU skyrockets to >90% and the framerate drops pretty hard.

I was wondering what changes could be made to improve rendering efficiency:

  • What flags/options/etc. in SDL2 work best for the Raspberry Pi?
  • Would Blitting be better for the Pi?
  • Are there other libraries that work with SDL2 which could help improve rendering efficiency on the Pi?
  • Rendering is computationally expensive what type of performance do you expect with a PI and 1GB of memory? – Steve Robillard Jan 4 '17 at 3:12
1

This will only work for Raspberry Pi 2, or 3.

In order for SDL2 to render using hardware acceleration, you need to activate OpenGL, the GL driver is disabled by default, because the driver is experimental and a bit wonky/crashy.

To use the OpenGL driver:
1. First make sure everything is up to date:

sudo apt-get update
sudo apt-get upgrade

2. Next, install the driver:

sudo apt-get install mesa-utils

3. Now, to activate the driver:

raspi-config

Navigate to Advanced Options>GL Driver, enable.
4. Reboot your Pi.
5. Make sure your game has the following flags:

  • In your SDL_Window you do not need the flag SDL_WINDOW_OPENGL for your game to run under OpenGL. I'd recommend you put whatever flags you want here.

  • In your SDL_Renderer, I'd recommend SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED.

Source: https://www.raspberrypi.org/blog/another-new-raspbian-release/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.