


Curiously, when we disassemble shaders compiled with their OpenGL implementation, we don’t see any such emulation. Because Metal uses the 0 to 1 clip space, it should require this emulation code.
#Curtain clips driver#
Like ANGLE, Apple’s OpenGL driver internally translates to Metal. Although this emulation adds overhead, it works for ANGLE’s open source implementation of OpenGL ES on Metal. As Metal uses the 0/1 clip space, implementing OpenGL on Metal requires emulating the -1/1 clip space by inserting extra instructions into the vertex shader to transform the Z coordinate. In OpenGL, however, Z ranges from negative 1 to 1. In every other API on the planet, the Z component (depth) of points in the 3D world range from 0 to 1, where 0 is “near” and 1 is “far”. In the past, I’ve relied on educated guesswork to bridge the gap, but there’s another solution… and it’s a doozy.įor motivation, consider the clip space used in OpenGL. Although Metal uses the same shader pipeline as OpenGL, it doesn’t support all the OpenGL features that the hardware does, which puts us in bind. To implement the modern OpenGL features, we rely on reverse-engineering the behaviour of Apple’s Metal driver, as we don’t have hardware documentation. That’s a win for open source drivers, and a win for GPU acceleration on Asahi Linux. If we implement the modern shader pipeline, Mesa will handle fixed function OpenGL for us transparently. This translation is complicated, but we get it for “free” as an open source driver in Mesa. Instead, the driver synthesizes shaders implementing the desired graphics. Modern GPUs don’t implement these features in hardware. Rather than supply programmable shaders like OpenGL 2, old OpenGL 1 applications configure a fixed set of graphics effects like fog and alpha testing. Neverball uses legacy “fixed function” OpenGL. There’s more to do, but Neverball is already playable (and a lot of fun!). Neverball rendered on the Apple M1 GPU with an open source OpenGL driverĪfter a year in development, the open source “Asahi” driver for the Apple GPU is running real games. Rosenzweig – Clip control on the Apple GPU Clip control on the Apple GPU
