Experimentations with OpenVG for hardware accelerated 2D drawing on Raspberry Pi.
Compares direct on-screen rendering, PbufferSurface and PbufferFromClientBuffer.
Relies on Freetype2 library for text drawing with TrueType fonts.
Pictures are saved to PNG files with stb library.
Raspberry Pi Zero W with Raspbian GNU/Linux 10 (buster), kernel 4.19.97.
Image size: 1920x1080.
Draws: ellipse + round rectangle + 2 strings.
A transformation matrix is applied to reverse pixels order according to stbi_write_png()
reading order.
Without pixels copy [1] | With pixels copy [2] | |||
VgFinish | VgFlush | VgFinish | VgFlush | |
onscreen.c | 93.75 i/s, 9.5% CPU | 166.66 i/s, 29% CPU | 24.19 i/s, 39% CPU | 25.21 i/s, 40% CPU |
PbufferSurface.c | 96.77 i/s, 10.5% CPU | 176.47 i/s, 30% CPU | 20.68 i/s, 26.5% CPU | 23.07 i/s, 33% CPU |
PbufferFromClientBuffer.c | 63.49 i/s, 6.5% CPU | 76.92 i/s, 7.8% CPU | 16.39 i/s, 23% CPU | 17.24 i/s, 19% CPU |
[1]: Pictures are only generated.
[2]: Pictures are generated and pixels are stored in memory (vgReadPixels()
for onscreen/PbufferSurface and vgGetImageSubData()
for PbufferFromClientBuffer), stbi_write_png()
is not used in these results.
gcc PbufferSurface.c -O2 -Wall -Werror -L/opt/vc/lib -lbrcmEGL -lbrcmGLESv2 -lbcm_host -I/opt/vc/include -I/opt/vc/include/interface/vmcs_host/linux -I/opt/vc/include/interface/vcos/pthreads -I/usr/include/stb -lstb -I/usr/include/freetype2 -lfreetype -I/usr/include/glib-2.0 -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include -lglib-2.0