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

8329820: [Linux] Prefer EGL over GLX #1381

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Conversation

tsayao
Copy link
Collaborator

@tsayao tsayao commented Feb 24, 2024

Wayland implementation will require EGL.

EGL works with Xorg as well. The idea is to be EGL first and if it fails, fallback to GLX. A force flag prism.es2.forceGLX=true is available.

See:
Switching the Linux graphics stack from GLX to EGL
Prefer EGL to GLX for the GL support on X11


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed (3 reviews required, with at least 1 Reviewer, 2 Authors)

Issue

  • JDK-8329820: [Linux] Prefer EGL over GLX (Enhancement - P4)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/1381/head:pull/1381
$ git checkout pull/1381

Update a local copy of the PR:
$ git checkout pull/1381
$ git pull https://git.openjdk.org/jfx.git pull/1381/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 1381

View PR using the GUI difftool:
$ git pr show -t 1381

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/1381.diff

Webrev

Link to Webrev Comment

# Conflicts:
#	modules/javafx.graphics/src/main/native-prism-es2/x11/X11GLContext.c
@bridgekeeper
Copy link

bridgekeeper bot commented Feb 24, 2024

👋 Welcome back tsayao! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Feb 24, 2024

@tsayao this pull request can not be integrated into master due to one or more merge conflicts. To resolve these merge conflicts and update this pull request you can run the following commands in the local repository for your personal fork:

git checkout egl
git fetch https://git.openjdk.org/jfx.git master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push

@openjdk openjdk bot added merge-conflict Pull request has merge conflict with target branch and removed merge-conflict Pull request has merge conflict with target branch labels Feb 24, 2024
@openjdk
Copy link

openjdk bot commented Mar 13, 2024

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@tsayao tsayao changed the title Draft: Replace GLX with EGL to allow further development towards Wayland Draft: Prefer EGL over GLX to allow further development towards Wayland Mar 31, 2024
Copy link
Contributor

@lukostyra lukostyra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took a brief look at your changes and I shared some comments.

Overall the changes look good. The EGL/GLX loading in GLFactory feels a bit hacky, but other than making EGL a completely separate Prism backend (which would duplicate/reorganize a lot of common EGL/GLX code - definitely a no-go IMO) I don't have a better idea how to solve this. Maybe with an ES2-specific property like prism.es2.forceglx=true?

This brings me to a question - other than some form of debugging/fallback for when EGL is still new to JFX, do we even need GLX implementation when we have a working EGL implementation? I'm fairly sure that current distros (especially ones officially supported by JFX) have EGL support available at this point in time, and since it's an intermediary layer between application and runtime it shouldn't depend on used GPU.

@lukostyra
Copy link
Contributor

Also a side note - the PR title does not match the JBS issue.

@tsayao tsayao changed the title Draft: Prefer EGL over GLX to allow further development towards Wayland 8329820: [Linux] Prefer EGL over GLX Apr 6, 2024
@openjdk openjdk bot added the rfr Ready for review label Apr 6, 2024
@mlbridge
Copy link

mlbridge bot commented Apr 6, 2024

@kevinrushforth
Copy link
Member

This will need a fair bit of testing and review. I would like a chance to review it, but won't be able to get to it for a couple weeks.

Reviewers: @kevinrushforth @lukostyra @johanvos @arapte
/reviewers 3

@openjdk
Copy link

openjdk bot commented Apr 8, 2024

@kevinrushforth
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 3 (with at least 1 Reviewer, 2 Authors).

@tsayao
Copy link
Collaborator Author

tsayao commented Apr 23, 2024

I have to figure out how to test Monocle, since I have changed the logic of defines on PrismES2Defs.h.

Copy link
Contributor

@lukostyra lukostyra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a few comments, mostly for adjusting error-checking. Once those are fixed and others have their input I'll test those changes.

@tsayao
Copy link
Collaborator Author

tsayao commented Apr 30, 2024

I changed it to use EGL_DEFAULT_DISPLAY in an attempt to make no assumptions on the platform. It works, but I'm not sure if it's correct. I'm looking at Mesa egl source to be sure.

I also changed the dummy window to use PBUFFER (also to make no assumptions on the platform, so there's no need to create a XWindow). I'm also not sure about that.

@tsayao
Copy link
Collaborator Author

tsayao commented Apr 30, 2024

It is possible to set the platform with EGL_PLATFORM=x11 environment variable.
Using EGL_LOG_LEVEL=debug currently outputs that the platform was detected in build time - I think it's wrong.

@tsayao
Copy link
Collaborator Author

tsayao commented Apr 30, 2024

I'll have to fix it

I got a reply explaining it (the docs where not very clear)
https://lists.freedesktop.org/archives/mesa-users/2024-April/001727.html

@tsayao
Copy link
Collaborator Author

tsayao commented Apr 30, 2024

I changed it to use platform specific way to get EGLDisplay so eglGetDisplay does not have to guess the platform (it can guess wrong).

It can be seen by setting EGL_LOG_LEVEL=debug (with eglGetDisplay it will output the guessing part).

I also reverted the Dummy window code change.

@openjdk
Copy link

openjdk bot commented May 1, 2024

@tsayao Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. See OpenJDK Developers’ Guide for more information.

@tsayao tsayao closed this May 13, 2024
@tsayao
Copy link
Collaborator Author

tsayao commented May 22, 2024

Reopening so maybe it could be usefult to 8332108

@tsayao tsayao reopened this May 22, 2024
@tsayao
Copy link
Collaborator Author

tsayao commented May 22, 2024

Testing 8332108 with this branch seems to have a significance in favor of EGL:

Using this branch, compare the attached example with and without -Dprism.es2.forceGLX=true

@tsayao
Copy link
Collaborator Author

tsayao commented May 26, 2024

It seems to make a difference when display refresh rate is lower (60Hz). With higher refresh (160hz), no difference.

EGL:
Screenshot from 2024-05-26 08-22-04

GLX:
Screenshot from 2024-05-26 08-22-24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rfr Ready for review
3 participants