Pengutronix TechWeek 2018: NIR for Etnaviv
Once in a year, mostly during springtime, no phone call is answered at Pengutronix, no customer Mail receives a reply, no BSP is built and no coffee machine gargles. But, no fear, this is not the end! It is just the time for something new! New ideas, focused development on new world domination plans and time to think outside the box. Yes, it's again the time for the Pengutronix TechWeek!
As every year, we hid in a green and isolated place with acceptable bandwidth and good catering. The perfect mixture for focused hacking, starting new projects and discussing the big picture.
Thanks to Freifunk Braunschweig, we could set up our own WiFi infrastructure. Besides that we enjoyed ourselves at a trip to Wisentgehege Springe, a local nature park, and on a pgp-keysigning party as well as on a BBQ.
But back to topic: On Friday morning, we had some short talks to share each team's results among our colleagues. In this and some following blog posts, we like to summarize these here as well.
Let's start with some news from our graphics team: During TechWeek 2017, Philipp Zabel and Michael Tretter had taken the first steps towards extending the etnaviv driver in Mesa with NIR compiler support. NIR is a compiler intermediate representation that is well suited for optimizing code transformations and is already used by many other Mesa drivers. Supporting NIR allows to share common optimizations with other drivers and facilitates better register allocation strategies.
Overall this will lead to faster shader code that runs in less instructions and uses fewer registers. Furthermore, using the shared NIR compiler layer will allow to work on common support for OpenCL and SPIR-V in the future.
Philipp and Michael were able to continue their work compiling NIR shaders from the GLSL compiler to Vivante machine code. The screenshot on the right shows one of the glmark2 programs, exposing some visual artefacts resulting from a still-incomplete NIR support; the work consisted of analyzing those artefacts, finding and finally fixing the reasons in the code.
While the code is far from feature complete, the current state looked promising enough that a first patch series was cleaned up and sent to the Mesa-developer ML. Hopefully people out in the community will start experimenting with the new possibilities, finding further bugs, adding features and extending the NIR support in Etnaviv.
For a TechWeek project, the challenge and fun of it was enough motivation. Thinking of future use, Etnaviv has meanwhile reached a maturity status that already enabled its use in many of our industrial customer projects, even in critical markets such as medical, automotive and aerospace. OpenCL on a full blown open source graphics stack will hopefully add interesting additional possibilities in the near future.