Wayland support #90676
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
13 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#90676
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
1 Introduction
1.1 Motivation
Wayland is a communication protocol between a compositor and GUI clients that present content on a screen. It is adopted by major desktop environments on Linux and enabled by default on the majority of distributions (Fedora/RHEL, Debian, Ubuntu). In the long-term, it is expected that X11 clients will only be supported through XWayland. Blender should support Wayland to gain the benefits such as tear-free and "atomic" window updates, fractional scaling, access to newer input methods and generally to support a more efficient communication with the compositor.
1.2 OpenGL Context
1.2.1 Legacy
Legacy OpenGL on Linux would assume that OpenGL is always used together with X11. The GL library (
libGL
) would therefore define GLX and OpenGL symbols:libGL
defines some OpenGL symbols (gl*
) and all GLX symbols (glX*
), as shown bynm --demangle --dynamic --defined-only --extern-only /usr/lib/x86_64-linux-gnu/libGL.so
.libGLX
defines a subset of GLX symbols.1.2.2 Modern
Modern OpenGL separates OpenGL functions and context creation functions via GLVND into
libOpenGL
andlibGLX
orlibEGL
.These libraries are not linked with each other. The EGL library:
only defines EGL symbols (
egl*
) and is separated from the OpenGL library:which only defines OpenGL symbols (
gl*
).libGLX
only defines the GLX symbols (glX*
) as above. You can check this withnm --demangle --dynamic --defined-only --extern-only
.There is no library that defines OpenGL and EGL symbols. Hence, to use "modern" OpenGL, an application has to link the OpenGL library and one of the context creation libraries.
Ubuntu and Fedora do not provide
libOpenGL
in the default installation. This library is provided via a package and has to be installed manually. OnlylibEGL
andlibGLX
are provided in the default installation.The only way to create an OpenGL context on Wayland is via EGL. EGL is also supported on X11. Wayland and X11 can therefore be enabled at the same time and use the same context creation procedures, removing the need to maintain GLX.
2 Current State
X11 (
WITH_GHOST_X11
) is enabled by default, while Wayland (WITH_GHOST_WAYLAND
) is disabled by default at compile time.X11 uses GLX to create the OpenGL context and uses either the system or external GLEW to query OpenGL function pointers. By default,
WITH_SYSTEM_GLEW
is OFF and hence the external GLEW is used. GLEW has to be compiled with either GLX or EGL support. It is not possible to use GLEW with a runtime selection of the context creation routines. Most distributions ship GLEW with GLX support enabled. Blender uses "legacy" OpenGL and linkslibGL
to resolve GLX and OpenGL symbols.If
WITH_GHOST_WAYLAND
is set ON, Blender has to use the external GLEW and compile this with EGL support. IfWITH_GHOST_X11
is ON in parallel, this means that also the X11 backend switches to EGL. It will additionally linklibEGL
(but keep the "LEGACY" OpenGL preference).The current behaviour can be summarised as:
WITH_GHOST_X11
WITH_GHOST_WAYLAND
libGL
,libX11
libEGL
,libGL
,libX11
libEGL
,libGL
,libX11
3 Proposed Solution
3.1 GHOST
Since the Wayland option has to be set at compile-time, the Wayland backend has not received wide testing yet. Enabling Wayland at compile-time (
WITH_GHOST_WAYLAND
) and making it opt-in at runtime has been proposed in https:developer.blender.org/D11489. This would setWITH_GHOST_WAYLAND
to on, but would still require to set the environment variableBLENDER_WAYLAND
to probe the Wayland connection firstif X11 is enabled in parallel//. If Wayland is the only backend enabled at compile-time, it will be used regardless of the runtimeBLENDER_WAYLAND
.WITH_GHOST_X11
WITH_GHOST_WAYLAND
BLENDER_WAYLAND
Note:
WITH_GHOST_WAYLAND
will always be set toOFF
if one of its required build dependencies is not available.3.2 OpenGL Context
To satisfy the following constraints:
libOpenGL
by defaultTo resolve the OpenGL symbols when EGL is used, I propose in https://developer.blender.org/D12034 to:
libGL
in the new default configuration (X11 and Wayland built in parallel)libOpenGL
in a pure Wayland configuration (without X11)Effectively, this means that Blender will by default continue to link
libGL
and additionally linklibEGL
for the EGL context creation. A pure Wayland built will use "modern" OpenGL and will not link any X11 symbol directly or indirectly. A distributed X11+Wayland binary will continue to work on default installations. A distributed Wayland-only binary will require to manually install the distribution packages that providelibOpenGL
. The latter does not apply to "packaged" distributed binaries, such as deb, flatpak and snap packages, as those can define or provide their own dependencies.4 Experimental Builds
BLENDER_WAYLAND= ./blender
) and fallback to X11, linkslibGL
Added subscribers: @christian.rauch, @ideasman42, @brecht, @JulianEisel, @dr.sybren, @ZedDB
Added subscriber: @GeorgiaPacific
A few thoughts:
As stated before I think that we should start the wayland backend without any special flags that needs to be set.
We could of course provide a flag to to force the use of the x11 backend even when wayland is detected.
This is because I think and I am certain that you will not get enough test as you are already targeting the currently very small wayland user base on linux.
Of those using the wayland backend, I don't think they would think of using the wayland back end unless they are hardcore wayland users.
So of that very small subset of blender wayland users, you are targeting an even smaller subset of that user base.
In addition to this they also have to use the experimental builds which narrows this down even further.
If it is ready for testing then at least to me, it should be on by default.
Then you will know for sure if it is ready for prime time when the release window closes.
According to the nvidia driver documentation: https://download.nvidia.com/XFree86/Linux-x86_64/390.42/README/installedcomponents.html
This implies that EGL might not work on nvidia cards without
libOpenGL
(GLVND).Has this been tested?
I have a sneaking suspicion that this is why quite a few projects have switched from GLEW to libepoxy or other alternatives so they can switch between EGL and GLX at runtime.
(So they can fallback to GLX nvidia systems that doesn't have the GLVND library installed)
What is the plan for loading wayland libraries?
As far as I know we can't (or at least shouldn't) statically link the wayland libraries.
So this means that unless you
dlopen
these, our binaries will not run on systems that lack them.The same is true for pure wayland systems of course as well. If there is not x11 libraries installed, our binary will fail to load.
How do you plan to tackle this issue?
I think ideally we would do two major changes:
That's asking a lot from @christian.rauch of course, but maybe we really should solve all these issues for a release build.
Right, I also think that those two points will require a lot of work.
This is why I initially proposed and/or asked why SDL2 had not been considered and if it had, what was the show stopper that prevented it from being a good candidate.
At least to me, SDL2 seems to have solved the issue with multiple back ends (but I could be wrong of course...).
So If we will have to do a lot of work regardless, why not switch to SDL2 and let that library do most of the platform specific heavy lifting for us?
I don't see how SDL solves any of the specific issues we are having now? Did you see any mechanism where it helps us avoid linking the Blender executable to X11 or Wayland libraries and decide to load them at runtime only?
And as mentioned in the code review, SDL does not support all the features we need.
According to this: https://wiki.libsdl.org/Installation
So to me this would solve us having to build a dymanic loading system into GHOST as SDL already have this for us.
Both X11/Wayland and GLX/EGL wise. So if we use SDL2, we don't need to implement this ourselves at all.
It also means that we don't have to implement wayland specific protocols ourselves, we can piggy back on SDL2 for that too.
I know you have pointed out that it doesn't support everything we need, but I don't think you gave any specific examples or gave a list of features that were missing or lacking.
From what I gather it seems like it was quite some time ago we looked at it and perhaps those issues have been fixed?
I'm not arguing that there are no issues, I just want to get a list so we can properly evaluate the pros and cons.
What I'm thinking is that if SDL2 solves this platform issue for us, then perhaps if we have any issues with it, we could fix it upstream and that would at least in the long run be a better solution.
There are a couple of topics touched here.
Runtime flags:
I agree that having this opt-in reduces the testing compared to activating this for all Wayland users at once. However, activating this at once also means that all undiscovered issues will show up for Wayland users without an easy way to start Blender with the X11 backend. This is the reason why other programs like Firefox, Chromium or SDL, activate Wayland by a runtime opt-in, and do not test this straight on their users. I strongly suggest following the same path before activating this permanently. I don't see the point of turning Wayland users into beta testers for Blender without their explicit intention.
SDL:
This came up a couple of times now. If SDL is to be used in Blender, then all of GHOST has to be replaced by SDL. It is up to Blender devs to make this call and implement it. However, SDL is a platform abstraction that will not be able to support platform-specific features. By using SDL you reduce the maintenance costs but also lose the ability to support platforms in all their detail.
EGL:
I have tested Blender X11-EGL on Intel and Nvidia systems without issues.
Wayland:
I don't have a plan for dynamically loading wayland libraries. The Wayland implementation is supposed to work in the same way as the current X11 implementation, which also does not use dynamic loading via dlopen either.
I don't see any infrastructure in Blender for dynamic loading of GHOST implementations, so I don't intend to do something like this for Wayland. I honestly also don't see the point of doing this only for a single GHOST implementation.
I started the design document in the hope that decisions on how to go onwards would be made. What I can offer the Blender project is a Wayland implementation that works in the same way as the X11 implementation and EGL support that works in the same way as the GLX support. I am happy to continue working on the Wayland support to solve any remaining issues once this can be enabled (opt-in or opt-out) at runtime.
Regarding dynamic linking (dlopen) of windowing and OpenGL libraries or replacing GHOST with SDL, I don't see any progress in Blender towards this. As a voluntary contributor to Blender with the aim of providing Wayland support, I don't have the time or intention to contribute additional features that touch the foundation of the windowing system. I believe that these fundamental changes are tasks for core Blender developers.
Added subscriber: @jtheoof
Added subscriber: @Mhaus
Added subscriber: @eszlari
SDL already has some platform-specific features, in v2.0.22 for Wayland too:
9c2f46b0d5
I'm sure, if a popular project like Blender needs more, they would be open to add them.
The Unreal Engine 5 editor seems to be running natively on Wayland with the help of SDL:
https://twitter.com/flibitijibibo/status/1511530172553605124
Added subscriber: @smeikx
You cannot expect SDL to adopt every platform-specific feature for all available platforms. If you want to support a new Wayland protocol, or features like a Touch Bar or the Surface Dial, you have to implement them in SDL first. There is no guarantee that these features will be accepted upstream and if you are on a long-term platform like Ubuntu LTS or Red Hat, you have to wait years until they become available in your distribution.
Games do not really need a lot of platform-specific features. Most games just open a fullscreen window and read from mouse, keyboard or gamepad.
Anyway, I am getting a bit tired of repeating these arguments. SDL, like GHOST, is a platform abstraction. While GHOST can support arbitrary features since it is tightly coupled with Blender, SDL cannot. If you still want to replace all of GHOST with SDL, then please go ahead.
Added subscriber: @Pipeliner
Added subscriber: @1ace
Added subscriber: @archerallstars
Added subscriber: @VitalyR
Could this task be closed now? It looks like issues raised in this task have been resolved.
Changed status from 'Needs Triage' to: 'Resolved'
Yes. The main questions regarding the OpenGL linking and Wayland support have been resolved. I think there are some open issues with the OpenGL context creation in OpenSubdiv, but this is not so much related to the issues discussed here.