<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
The difficulty with OpenGL on macOS is that all driver interfaces are both undocumented and deprecated.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
If you want to override the system OpenGL, you can use apitrace code as reference.  There are two approaches:</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<ol>
<li><span>DYLD_FRAMEWORK_PATH  <a href="https://github.com/apitrace/apitrace/blob/master/cli/cli_trace.cpp">https://github.com/apitrace/apitrace/blob/master/cli/cli_trace.cpp</a></span></li><li style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
DYLD_INSERT_LIBRARIES <a href="https://github.com/apitrace/apitrace/tree/dyld-interpose" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;">https://github.com/apitrace/apitrace/tree/dyld-interpose</a><span style="color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;"> (experimental
 branch)</span></li></ol>
<div> </div>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
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?</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
So, if one wants to have a SW renderer on macOS with llvmpipe without depending on X11, then one would need to implement:</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<ul>
<li>a new <a href="https://gitlab.freedesktop.org/mesa/mesa/-/tree/main/src/gallium/frontends" title="https://gitlab.freedesktop.org/mesa/mesa/-/tree/main/src/gallium/frontends">
Gallium frontend</a> that implements CGL API (equivalent to the WGL frontend that exists for Windows)</li><li>a new <a href="https://gitlab.freedesktop.org/mesa/mesa/-/tree/main/src/gallium/winsys" title="https://gitlab.freedesktop.org/mesa/mesa/-/tree/main/src/gallium/winsys">
SW renderer winsys</a> that draws pixels to Cocoa window somehow (equivalent to the GDI winsys that draws to a Windows GDI surface) </li></ul>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
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.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Jose</div>
<div id="appendonsend"></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> mesa-dev <mesa-dev-bounces@lists.freedesktop.org> on behalf of Martin Pernollet <martin.pernollet@protonmail.com><br>
<b>Sent:</b> Friday, April 29, 2022 12:32<br>
<b>To:</b> mesa-dev@lists.freedesktop.org <mesa-dev@lists.freedesktop.org><br>
<b>Subject:</b> Enable OpenGL software rendering on macOS</font>
<div> </div>
</div>
<div>
<meta name="color-scheme" content="light dark">
<meta name="supported-color-schemes" content="light dark">
<p class="x_external-email-banner" style="background-color: rgb(255, 229, 201); color: black; font-family: Metropolis, "Clarity City", sans-serif; font-size: 14px; border-radius: 4px; padding: 8px; margin: 24px 0px;background-color: rgb(255, 229, 201); color: black; font-family: Metropolis, "Clarity City", sans-serif; font-size: 14px; border-radius: 4px; padding: 8px; margin: 24px 0px;">
<b>⚠ External Email</b></p>
<div>
<div style="font-family:arial; font-size:14px"><span>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.</span>
<div><br>
</div>
<div><br>
</div>
<div>Hi everyone,</div>
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div>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).</div>
<div><br>
</div>
<div>I however thrive to use<span> </span><b>Mesa's software rendering on macOS<span> </span></b>for the following reasons</div>
<div>
<div>
<ul style="margin:0px; padding:0px 0px 0px 2em; font-size:1em">
<li><span><span></span>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] <span>Someone says that Mesa's macOS implementation relies on system GL [4].<span style="background-color:rgb(255,255,255); display:inline!important"> I noticed that when enabling <span style="background-color:rgb(255,255,255); display:inline!important">LIBGL_ALWAYS_SOFTWARE=true,
 this activates Apple software rendering but not Mesa's software rendering [5].</span> </span></span></span>I wonder how I could avoid this and use a pure Mesa's OpenGL implementation in this situation. </li><li><span>When getting out of the java World</span></li><ul style="margin:0px; padding:0px 0px 0px 2em">
