Skip to content

Conversation

@pkrack
Copy link
Collaborator

@pkrack pkrack commented Jun 13, 2025

to support headless rendering (e.g. on HPC) we need to use EGL to create a graphics context and cannot link against GLFW.

This PR solves both:

  • We create the EGL context in python using mujocos mujoco.egl.GLContext helper.
  • We locate and dlopen libEGL in python using ctypes and pass the context, eglMakeCurrent function pointer to c++
  • In C++ we just ensure that the context is current by calling the function pointer with the context pointer whenever we need to render.
  • We remove all glfw code by using mujoco.viewer.launch_passive in a separate python process. As before the separate process reads simulation state from shared memory.

pkrack added 6 commits June 12, 2025 18:55
First we now use EGL for rendering enabling headless for HPC.

We do not link against glfw nor egl anymore. Instead we find and load
the required libraries dynamically on the python side (cf.
egl_bootstrap.py).

There is only one rendering context, created in python. We just pass the
function to make it current to the C++ side and the C++ extension can
just call that.

Finally remove the custom renderer: We keep the shared memory approach,
just remove the gui implement in C++. Instead we can use
mujoco.viewer.launch_passive in a new process to get the full simulate
GUI (without interaction).
@pkrack pkrack requested a review from juelg June 13, 2025 14:59
@juelg juelg linked an issue Jun 16, 2025 that may be closed by this pull request
@juelg juelg marked this pull request as ready for review June 16, 2025 12:35
@juelg juelg merged commit af2e506 into master Jun 16, 2025
4 checks passed
@juelg juelg deleted the krack/egl branch June 16, 2025 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for Environments without X-Server

3 participants