One task today was optimizing the OpenGL driver so SuperTuxKart would be playable. On Lina's latest stream, she tried to play SuperTuxKart, but it was just too slow.
Why? Every time the application wants to access GPU memory, the driver needs to synchronize access between the CPU and GPU. On a tiler GPU, like Apple's, that synchronization is expensive because it requires flushing out drawing commands. Fortunately, we can skip most of the flushing with some careful driver accounting. With that optimization, SuperTuxKart still works... but now it's fast! β¨β
@lina @dougall Another task was getting X11 applications working. On Lina's latest stream, she could try to open X11 applications like xterm and urxvt, but they were unusably glitchy! After getting SuperTuxKart running, I turned to debugging why.
It turns out the culprit was glPointSize(). In OpenGL ES, any time an application renders points, it has to write out the point size as a special variable in the vertex shader. But in OpenGL, the application can omit the write and instead set the point size on the CPU with a glPointSize() call.
Currently, the Asahi Mesa driver handles gl_PointSize variable writes but not glPointSize calls. But that doesn't mean all points will have a "default" size... they'll have undefined sizes! The hardware will read out a variable that's never written, and havoc ensues.
Fortunately, this issue is easy to workaround. All we need to do is add a gl_PointSize write into the vertex shader whenever we see a glPointSize call. Mesa even has common code to do this, we just need to opt-in to using it like Zink does (since layering OpenGL-on-Vulkan has the same problem). So with a single line of code inserted, X11 applications work. Not just xterm and urxvt -- entire desktop environments like MATE seem to render ok, although there's lots of low-hanging performance work to go.
All in all, a good day for Apple GPUs!
@lina @dougall Another task was getting X11 applications working. On Lina's latest stream, she could try to open X11 applications like xterm and urxvt, but they were unusably glitchy! After getting SuperTuxKart running, I turned to debugging why.
It turns out the culprit was glPointSize(). In OpenGL ES, any time an application renders points, it has to write out the point size as a special variable in the vertex shader. But in OpenGL, the application can omit the write and instead set the point size...