Accelerated pcbnew canvas on etnaviv
etnaviv is the open source GPU driver (in kernel and mesa) for Vivante/Verisilicon IP like GC3000, GC7000 etc. used in NXP i.MX6, i.MX8 and other ARM SoC families. We're building an open hardware laptop based on i.MX8M and we're running KiCAD on it. The current mesa development version yields desktop OpenGL 2.1 and GLES 2.0, which are sufficient for the accelerated canvas of pcbnew. But the "overlay" implementation in KiCAD is currently not compatible because it wants to allocate multiple framebuffers.
OPENGL_COMPOSITOR::CreateBuffer currently errors with:
"Cannot create more framebuffers. OpenGL rendering backend requires at least 3 framebuffers. You may try to update/change your graphic drivers."
I made an experimental patch that works around this problem by no allocating a separate overlay for the framebuffer, but that draws overlay graphics to the mainBuffer as well.
I got the overlay to update correctly (without leaving trails) by calling m_view->MarkDirty() in every call of EDA_DRAW_PANEL_GAL::onPaint(). This is of course more wasteful than the overlay blitting approach, but on i.MX8M this is still a lot faster than using software rendering, and making KiCAD usable on this platform.
This patch is just meant as a proof-of-concept. I'd like some feedback/guidance of how to implement this cleanly as an option/fallback in the case of multiple framebuffers not being supported on a platform. I would like to take this as my issue to work on at the KiCAD development event before FOSDEM on Jan 31st, 2020.
Steps to reproduce
- Get a Linux machine with Vivante/Verisilicon GPU and etnaviv
- In pcbnew, switch on "Accelerated Graphics" in Preferences.
Application: Pcbnew Version: (5.99.0-663-gfd0d5fdb3-dirty), debug build Libraries: wxWidgets 3.0.4 Platform: Linux 5.4.0-rc6-next-20191108+ aarch64, 64 bit, Little endian, wxGTK Build Info: Build date: Jan 8 2020 20:23:27 wxWidgets: 3.0.4 (wchar_t,wx containers,compatible with 2.8) GTK+ 3.24 Boost: 1.67.0 Compiler: GCC 8.3.0 with C++ ABI 1013 Build settings: KICAD_SCRIPTING=OFF KICAD_SCRIPTING_MODULES=OFF KICAD_SCRIPTING_PYTHON3=OFF KICAD_SCRIPTING_WXPYTHON=OFF KICAD_SCRIPTING_WXPYTHON_PHOENIX=OFF KICAD_SCRIPTING_ACTION_MENU=OFF BUILD_GITHUB_PLUGIN=OFF KICAD_USE_OCE=OFF KICAD_USE_OCC=OFF KICAD_SPICE=OFF KICAD_STDLIB_DEBUG=OFF KICAD_STDLIB_LIGHT_DEBUG=OFF KICAD_SANITIZE=OFF