The difficulty with OpenGL on macOS is that all driver interfaces are both 
undocumented and deprecated.


If you want to override the system OpenGL, you can use apitrace code as 
reference.  There are two approaches:

  1.  DYLD_FRAMEWORK_PATH  
https://github.com/apitrace/apitrace/blob/master/cli/cli_trace.cpp
  2.  DYLD_INSERT_LIBRARIES 
https://github.com/apitrace/apitrace/tree/dyld-interpose (experimental branch)


AFAIK, Mesa build for macOS generates a ibGLX which depends on X11, which is 
probably not what you want.  You want to use Mesa for macOS apps which use CGL 
as opposed to GLX, right?


So, if one wants to have a SW renderer on macOS with llvmpipe without depending 
on X11, then one would need to implement:

  *   a new Gallium 
frontend<https://gitlab.freedesktop.org/mesa/mesa/-/tree/main/src/gallium/frontends>
 that implements CGL API (equivalent to the WGL frontend that exists for 
Windows)
  *   a new SW renderer 
winsys<https://gitlab.freedesktop.org/mesa/mesa/-/tree/main/src/gallium/winsys> 
that draws pixels to Cocoa window somehow (equivalent to the GDI winsys that 
draws to a Windows GDI surface)

It's not a matter of just integrating existing components together -- there's 
lot of new code that would be need here -- I'd reckon 2 months for somebody 
familiar with Mesa/macOS, 6 - 12 months for somebody more novice.  And let's be 
frank, given mac deprecation of OpenGL and migration away from Intel to Arm, 
the usefulness of this in the long term is dubious.


Jose

________________________________
From: mesa-dev <mesa-dev-boun...@lists.freedesktop.org> on behalf of Martin 
Pernollet <martin.pernol...@protonmail.com>
Sent: Friday, April 29, 2022 12:32
To: mesa-dev@lists.freedesktop.org <mesa-dev@lists.freedesktop.org>
Subject: Enable OpenGL software rendering on macOS


⚠ External Email

TLDR : I failed using Mesa software rendering on macOS. I am looking for advice 
to invoke mesa's libGL.dylib without relying on macOS's system GL.


Hi everyone,

I am building (java) software involving Mesa for CPU rendering. I use CPU 
rendering as fallback when JOGL (OpenGL binding for Java) fail to use the GPU 
natively. This is sometime the case for old Linux distributions, this will 
certainly be frequent on macOS in the future due to Apple's OpenGL deprecation.

Mesa CPU rendering is working great on Ubuntu (by enabling 
LIBGL_ALWAYS_SOFTWARE=true) and Windows (by simply loading Mesa's DLL instead 
of system DLL, no need to ask for software mode).

I however thrive to use Mesa's software rendering on macOS for the following 
reasons

  *   Spying dynamic library load sequence shows that whenever Mesa's 
libGL.dylib is loaded, Apple Metal and libGL.dylib are loaded before, even when 
using DYLD tricks to ensure Mesa get loaded before any other library (except 
the Java VM) [1] Someone says that Mesa's macOS implementation relies on system 
GL [4]. I noticed that when enabling LIBGL_ALWAYS_SOFTWARE=true, this activates 
Apple software rendering but not Mesa's software rendering [5]. I wonder how I 
could avoid this and use a pure Mesa's OpenGL implementation in this situation.
  *   When getting out of the java World
     *   Running a pre-built glxgear/glxinfo installed through MacPorts only 
allows using Apple's libGL.dylib but not Mesa's libGL.dylib [2].
     *   Building glxinfo myself by linking explicitely to Mesa's GL + X11 lead 
to an X11 error that I am not able to depict [3].

This has been discussed already on Khronos community [1] but I have no clue how 
to go further. I hope some experts here can help me solve this!

Thanks in advance,

Martin

[1] 
https://community.khronos.org/t/failing-to-load-mesa3d-on-macos-instead-of-macos-provided-opengl-library/108408<https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.khronos.org%2Ft%2Ffailing-to-load-mesa3d-on-macos-instead-of-macos-provided-opengl-library%2F108408&data=05%7C01%7Cjfonseca%40vmware.com%7C0282a06768b14d74e2d008da29d3ff8f%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C1%7C637868287773929833%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000%7C%7C%7C&sdata=TCTGtFzds%2FhFJRjrcj4xjALQ5vuZn0X8NekXJxJIF8Y%3D&reserved=0>
[2] 
https://community.khronos.org/t/failing-to-load-mesa3d-on-macos-instead-of-macos-provided-opengl-library/108408/14<https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.khronos.org%2Ft%2Ffailing-to-load-mesa3d-on-macos-instead-of-macos-provided-opengl-library%2F108408%2F14&data=05%7C01%7Cjfonseca%40vmware.com%7C0282a06768b14d74e2d008da29d3ff8f%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C1%7C637868287773929833%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000%7C%7C%7C&sdata=%2Bhy73iogAkMSiYOcSTBXjF8Rh80LBcv%2Ffj7%2B9%2Bm2Tdw%3D&reserved=0>
[3] 
https://community.khronos.org/t/failing-to-load-mesa3d-on-macos-instead-of-macos-provided-opengl-library/108408/19<https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.khronos.org%2Ft%2Ffailing-to-load-mesa3d-on-macos-instead-of-macos-provided-opengl-library%2F108408%2F19&data=05%7C01%7Cjfonseca%40vmware.com%7C0282a06768b14d74e2d008da29d3ff8f%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C1%7C637868287773929833%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000%7C%7C%7C&sdata=MkMiH9Hc9hMSmv0%2FM5Klk4EyouR4OBz3wXk8nP30Q1A%3D&reserved=0>
[4] 
https://community.khronos.org/t/how-to-use-opengl-on-zink-mesa-moltenvk-and-macos/108160/18<https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.khronos.org%2Ft%2Fhow-to-use-opengl-on-zink-mesa-moltenvk-and-macos%2F108160%2F18&data=05%7C01%7Cjfonseca%40vmware.com%7C0282a06768b14d74e2d008da29d3ff8f%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C1%7C637868287773929833%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000%7C%7C%7C&sdata=KkXEuBfzxSBxfZ2oRDGh%2FR6jKc5i9wqiMjcgsmJUoBI%3D&reserved=0>
[5] 
https://community.khronos.org/t/failing-to-load-mesa3d-on-macos-instead-of-macos-provided-opengl-library/108408/17<https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.khronos.org%2Ft%2Ffailing-to-load-mesa3d-on-macos-instead-of-macos-provided-opengl-library%2F108408%2F17&data=05%7C01%7Cjfonseca%40vmware.com%7C0282a06768b14d74e2d008da29d3ff8f%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C1%7C637868287773929833%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000%7C%7C%7C&sdata=YCxes9WhHixFGK73kliu4ELFfMQXoIfbZ%2BeMeU8U1HA%3D&reserved=0>





________________________________

⚠ External Email: This email originated from outside of the organization. Do 
not click links or open attachments unless you recognize the sender.

Reply via email to