Using NVidia's libEGL instead of Mesa's libEGL

8 views
Skip to first unread message

Gonzalo Garramuño

unread,
Apr 29, 2024, 9:45:54 PMApr 29
to fltkc...@googlegroups.com
According to CMake's find_package(OpenGL), setting this should allow for
a vendor neutral distribution of Wayland and EGL:

set(OpenGL_GL_PREFERENCE GLVND)
find_package(OpenGL REQUIRED)

...etc...

list(APPEND LIBRARIES OpenGL::OpenGL OpenGL::EGL)
target_link_libraries(mrv2 PUBLIC ${LIBRARIES} )

But it does not seem to work for me.  My application with FLTK and GLFW
both latest (compiled on Rocky Linux 8.9 and running on Ubuntu 22.04.4
LTS) starts fine but always loads Mesa's libEGL.

Google's Gemini told me about these variables:

The system searches for directories or files specified by environment
variables:
__EGL_VENDOR_LIBRARY_FILENAMES: This variable takes a colon-separated
list of JSON files describing available ICDs.
__EGL_VENDOR_LIBRARY_DIRS: This variable takes a colon-separated list of
directories containing JSON files for ICDs.

I set them to:

> echo $__EGL_VENDOR_LIBRARY_DIRS
/usr/share/glvnd/

> echo $__EGL_VENDOR_LIBRARY_FILENAMES
10_nvidia.json:50_mesa.json

And then my application does not start and gives me the weird error:

GLFW ERROR: EGL: Failed to get EGL display: Success
ERROR: Cannot create window

The reason I want load NVidia's EGL instead of Mesa's EGL is one of
performance.  Mesa's EGL plays 4K movies at 16 FPS while NVidia's EGL
plays them at a perfect 60 FPS.

Manolo and Albrecht, can you help?

--
Gonzalo Garramuño
ggar...@gmail.com

Manolo

unread,
Apr 30, 2024, 3:00:01 AMApr 30
to fltk.coredev
I'm not sure I can help because I have only access at Wayland in a VM machine hosted by macOS.

I would suggest to try first with a very simple GL app, say FLTK's test/shape and without CMake,
without installed, shared FLTK libs. Just use fltk-config and a non-installed, static, debug-ready
version of libfltk. Can you determine a list of Ubuntu packages and link command switches
that produce an executable using NVidia's EGL lib? Then, Albrecht should be able to tell you how
to get the same result using CMake to build a full size FLTK client app.

Gonzalo Garramuno

unread,
Apr 30, 2024, 3:08:44 AMApr 30
to fltkc...@googlegroups.com


> El 30 abr 2024, a las 04:00, Manolo <manol...@gmail.com> escribió:
>
> Can you determine a list of Ubuntu packages and link command switches
> that produce an executable using NVidia's EGL lib? Then, Albrecht should be able to tell you how
> to get the same result using CMake to build a full size FLTK client app.ç

The command I used to link the nvidia library was easy. I did:

find_library( EGL NAMES EGL_nvidia EGL )

target_link_libraries( TARGET mrv2 LIBRARIES EGL )

That links directly to the NVidia EGL library, but it is not portable to other graphics cards.

Supposedly GLVND is the solution, but cannot get it to work. I am on my Mac now, and won’t be able to check till later this evening.



Gonzalo Garramuno
ggar...@gmail.com




Albrecht Schlosser

unread,
Apr 30, 2024, 5:04:39 PMApr 30
to fltkc...@googlegroups.com
On 4/30/24 03:45 Gonzalo Garramuño wrote:
According to CMake's find_package(OpenGL), setting this should allow for a vendor neutral distribution of Wayland and EGL:

set(OpenGL_GL_PREFERENCE GLVND)

This should be the default (since CMake 3.10 or so), and we don't override this. You *can* specify it but you shouldn't need this because we require CMake 3.15 and that enables the according CMake policy.

find_package(OpenGL REQUIRED)

This seems to be the main issue. We don't use this directly (yet), our current code uses findLibrary() and is ... suboptimal.

I'll check this when time permits.


list(APPEND LIBRARIES OpenGL::OpenGL OpenGL::EGL)
target_link_libraries(mrv2 PUBLIC ${LIBRARIES} )

Same issue as above, we're not (yet) using the OpenGL targets in FLTK's CMake files. Our code predates the addition of GLVND support in CMake.


But it does not seem to work for me.  My application with FLTK and GLFW both latest (compiled on Rocky Linux 8.9 and running on Ubuntu 22.04.4 LTS) starts fine but always loads Mesa's libEGL.

Let's see what I can do to change this although I don't have any NVIDIA stuff installed because I don't use NVIDIA graphics.

However, it looks like I got 'GLVND' support on my system. From `apt list`:

libglvnd-core-dev/stable,now 1.6.0-1 amd64 [installed,automatic]
libglvnd-dev/stable,now 1.6.0-1 amd64 [installed,automatic]
libglvnd0/stable,now 1.6.0-1 amd64 [installed,automatic]
libglvnd0/stable,now 1.6.0-1 i386 [installed,automatic]

Whatever that means.


Google's Gemini told me about these variables:

The system searches for directories or files specified by environment variables:
__EGL_VENDOR_LIBRARY_FILENAMES: This variable takes a colon-separated list of JSON files describing available ICDs.
__EGL_VENDOR_LIBRARY_DIRS: This variable takes a colon-separated list of directories containing JSON files for ICDs.

Great explanation for someone who doesn't know what ICD means is this context!  :-(

Looks like "Installable Client Driver (OpenGL)" is meant here, rather than "Implantable Cardioverter Defibrillator" ;-)


I set them to:

> echo $__EGL_VENDOR_LIBRARY_DIRS
/usr/share/glvnd/

> echo $__EGL_VENDOR_LIBRARY_FILENAMES
10_nvidia.json:50_mesa.json

Does the file '10_nvidia.json' exist at the appropriate place?
My /usr/share/glvnd/ tree looks like:
$ tree /usr/share/glvnd/
/usr/share/glvnd/
└── egl_vendor.d
    └── 50_mesa.json

There's no 10_nvidia.json file for obvious reasons... (see above).


And then my application does not start and gives me the weird error:

GLFW ERROR: EGL: Failed to get EGL display: Success
ERROR: Cannot create window

OK, that's really weird, an ERROR because of "Success".


The reason I want load NVidia's EGL instead of Mesa's EGL is one of performance.  Mesa's EGL plays 4K movies at 16 FPS while NVidia's EGL plays them at a perfect 60 FPS.

Manolo and Albrecht, can you help?

I'm not sure, I have no idea what this OpenGL and GLVND stuff is all about.  Meanwhile I know a little more, but the (CMake) docs are more for users who KNOW what GLVND is and not for such users like me. ;-)

Anyway, I believe I can improve at least the usage of findOpenGL and thus hopefully enable the GLVND mode and maybe that solves your issues.

Reply all
Reply to author
Forward
0 new messages