Const.me
Posts: 9
Joined: Sat Mar 14, 2020 6:30 pm

How to enable GPU?

Sat Mar 14, 2020 7:41 pm

GLES 3.1 appears to work OK atop of DRM/KMS, GBM, EGL, however it uses software rasterizer. eglGetDisplayDriverName returns “kms_swrast”, glGetString( GL_RENDERER ) returns “llvmpipe (LLVM 9.0.1, 128 bits)”

The kmscube example behaves the same way. Specifically, the original code from MESA fails at runtime. But I was able to compile and run the version specifically patched for Pi4, found somewhere on this forum, I’ve modified it locally to call eglGetDisplayDriverName() and print the result. Renders OK but again I've got “kms_swrast”.

How do I enable the hardware GPU?

Using Pi4, running the officially supported OS build, Raspbian Buster Lite.

Thanks in advance.

Const.me
Posts: 9
Joined: Sat Mar 14, 2020 6:30 pm

Re: How to enable GPU?

Tue Mar 17, 2020 1:41 am

It’s a Raspbian configuration bug. Out of the box, here’s the permission on GPU endpoints:

Code: Select all

ls -la /dev/dri
total 0
drwxr-xr-x  3 root root        120 Mar 15 20:24 .
drwxr-xr-x 17 root root       3840 Mar 15 20:24 ..
drwxr-xr-x  2 root root        100 Mar 15 20:24 by-path
crw-rw----  1 root video  226,   0 Mar 15 20:24 card0
crw-rw----  1 root video  226,   1 Mar 15 20:24 card1
crw-rw----  1 root render 226, 128 Mar 15 20:24 renderD128
By default, the pi user is a member of video group, but not a member of render group. It can switch video modes just fine, however 3D rendering access is denied, and GLES falls back to software rendering. Horribly slow, of course.

Here’s an easy fix:

Code: Select all

sudo usermod -a -G render pi

User avatar
PeterO
Posts: 5829
Joined: Sun Jul 22, 2012 4:14 pm

Re: How to enable GPU?

Tue Mar 17, 2020 8:13 am

On my Pi4 it returns "eglDriverName=vc4"
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

Return to “OpenGLES”