# Which hardware for SDL2? =\> bad performances on RaspberryPI2 SOLVED

**URL:** <https://discourse.libsdl.org/t/which-hardware-for-sdl2-bad-performances-on-raspberrypi2-solved/23408>\
**Category:** SDL Development\
**Created:** [November 15, 2017, 1:04pm UTC](https://discourse.libsdl.org/t/which-hardware-for-sdl2-bad-performances-on-raspberrypi2-solved/23408 "2017-11-15T13:04:55Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlBo](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/a/a87d85/32.png) [@AlBo](https://discourse.libsdl.org/u/AlBo)\
**Post date:** [November 15, 2017, 1:04pm UTC](https://discourse.libsdl.org/t/which-hardware-for-sdl2-bad-performances-on-raspberrypi2-solved/23408/1 "2017-11-15T13:04:55Z")

</div>

Hello,

I made a quite frustrating attempt few months ago with SDL2 (2.0.3) on RaspberryPI2 and other similar ARM architecture and I have some doubts that things changed a lot in 2.0.7.

So now, I’m looking for hardware for Linux industrial embedded application where I get chance to comfortably execute SDL2 in 2D accelerated mode.

Any idea?

Regards,  
Al

---

<div class="post-metadata">

**Author:** ![rtrussell](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/rtrussell/32/4768_2.png) [@rtrussell](https://discourse.libsdl.org/u/rtrussell)\
**Post date:** [November 15, 2017, 6:14pm UTC](https://discourse.libsdl.org/t/which-hardware-for-sdl2-bad-performances-on-raspberrypi2-solved/23408/2 "2017-11-15T18:14:32Z")

</div>

> [@AlBo](#):
>
> I made a quite frustrating attempt few months ago with SDL2 (2.0.3) on RaspberryPI2

I find it works quite well on a Raspberry Pi 3 under X11 (with the SDL available from the Raspbian repository) but it is essential to enable the ‘experimental’ VC4 GL Driver in order to take advantage of hardware acceleration. I would call this approach “comfortable” because it’s not necessary to rebuild SDL from source.

---

<div class="post-metadata">

**Author:** ![AlBo](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/a/a87d85/32.png) [@AlBo](https://discourse.libsdl.org/u/AlBo)\
**Post date:** [November 16, 2017, 8:42am UTC](https://discourse.libsdl.org/t/which-hardware-for-sdl2-bad-performances-on-raspberrypi2-solved/23408/3 "2017-11-16T08:42:01Z")

</div>

Hi rtrussell,

We had this discussion few month ago [here](https://discourse.libsdl.org/t/sdl2-performances-on-raspberrypi/22992/5).

Do you finally run it on Stretch or Jessie?  
And do you it on Pi2 or Pi3?

Al

---

<div class="post-metadata">

**Author:** ![rtrussell](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/rtrussell/32/4768_2.png) [@rtrussell](https://discourse.libsdl.org/u/rtrussell)\
**Post date:** [November 16, 2017, 10:04am UTC](https://discourse.libsdl.org/t/which-hardware-for-sdl2-bad-performances-on-raspberrypi2-solved/23408/4 "2017-11-16T10:04:47Z")

</div>

> [@AlBo](#):
>
> Do you finally run it on Stretch or Jessie?  
> And do you it on Pi2 or Pi3?

I’m running Stretch on a Pi3 (the Stretch repository has a later version of SDL than Jessie). Because I’m enabling the VC4 driver the OpenGL (mesa) issues in Stretch - serious as they are - are not directly affecting me.

---

<div class="post-metadata">

**Author:** ![AlBo](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/a/a87d85/32.png) [@AlBo](https://discourse.libsdl.org/u/AlBo)\
**Post date:** [November 16, 2017, 12:58pm UTC](https://discourse.libsdl.org/t/which-hardware-for-sdl2-bad-performances-on-raspberrypi2-solved/23408/5 "2017-11-16T12:58:10Z")

</div>

Ok thanks a lot.  
I’m going to test like that.  
Al

---

<div class="post-metadata">

**Author:** ![AlBo](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/a/a87d85/32.png) [@AlBo](https://discourse.libsdl.org/u/AlBo)\
**Post date:** [November 16, 2017, 6:09pm UTC](https://discourse.libsdl.org/t/which-hardware-for-sdl2-bad-performances-on-raspberrypi2-solved/23408/6 "2017-11-16T18:09:30Z")

</div>

@rtrussell,

That’s a nightmare!!!  
I’d like to verify few infos if you can help me a bit. I’m using a RasberryPI2.

Strangely, AFAIR raspi-config talked about experimental driver in previous Stretch I tested few months ago. Maybe I’m wrong.

Now, in Advanced options-\> GL driver, I can see this:  
G1 GL (Full KMS) OpenGL desktop driver with full kms (this the default choice)  
G2 GL (Fake KMS) OpenGL Desktop driver with Fake  
G3 Legacy …

So it seems it uses the VC4 driver

When I call SDL\_getRendererInfo(), it replies with RendererInfo.flags & SDL\_RENDERER\_ACCELERATED.  
So it seems it initializes the driver as requested in accelerated mode.  
But the application is incredibly slow and the texts (rendered with SDL\_ttf) are not displayed !?!

When I call SDL\_GetRenderDriverInfo, I get:  
SDL\_GetNumVideoDrivers=3  
name=x11  
name=wayland  
name=dummy

Is it correct?  
Any idea?

---

<div class="post-metadata">

**Author:** ![rtrussell](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/rtrussell/32/4768_2.png) [@rtrussell](https://discourse.libsdl.org/u/rtrussell)\
**Post date:** [November 16, 2017, 6:51pm UTC](https://discourse.libsdl.org/t/which-hardware-for-sdl2-bad-performances-on-raspberrypi2-solved/23408/8 "2017-11-16T18:51:59Z")

</div>

> [@AlBo](#):
>
> SDL\_GetNumVideoDrivers=3  
> name=x11  
> name=wayland  
> name=dummy

You should be using the x11 video driver and the OpenGL render driver. I’m using this hint:

```
SDL_SetHint (SDL_HINT_RENDER_DRIVER, "opengl") ;

```

and I’m including `SDL_WINDOW_OPENGL` in the window flags.

This [YouTube video](https://www.youtube.com/watch?v=Ty1qS90Z5yg) should give you an idea of the performance I am getting on the RPi 3. All the programs you see running are using SDL.

---

<div class="post-metadata">

**Author:** ![AlBo](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/a/a87d85/32.png) [@AlBo](https://discourse.libsdl.org/u/AlBo)\
**Post date:** [November 17, 2017, 8:44am UTC](https://discourse.libsdl.org/t/which-hardware-for-sdl2-bad-performances-on-raspberrypi2-solved/23408/9 "2017-11-17T08:44:33Z")

</div>

@rtrussell,

Ok, I’m impressed as a call to SDL\_RenderPresent() for a 800x600 window takes between 600 and 750 ms in my case !!  
Did you install SDL2 2.0.5 from the Raspbian’s apt?

And do you use SDL2 primitives or the OpenGL ones?

Al

---

<div class="post-metadata">

**Author:** ![rtrussell](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/rtrussell/32/4768_2.png) [@rtrussell](https://discourse.libsdl.org/u/rtrussell)\
**Post date:** [November 17, 2017, 9:16am UTC](https://discourse.libsdl.org/t/which-hardware-for-sdl2-bad-performances-on-raspberrypi2-solved/23408/10 "2017-11-17T09:16:24Z")

</div>

> [@AlBo](#):
>
> Did you install SDL2 2.0.5 from the Raspbian’s apt?

Yes.

> [@](#):
>
> And do you use SDL2 primitives or the OpenGL ones?

I’m using SDL2 primitives for 2D. I have also successfully used OpenGL primitives for 3D rendering (again in an SDL framework) as shown in [this video](https://www.youtube.com/watch?v=6UT3XRIJ2r0) .

Richard.

---

<div class="post-metadata">

**Author:** ![AlBo](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/a/a87d85/32.png) [@AlBo](https://discourse.libsdl.org/u/AlBo)\
**Post date:** [November 17, 2017, 9:34am UTC](https://discourse.libsdl.org/t/which-hardware-for-sdl2-bad-performances-on-raspberrypi2-solved/23408/11 "2017-11-17T09:34:43Z")

</div>

@rtrussell

So I’m going to test it on PI3, in case the SDL2/VC4 driver be optimized for this… Strange.  
Because even with your parameters, a SDL\_RenderPresent for a 800x600 window always takes about 600 ms…

Alain

---

<div class="post-metadata">

**Author:** ![AlBo](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/a/a87d85/32.png) [@AlBo](https://discourse.libsdl.org/u/AlBo)\
**Post date:** [November 17, 2017, 9:46am UTC](https://discourse.libsdl.org/t/which-hardware-for-sdl2-bad-performances-on-raspberrypi2-solved/23408/12 "2017-11-17T09:46:42Z")

</div>

@rtrussell  
!!! I have been completely mistaken by raspi-config in fact!!!

Thansk to this [video](https://www.youtube.com/watch?v=-ghJtPR0L1g) automatically displayed after yours, I understood that the first choice shown for GL driver option doesn’t mean that it’s enabled!

So I activated it and now SDL\_RenderPresent() takes 311 us instead of 600 ms !!! Argghhhhh

Many thanks my friend!!!

---

<div class="post-metadata">

**Author:** ![tekman](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/tekman/32/3065_2.png) [@tekman](https://discourse.libsdl.org/u/tekman)\
**Post date:** [November 17, 2017, 9:59am UTC](https://discourse.libsdl.org/t/which-hardware-for-sdl2-bad-performances-on-raspberrypi2-solved/23408/13 "2017-11-17T09:59:28Z")

</div>

Could you, please, give us a code example?  
I did not understand what to add to the code.  
Thanks a lot 👨‍🎓

---

<div class="post-metadata">

**Author:** ![AlBo](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/a/a87d85/32.png) [@AlBo](https://discourse.libsdl.org/u/AlBo)\
**Post date:** [November 17, 2017, 10:06am UTC](https://discourse.libsdl.org/t/which-hardware-for-sdl2-bad-performances-on-raspberrypi2-solved/23408/14 "2017-11-17T10:06:49Z")

</div>

@tekman,

Nothing to add to the code in fact, just do like @rtrussell explained:

```
if (SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl") != SDL_TRUE)
{
	printf("Fail to execute SDL_SetHint %s\n", SDL_GetError());
}

if (SDL_CreateWindowAndRenderer(
		w,
	h,
	SDL_WINDOW_INPUT_FOCUS|SDL_WINDOW_SHOWN|SDL_WINDOW_OPENGL,
	&WID_main_window,
	&WID_main_renderer)) {
    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window and renderer: %s", SDL_GetError());

```

But the key point is to enable the full KMS GL driver with `raspi-config` like shown [here](https://www.youtube.com/watch?v=-ghJtPR0L1g) at 1’34".  
But to really do it, once in the GL Driver menu, be sure to select “OK” and see the message “The full KMS GL driver is enabled”, then reboot.

Alain
