Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] libobs-opengl: Support Wayland-EGL #2097

Draft
wants to merge 1 commit into
base: master
from

Conversation

@cyclopsian
Copy link
Contributor

cyclopsian commented Oct 6, 2019

Description

Enables support for EGL on wayland as a libobs-opengl backend. It supports swapping between the X11/Wayland backends on Unix-like platforms. This is for the rendering backend only, it doesn't cover the capture plugins.

Motivation and Context

Qt already supports an environment variable to change backends at program startup, by setting QT_QPA_PLATFORM=xcb or QT_QPA_PLATFORM=wayland-egl. Without this PR, OBS ignores this Qt setting and instead assumes that on Unix-like platforms, X11 is always used. This causes creation of the glx context to fail and the OpenGL preview to show up blank when the Qtwayland backend is used. The relevant bug is 0001518, which this PR aims to fix. This also clears up half of 0000609.

How Has This Been Tested?

I test on Ubuntu Disco with an Intel i915. The wayland compositors I've tested with are Weston, Sway, Mutter (GNOME), and KWin (KDE). It works in Weston and Sway, but there are issues in the others:

  • Mutter displays a blank preview window
  • KWin causes OBS to deadlock when resizing the window

Note that currently this PR is not ready to merge because of those issues. It's not clear to me yet if those are bugs in OBS, in Qt, or in those compositors. Since it works fine in Weston, it leads me to believe that those are compositor issues. If you're using Sway or another wlroots compositor then you can use this PR as-is before it's merged.

I've also tested this on my machine X11 in GNOME, KDE, and with i3 to make sure nothing broke there. I have not tested on any BSDs. Some of the general backend code was touched, so this should also be tested on the non-Unix platforms to make sure nothing broke. I have not tested on Windows or MacOS.

Types of changes

New feature: Support wayland as a rendering backend.

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
Enable swapping between X11/GLX and Wayland/EGL backends on Unix-like
platforms. The backend can be chosen manually by setting the
QT_QPA_PLATFORM environment variable to "xcb", or "wayland-egl".
@kkartaltepe

This comment has been minimized.

Copy link
Collaborator

kkartaltepe commented Oct 6, 2019

Personally, a different name should be chosen for libobs/obs-nix, and libobs/obs-x11 should be git cped to preserve history and so the diff is readable. It may be possible to start a new history for libobs/obs-nix if you git mv to obs-x11 and then create libobs/obs-nix which if it works would be good too.

--edit

Also for the sake of reviewers it may be best to split this into two commits. 1 libobs modification to create a runtime platform layer only supporting existing platforms. And the 2nd commit adding in the wayland platform layer.

@cyclopsian

This comment has been minimized.

Copy link
Contributor Author

cyclopsian commented Oct 11, 2019

@kkartaltepe: I think those are good suggestions. I will try to update this soon.

@grimmy

This comment has been minimized.

Copy link
Contributor

grimmy commented Oct 25, 2019

I pulled the branch, rebased upstream/master (needed for the caption fix) and seems to be working alright for me. Debian unstable.

That said, I'm still seeing quite a few of these in the console log.

[1025/184204.066813:ERROR:gl_surface_presentation_helper.cc(237)] GetVSyncParametersIfAvailable() failed!

If you need/want any help, I'd love to see this merged.

@grimmy

This comment has been minimized.

Copy link
Contributor

grimmy commented Oct 25, 2019

Hah, i Just noticed there's some placement issues though... Notice that the preview is overlapping the stats panel... Happens outside of studio mode too

image

@w23

This comment has been minimized.

Copy link

w23 commented Nov 6, 2019

There's also EGL context creation in this PR: #1758
Although it is targeting X11 mostly, it does accidentally work under wayland (although very likely still not really natively) and allows for screen grabbing using KMS.
We should probably coordinate our efforts on getting EGL into OBS.

@kkartaltepe

This comment has been minimized.

Copy link
Collaborator

kkartaltepe commented Nov 6, 2019

I dont really see much of a reason to try and coordinate between the two PRs (this adds wayland windowing support, egl is just incidental to that cause, and such a context couldnt be shared with X11 anyway). What did you have in mind for coordinating?

@WizardCM WizardCM added the Linux label Nov 7, 2019
@ayng

This comment has been minimized.

Copy link

ayng commented Nov 16, 2019

I like that you can select GLX/EGL at run-time with this PR, rather than it being a compile-time option. I'm a little intimidated by the #ifdefs and if-statements, as they introduce a lot of new states to consider. I wonder if there is a way to compile the GLX and EGL backends to .so files, and then dynamically link the one you want at run-time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.