SDL 2 2D hardware acceleration on Raspberry Pi |
Hop
|
Is it possible to use SDL2 with 2D hardware accelerated rendering on Raspberry Pi?
If 2D hardware accelerated rendering is possible on the device, how do you check to see that your application is using hardware acceleration? i.e. How do you ensure that SDL2 and the application are set up correctly to use OpenGL ES 2.0? I have built SDL2 from source configured with as described in this post: https://solarianprogrammer.com/2015/01/22/raspberry-pi-raspbian-getting-started-sdl-2/ In short:
I believe the configure step should prevent SDL from using a software implementation of OpenGL, and force it to use an OpenGL ES backend, which is supported by the hardware. I hope this implies that any 2D render calls (e.g. SDL_DrawRect) call through to the OpenGL ES API so access the GPU and are therefore hardware accelerated. When configure runs it states that it has found the OpenGL ES v1 and v2 headers, and lists Video drivers : dummy, opengl_es1 and opengl_es2 I'm using a very simple Tetris clone as a test case. The application's naive render function consists of drawing each of the 200 32x32 pixel squares that make up the board in turn to a 1280x720 buffer. Each square requires 2 calls to SDL_SetRenderDrawColor a call to SDL_RenderDrawRect and SDL_RenderFillRect. It is initialised like so:
and built with:
This runs at about 15 FPS, which strikes me as extremely slow and makes me think that software rendering is in use. Is there any other set-up/initialisation required in the application to ensure that the GLES backend is used? Is there anyway to check at runtime that the renderer is using hardware acceleration? To be clear: I don't actually want to use the GL API at all, I just want to use the SDL 2D Render API, ensuring that the rendering happens in hardware and not software. Many thanks! |
|||||||||||||||||
|
Hop
|
I managed to get a little further with this (I already posted this response over on http://raspberrypi.stackexchange.com/questions/37096/sdl2-performance/37120#37120
> Is it possible to use SDL2 with 2D hardware accelerated rendering on Raspberry Pi? > Is there anyway to check at runtime that the renderer is using hardware acceleration? Yes and yes. It seems that this method is actually producing an executable that uses SDL2 with an OpenGLES 2 backend. This can be confirmed by adding some code:
This produces the following output:
It seems that the performance of the application is limited by the number of SDL_RenderDraw*Rect calls. This is a little disappointing. The application in question is at https://github.com/howprice/sdl2-tetris |
|||||||||||||||
|