How to use OpenGL on Zink, Mesa, MoltenVK, and macOS

Software rendering is just a backend driver. Once you have them working you can select what ever you like. Admittedly there is little point in select something like the INTEL or AMD drivers, but software rasterisers or Zink are then possible.

My goal is to compute OpenGL with a C/C++ software that will only run in CPU and provide an image to display in an app. This works well on Ubuntu and Windows for which I get a llvmpipe renderer. The point is to use Mesa’s software rasterizer when JOGL (a Java OpenGL binding) fail to access native/OS GL.

There is a platform define that ends in APPLEGL, IIRC

I indeed found
GLX_USE_APPLEGL in src/glx/apple_glx.c and several src/glx/apple/apple_glx_*.c files. The flag is set there, which let me think that Mesa won’t call Apple GL if compilation has options with_glx == 'xlib' or with_glx == 'gallium-xlib' (which is conform to what the doc says).

I however exactly followed these instructions and built mesa with -Dosmesa=true -Dglx=xlib -Dgallium-drivers=swrast, so I would expect the whole Apple GL code to be bypassed, which is not

# Force my mesa build before Apple's one
export DYLD_INSERT_LIBRARIES=/Users/martin/Dev/jzy3d/external/osmesa/lib/libGL.dylib
# Force CPU rendering
export LIBGL_ALWAYS_SOFTWARE=true
# Print info on selected GL renderer
glxinfo | head -n 50

yields to the following output

client glx vendor string: Mesa Project and SGI
client glx version string: 1.4
...
OpenGL vendor string: Apple Inc.
OpenGL renderer string: Apple Software Renderer
OpenGL version string: 2.1 APPLE-18.5.9
OpenGL shading language version string: 1.20

whereas I would expect

OpenGL renderer string: llvmpipe

I found no IIRC string in the project.

IIRC was not a string in the code, it was a “If I Remember Correctly” (IIRC) comment. Sorry. :grinning:

The GLX_USE_APPLEGL will get you the control over the display system. There is extra that also needs to be done to switch the GL function pointers and use the MESA drivers, but I really need to look it up to figure out what those changes are. As I can never remember and it always takes me a while to find the change again.

1 Like

I have not had chance to check the new code, but this article claims Windows is calling through to Zink. Hopefully MacOS code is either also working or just needs a similar set of tweeks.

https://www.phoronix.com/scan.php?page=news_item&px=Zink-Windows-Kopper-Progress

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.