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

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

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.

Hi rtrussell,

We had this discussion few month ago here.

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

Al

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.

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

@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?

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 should give you an idea of the performance I am getting on the RPi 3. All the programs you see running are using SDL.

@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

Yes.

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 .

Richard.

@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

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

Thansk to this video 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!!!

1 Like

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

@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 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