nagual20
Posts: 4
Joined: Fri Aug 18, 2017 5:24 pm

Please explain RPi video driver / OpenGL relationship

Tue Aug 29, 2017 2:47 pm

I'm working on a framework to make some simple games for my 2.5 year old on RPi 3B. Using SDL2 for sprites and sound. My confusion arises from very poor performance of supposedly hardware-accelerated 2d drawing of even a few dozen textures on the screen. Am I really using hardware acceleration? SDL says I do.

Not using X11 or any desktop environment. All command line.

I'm totally confused by Raspberry Pi video driver architecture / stack.

I would be very grateful for any comments that enhance my understanding of this. Here's what I know / surmise:

* RPi uses Broadcom video chip called VideoCore4.

* There's some sort of built in driver for it (default), then there are two experimental "full kms" and "fake kms" desktop drivers that can be enabled from raspi-config tool. But both break boot process with errors for me, and can make system inaccessible. But these are only for X11 / desktop, right?

* When I'm compiling an SDL application, and dynamically linking to GLESv2 library - the produced binary links to whatever implementation of OpenGL is installed into /usr/lib or whatever - the one bundled with Raspbian is Mesa, right? How do I know if this is hardware accelerated or not?

Any insight into this would be helpful. Thank you.

User avatar
topguy
Posts: 5967
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Please explain RPi video driver / OpenGL relationship

Tue Aug 29, 2017 3:47 pm

Some info on this page: http://elinux.org/Raspberry_Pi_VideoCore_APIs but not sure if its informational or confusing at this stage.

- The experimental OpenGL driver is only for X11 ( afaik )
- What is supported outside X11 is GLES2.0.

The VC4 libraries are in "/opt/vc/lib" so verify with "ldd" command that those are loaded instead of the Mesa ones which I believe are the ones in "/usr/lib/arm....."
( also I think there is a "/opt/vc/include" you should be using during compiling. )

Using "export LD_LIBRARYPATH=/opt/vc/lib" before you start your program might make the linker look there first.

Are you useing Raspbian Stretch or Jessie ?
On Raspbian Stretch the library is called "libbrcmGLESv2.so" and not "libGLESv2.so" as in Jessie.

Not exaclty sure how your SDL is compiled so no clear answers from me, but hopefully some pointers.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7575
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Please explain RPi video driver / OpenGL relationship

Tue Aug 29, 2017 8:36 pm

The Pi firmware (binary blob) supports OpenGLES only. It also has a composition API called DispmanX.
There is an open Linux kernel OpenGL and KMS (composition) driver actively under development.

The OpenGL side can be used either with the kernel KMS driver ("full kms"), or retaining the DispmanX API for composition ("fake KMS"). There are numerous things that can only sensibly be used with the "fake KMS" driver, eg video playback and the camera, as in both cases they directly send images to the composition engine/screen rather than going via the kernel.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

nagual20
Posts: 4
Joined: Fri Aug 18, 2017 5:24 pm

Re: Please explain RPi video driver / OpenGL relationship

Wed Aug 30, 2017 4:02 pm

Thank you.

Very helpful.

Return to “Graphics, sound and multimedia”