Page MenuHome

GHOST/Wayland: dynamic loading support for libwayland-* (WITH_GHOST_WAYLAND_DYNLOAD)
AbandonedPublic

Authored by Campbell Barton (campbellbarton) on Jun 21 2022, 12:55 PM.

Details

Summary

Add CMake option WITH_GHOST_WAYLAND_DYNLOAD which loads libwayland-{egl/cursor/client} at run-time.

Needed so official releases can be built with Wayland without preventing Blender from starting on systems that don't have wayland libraries installed.

Note that there was one complication with wl_proxy_marshal_flags which is a variadic function that doesn't have a version that takes a va_list.
As far as I can see it's not possible to wrap these functions without resorting to overly complex & non-portable solutions.
Instead a workaround that replaces functions that use variadic arguments needs to be included immediately after <libwayland-client.h>.

Tested with gcc-12.1 and clang-13.0.1.


Other notes:

  • This wrapper library needs to be updated by hand, although the core of Wayland used by Blender is quite small (20 functions & 15 interfaces).

    Generated API's such as tablet-support make use of existing primitive functions, so supporting additional extension API's isn't likely to increase the number of API calls.

    It may still be good to updating this wrapper automatically from headers.
  • I was hoping to make this more generic (similar to extern/sdlew for example), however the workaround needed for wl_proxy_marshal_flags made it more difficult to keep this as an isolated module. If it could be done neatly I'd still be interested to split this out into a stand-alone module.
  • The only way I found for wrapping wl_proxy_marshal_flags depends on __builtin_apply which works on GCC but not clang, see: P3032.

Diff Detail

Repository
rB Blender
Branch
TEMP-WAYLAND-WRANGLER-INLINE-REPLACE (branched from master)
Build Status
Buildable 22613
Build 22613: arc lint + arc unit

Event Timeline

Campbell Barton (campbellbarton) created this revision.

Minor additions to comments

Being able to build Wayland support into the official binary release would be great.

But I think this will still need EGL enabled. Could we revisit D12034 for building GLEW with EGL support (when WITH_GL_EGL=ON)?

Nothing against completing D12034, checking the patch it seems it's ready to be reviewed again.

  • remove unused error enum value
  • Add header comment for GHOST_WaylandDynload_prelude.h.
Campbell Barton (campbellbarton) edited the summary of this revision. (Show Details)

closing this patch in favor of a simpler alternative (use function pointers in a similar way to SDL),