<li><span>Running a pre-built glxgear/glxinfo installed through MacPorts only allows using Apple's libGL.dylib but not Mesa's libGL.dylib [2]. </span></li><li><span>Building glxinfo myself by linking explicitely to Mesa's GL + X11 lead to an X11 error that I am not able to depict [3].</span></li></ul>
</ul>
<div><span><br>
</span></div>
</div>
<div><span>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!</span></div>
<div><span><br>
</span></div>
<div><span>Thanks in advance,</span></div>
<div><span><br>
</span></div>
<div><span>Martin</span></div>
<div><span><br>
</span></div>
<div><span>[1] <span><a href="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" data-auth="Verified" originalsrc="https://community.khronos.org/t/failing-to-load-mesa3d-on-macos-instead-of-macos-provided-opengl-library/108408" shash="Clty0oxHQ/DT9+YY9aEimzdgrh0KFyuCKYaGuWS+cPlPL72mxDLo6WJmWaGBImIfEMP0TyHPFYZD7fPPIwd3qzjh/HFHG3Qq9yTTHKIf23zKrFiLjsR82MZcdyvZzIT/UemKsNfm0stiWueNlbvrnSzFKcmsh8qbCp/GqYEqZjI=" style="text-decoration:underline">https://community.khronos.org/t/failing-to-load-mesa3d-on-macos-instead-of-macos-provided-opengl-library/108408</a></span></span></div>
<div><span>[2] <span><a href="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" data-auth="Verified" originalsrc="https://community.khronos.org/t/failing-to-load-mesa3d-on-macos-instead-of-macos-provided-opengl-library/108408/14" shash="qeEAbwpKBpQzg9IBSIJksCq6Flv3RhVv7l0AzWpHOdovdbH9VfjClvjWjvre0VZ9/21zsBIlwEzyLLDoCJFEm2ugGM+wYssuFvjb0rENoCqxyQBbvLDuOPyKOSt+BRHCDmRQxvw8JiZgCQYTdgXnHGfME4ZAwl34KXLpGXxbQjg=" style="text-decoration:underline">https://community.khronos.org/t/failing-to-load-mesa3d-on-macos-instead-of-macos-provided-opengl-library/108408/14</a></span></span></div>
<div><span>[3] <span><a href="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" data-auth="Verified" originalsrc="https://community.khronos.org/t/failing-to-load-mesa3d-on-macos-instead-of-macos-provided-opengl-library/108408/19" shash="ZW7jZHuDGhLD5q7dny1htHFDh5DbuHPQf4EoQLYINqDI5Y369g07kBwEyDR1I8OIu+Adr4jluo3bKNlX8CWAKyKnN0RhDoNIMFGPisa2VS5ogG9CnNdoPD/AaFj3pxLL1nFTT7AqPDS4iig4qPangxEIXMY5vty9hjPok1in1XE=" style="text-decoration:underline">https://community.khronos.org/t/failing-to-load-mesa3d-on-macos-instead-of-macos-provided-opengl-library/108408/19</a></span></span></div>
<div><span>[4] <span><a href="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" data-auth="Verified" originalsrc="https://community.khronos.org/t/how-to-use-opengl-on-zink-mesa-moltenvk-and-macos/108160/18" shash="mjlRrYXw7uDWwse0JFtoWEeDu1pWcUUiftrigFAz7xbJncn5wzFJ5zwYKosBWiYKdMhQ72AdRK/7iMt6F1NICpI4qKUsl9Wx0L7TJDuO+aX1/bCprlLTfnPxwLDAgr9qXgP0BeGUQlLNAdNNarzef6c6m67a/mULJJ87fwseWuw=" style="text-decoration:underline">https://community.khronos.org/t/how-to-use-opengl-on-zink-mesa-moltenvk-and-macos/108160/18</a></span></span></div>
<div>[5] <span><a href="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" data-auth="Verified" originalsrc="https://community.khronos.org/t/failing-to-load-mesa3d-on-macos-instead-of-macos-provided-opengl-library/108408/17" shash="s44nIC1rUCueydj4Pfd9bUu+HblNPNn9ttIBRQEjt4ZjQlwiKjwp9+6SLHhUxQwwIhtuiUHMeZ8r8FM4Lqyq3Ni9zNjSrbZYzc1JfdVj5yHd5pqYWc32mcsTPB/7CvVcERXutpEy2ytLk5BBEnvYdPvA8hP+FqYBr7+4Bx6J/94=" style="text-decoration:underline">https://community.khronos.org/t/failing-to-load-mesa3d-on-macos-instead-of-macos-provided-opengl-library/108408/17</a></span></div>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<span></span><br>
</div>
<div class="x_protonmail_signature_block" style="font-family:arial; font-size:14px">
</div>
</div>
<meta name="color-scheme" content="light dark">
<meta name="supported-color-schemes" content="light dark">
<br>
<hr>
<p class="x_external-email-banner" style="background-color: rgb(255, 229, 201); color: black; font-family: Metropolis, "Clarity City", sans-serif; font-size: 14px; border-radius: 4px; padding: 8px; margin: 24px 0px;background-color: rgb(255, 229, 201); color: black; font-family: Metropolis, "Clarity City", sans-serif; font-size: 14px; border-radius: 4px; padding: 8px; margin: 24px 0px;">
<b>⚠ External Email:</b> This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender.</p>
</div>
</body>
</html>