jfx icon indicating copy to clipboard operation
jfx copied to clipboard

8329820: [Linux] Prefer EGL over GLX

Open tsayao opened this issue 1 year ago • 26 comments

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

  • [x] Change must not contain extraneous whitespace
  • [x] 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

tsayao avatar Feb 24 '24 17:02 tsayao

:wave: 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.

bridgekeeper[bot] avatar Feb 24 '24 17:02 bridgekeeper[bot]

@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[bot] avatar Feb 24 '24 17:02 openjdk[bot]

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

openjdk[bot] avatar Mar 13 '24 20:03 openjdk[bot]

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

lukostyra avatar Apr 02 '24 12:04 lukostyra

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

kevinrushforth avatar Apr 08 '24 13:04 kevinrushforth

@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).

openjdk[bot] avatar Apr 08 '24 13:04 openjdk[bot]

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

tsayao avatar Apr 23 '24 12:04 tsayao

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 avatar Apr 30 '24 12:04 tsayao

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 avatar Apr 30 '24 14:04 tsayao

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 avatar Apr 30 '24 14:04 tsayao

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.

tsayao avatar Apr 30 '24 20:04 tsayao

@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.

openjdk[bot] avatar May 01 '24 21:05 openjdk[bot]

Reopening so maybe it could be usefult to 8332108

tsayao avatar May 22 '24 21:05 tsayao

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 avatar May 22 '24 22:05 tsayao

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

tsayao avatar May 26 '24 11:05 tsayao

Note: Running full Robot systemtests are failing. Will look.

tsayao avatar May 27 '24 12:05 tsayao

@tsayao This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

bridgekeeper[bot] avatar Jul 07 '24 16:07 bridgekeeper[bot]

I will get back to this next week.

tsayao avatar Jul 07 '24 17:07 tsayao

Would it be better to still default to GLX and have a flag to use EGL (and switch within a few releases), or to go with EGL and have a flag to fallback to GLX?

Currently (on this PR) it defaults to EGL first, and if it fails, try GLX (I don't know a scenario where EGL won't work, on Xorg o XWayland).

tsayao avatar Jul 08 '24 13:07 tsayao

SetSceneScalingTest currently fails with EGL_BAD_ALLOC on nCreateDrawable. I still don't know why - by the file name I would suspect something related to scaling - but there's no scaling on the test (not that I can see).

tsayao avatar Jul 29 '24 20:07 tsayao

by the file name I would suspect something related to scaling - but there's no scaling on the test (not that I can see).

It is related to system's DPI setting. We had a problem with UI elements sometimes being incorrectly rendered/shifted when scaling setting in the system was set to more than 100% - see JDK-8299968

lukostyra avatar Jul 30 '24 06:07 lukostyra