Skip to content

egl: Query available priorities at context creation time

Carlos Garnacho requested to merge carlosg/mesa:context-priority-on-threads into main

Querying those once at screen setup time might yield the wrong results if there are EGLContexts being created at a separate thread with differing capabilities than the one calling eglInitialize().

There's two ways in which it may go wrong:

  • The eglCreateContext thread has capabilities, but the thread where eglInitialize was called did not: The priority will be silently ignored, despite the ioctl still being able to succeed there.
  • The eglInitialize thread had capabilities at the time of being called, but the eglCreateContext thread does not preserve them: The context will try to set the ioctl, but fail hard, and result on no context being created. This seems to go against EGL_IMG_context_priority extension.

It seems a better way that would provide the right results on mixed threads with different capabilities is to query the allowed values at context creation time. At this moment we can still reset the user-set priority on failure (as future queries should return the assigned priority), and be sure that the value is handled relative to the calling thread.

Also, drop a comment that no longer really applies after this change.

--

NB: This comes from https://gitlab.gnome.org/GNOME/mutter/merge_requests/923 where we are trying to make sure mutter/gnome-shell drops CAP_SYS_NICE ASAP while still keeping high priority contexts possible. Keeping the capability may bring some risks, and some libraries don't like it much at all (eg. https://gitlab.gnome.org/GNOME/glib/issues/1928).

Merge request reports