Opened 5 years ago

Closed 5 years ago

#4118 closed enhancement (wontfix)

Add offscreen rendering support for macOS using XQuartz libOSMesa.dylib

Reported by: Tom Goddard Owned by: Tom Goddard
Priority: moderate Milestone:
Component: Graphics Version:
Keywords: Cc:
Blocked By: Blocking:
Notify when closed: Platform: all
Project: ChimeraX

Description

Would be nice to have offscreen rendering when using ChimeraX as a python module on macOS. It only needs libOSMesa. We only compile that library for Linux. On macOS the XQuartz distribution (X11 server) is said to include libOSMesa so that would be an easy way to get it. Would not need to distribute anything with ChimeraX, just have our offscreen code look in /opt/X11/lib on Mac.

Change History (2)

comment:1 by Tom Goddard, 5 years ago

I tried offscreen rendering on macOS 10.15 using /opt/X11/lib/libOSMesa.dylib provided by XQuartz 2.7.11 (2016, most recent). First I needed to edit PyOpenGL to find the library

ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/OpenGL/platform/ctypesloader.py

in routine loadLibrary() add

elif sys.platform == 'darwin':

filename = '/opt/X11/lib/libOSMesa.dylib'
return dllType(filename, mode)

Running ChimeraX with --offscreen then gives message "OSMesa needs to be configured with --enable-gallium-osmesa for OpenGL Core Context support.". This error message really just means OSMesa could not provide the requested context. Changing the requested attributes in graphics/opengl.py OffScreenRenderingContext.init() to not request version 3.3 and not request core profile as follows

attribs = [

osmesa.OSMESA_FORMAT, osmesa.OSMESA_RGBA,
osmesa.OSMESA_DEPTH_BITS, 32,
# osmesa.OSMESA_STENCIL_BITS, 8,

# osmesa.OSMESA_PROFILE, osmesa.OSMESA_CORE_PROFILE,
# osmesa.OSMESA_PROFILE,
# osmesa.OSMESA_CONTEXT_MAJOR_VERSION, 3,
# osmesa.OSMESA_CONTEXT_MINOR_VERSION, 3,

0 # must end with zero

]

it gets a context but it is version OpenGL 2.1 and ChimeraX needs 3.3. Asking for major version 3 returns None for he contet. Asking for core context with no version also returns None.

So it appears the XQuartz 2.7.11 version of libOSMesa.dylib can only provide legacy contexts and only version 2.1.

Would need to compile osmesa on Mac to make this work.

comment:2 by Tom Goddard, 5 years ago

Resolution: wontfix
Status: assignedclosed

Unfortunately XQuartz was last updated in 2016 and the libOSMesa.dylib it provides seems only able to provide OpenGL 2.1 and not core OpenGL contexts.

I did not see any other macOS distributions of libOSMesa so we would need to compile and distribute it ourselves. I don't think it is worth that effort.

Note: See TracTickets for help on using tickets.