Skip to contentSkip to conversation

package/libglvnd: introduce the GL vendor-neutral proxy (branch yem/libglvnd)

PATCH Superseded Yann E. MORIN 1 participant 3 messages Jun 22, 2020

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover package/libglvnd: introduce the GL vendor-neutral proxy (branch yem/libglvnd)

Hello All!

This is a respin from the original series by Jakub, heavily massaged by me (Yann); thanks Jakub for your initial work! :-) What follows is Jakub's original cover letter (tweaked to drop the reference to other patches not include in this respin):

Here comes support for GLVND which is a GL Vendor-Neutral disaptches, initially proposed by NVidia, currently done within the Freedestop/ RedHat project team as libglvnd.

It's useful not only for NVidia (they were first to adopt it though) but might be also beneficial for others, for example allowing you to deliver an image running on multiple machines with different GPUs and their respective OpenGL providers, which happens quite often on x86_64 and was the major reason to implement it in Buildroot for me.

On the other hand, if your board has multiple GPUs it also helps a lot
- for example when you have a "display" unit and "compute/accel" graphics units from different vendors. Happens on some ARM boards recently and there are already efforts to integrate it in these GL stacks.

The only EXT needed by GL provider is to implement GL_EXT_libglvnd which is a dummy extension allowing GL lib to "register" to let it receive GL calls.

In practive it's very simple, the libglvnd delivers its own set of "dummy" libraries:

- libGL.so
- libGLX.so
- libOpenGL.so
- libEGL.so

and needs the actual providers to be present as they already are but with names like libGLX_nvidia.so.

It allows developers to link against vendor-neutral dummy libs and openGL contexts without thinking about target GPU too much as long as it supports desired GL/EGL standard.

Also delivers GL API headers (GL/gl.h, GL/egl.h, etc.) so removes need of mesa3d-headers in GLVND-supported drivers.

Currently it's supported by all Mesa-compatible drivers and NVidia. For simplicity sake, and to ease introduction of libglvnd, only mesa3d is converted to be compatible with libglvnd. Other providers, like NVidia, can be converted (or added!) in follow-up patches.

Regards,
Yann E. MORIN.

The following changes since commit 92d73f31b2ffdbbdb7049a9c25669c973766d7f9

package/libxmlrpc: fix check-package warnings (2020-06-22 22:52:09 +0200)

are available in the git repository at:

https://git.busybox.net/~ymorin/git/buildroot

for you to fetch changes up to d09d09de3bedf9fa0c91cf515269bbb4e7014dc4

package/mesa3d: make it aware of libglvnd and support it when present (2020-06-22 22:55:31 +0200)

----------------------------------------------------------------
Jakub Skrzypnik (2):
package/libglvnd: new package
package/mesa3d: make it aware of libglvnd and support it when present

 package/Config.in              |  1 +
 package/libglvnd/Config.in     | 42 +++++++++++++++++++++++++++++++++
 package/libglvnd/libglvnd.hash |  7 ++++++
 package/libglvnd/libglvnd.mk   | 53 ++++++++++++++++++++++++++++++++++++++++++
 package/mesa3d/Config.in       | 15 +++++++-----
 package/mesa3d/mesa3d.mk       | 15 ++++++++----
 6 files changed, 123 insertions(+), 10 deletions(-)
 create mode 100644 package/libglvnd/Config.in
 create mode 100644 package/libglvnd/libglvnd.hash
 create mode 100644 package/libglvnd/libglvnd.mk
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#1 lore raw

PATCH v3 1/2 package/libglvnd: new package

From: Jakub Skrzypnik <[email protected]>

libglvnd is the GL Vendor-Neutral Dispatch library, used to dispatch GL calls across multiple GL implementations at runtime.

Full GL support, as usual, requires (parts of) the X11 stack: libX11, libXext, and xorgproto (for glproto). However, with just libX11, it is possible to do EGL on X11. EGL and GLES have no dependencies.

Note: x11 and glx are 'features', so need to be 'enabled' or 'disabled' (or 'auto', but we don't care in Buildroot), while egl and gles1/2 are 'booleans', so need to be 'true' or 'false'.

When an actual provider for GL, EGL, or GLES is enabled, so must the corresponding flavour be enabled in libglvnd. Conversely, when there is no actual provider, the corresponding support must be disabled in libglvnd. So we make each flavour selectable with hidden options, which actual providers will have to select.

The license for libglvnd itself is a custom license by NVidia. It is pretty close to MIT, but it's different (although Debian does classify it as MIT); SPDX has no identifier for that license either. As such, we choose to just identify it as 'libglvnd license', and let users deal that with their legal department. Additionally, libglvnd bundles some code from other projects, so we list them explicitly as well.

[yann.morin.1998 at free.fr:
- provide help text
- don't force X11 libraries, split them between X11 and full GL
- make each flavour selectable
- fix make check-package issues
- fix and complete licensing information
- expand commit log
]

---
 package/Config.in              |  1 +
 package/libglvnd/Config.in     | 42 +++++++++++++++++++++++++++
 package/libglvnd/libglvnd.hash |  7 +++++
 package/libglvnd/libglvnd.mk   | 53 ++++++++++++++++++++++++++++++++++
 4 files changed, 103 insertions(+)
 create mode 100644 package/libglvnd/Config.in
 create mode 100644 package/libglvnd/libglvnd.hash
 create mode 100644 package/libglvnd/libglvnd.mk
package/Config.in +1 -0
index e2bb004015..9c6b994549 100644
@@ -310,6 +310,7 @@ comment "Graphic libraries"
 	source "package/fbv/Config.in"
 	source "package/freerdp/Config.in"
 	source "package/imagemagick/Config.in"
+	source "package/libglvnd/Config.in"
 	source "package/linux-fusion/Config.in"
 	source "package/lite/Config.in"
 	source "package/mesa3d/Config.in"
package/libglvnd/Config.in new file +42 -0

42 lines not on this page · raw message

package/libglvnd/libglvnd.hash new file +7 -0
new file mode 100644
index 0000000000..1b13c5738e
@@ -0,0 +1,7 @@
+# Locally computed
+sha256  b26c931ff79feced0d1ac69332797a08427308fa85541282ee9995680c880b24  libglvnd-v1.3.1.tar.gz
+
+# Locally computed hashes for license files
+sha256  224534547628a9e5e889d8808385bd38839e6bdb77d89c90ac04dad6891a4f5f  README.md
+sha256  bebdc0fd27cd37af8406e47af23c113866b7856c3f7349ffcbc672029ec8acf7  src/util/uthash/LICENSE
+sha256  f6f207863675ca5a5128fd120b9aef4f4bbab73ffa57e5f771ccffc8e3cc56b7  src/util/cJSON/LICENSE
package/libglvnd/libglvnd.mk new file +53 -0

53 lines not on this page · raw message

Signature · 1 line
2.20.1
#2 lore raw

PATCH v3 2/2 package/mesa3d: make it aware of libglvnd and support it when present

In reply to Yann E. MORIN

From: Jakub Skrzypnik <[email protected]>

When libglvnd is enabled, mesa3d must be told so, so as it installs its libraries with the vendor suffix (e.g. libEGL_mesa.so instead of libEGL.so).

Additionally, the provider (in Buildroot parlance) is libglvnd, not mesa3d.

[yann.morin.1998 at free.fr:
- don't override the _PROVIDES variable, only assign when needed
]

---
 package/mesa3d/Config.in | 15 +++++++++------
 package/mesa3d/mesa3d.mk | 15 +++++++++++----
 2 files changed, 20 insertions(+), 10 deletions(-)
package/mesa3d/Config.in +9 -6
index 11d04b7a3f..5417aeda1a 100644
@@ -422,7 +422,8 @@ comment "gbm support needs a dri driver or a gallium driver w/ EGL support."
 config BR2_PACKAGE_MESA3D_OPENGL_GLX
 	bool "OpenGL GLX"
 	depends on BR2_PACKAGE_XORG7
-	select BR2_PACKAGE_HAS_LIBGL
+	select BR2_PACKAGE_HAS_LIBGL if !BR2_PACKAGE_LIBGLVND
+	select BR2_PACKAGE_LIBGLVND_DISPATCH_GL if BR2_PACKAGE_LIBGLVND
 	select BR2_PACKAGE_MESA3D_NEEDS_X11
 	help
 	  Enable GLX graphic acceleration (OpenGL + X11).
@@ -432,7 +433,8 @@ comment "OpenGL GLX support needs X11"
 
 config BR2_PACKAGE_MESA3D_OPENGL_EGL
 	bool "OpenGL EGL"
-	select BR2_PACKAGE_HAS_LIBEGL
+	select BR2_PACKAGE_HAS_LIBEGL if !BR2_PACKAGE_LIBGLVND
+	select BR2_PACKAGE_LIBGLVND_DISPATCH_EGL if BR2_PACKAGE_LIBGLVND
 	select BR2_PACKAGE_HAS_LIBEGL_WAYLAND
 	select BR2_PACKAGE_MESA3D_GBM
 	help
@@ -441,7 +443,8 @@ config BR2_PACKAGE_MESA3D_OPENGL_EGL
 
 config BR2_PACKAGE_MESA3D_OPENGL_ES
 	bool "OpenGL ES"
-	select BR2_PACKAGE_HAS_LIBGLES
+	select BR2_PACKAGE_HAS_LIBGLES if !BR2_PACKAGE_LIBGLVND
+	select BR2_PACKAGE_LIBGLVND_DISPATCH_GLES if BR2_PACKAGE_LIBGLVND
 	help
 	  Use the Khronos OpenGL ES APIs. This is commonly used on
 	  embedded systems and represents a subset of the OpenGL API.
@@ -449,13 +452,13 @@ config BR2_PACKAGE_MESA3D_OPENGL_ES
 endif # BR2_PACKAGE_MESA3D_DRIVER
 
 config BR2_PACKAGE_PROVIDES_LIBGL
-	default "mesa3d" if BR2_PACKAGE_MESA3D_OPENGL_GLX
+	default "mesa3d" if BR2_PACKAGE_MESA3D_OPENGL_GLX && !BR2_PACKAGE_LIBGLVND
 
 config BR2_PACKAGE_PROVIDES_LIBEGL
-	default "mesa3d" if BR2_PACKAGE_MESA3D_OPENGL_EGL
+	default "mesa3d" if BR2_PACKAGE_MESA3D_OPENGL_EGL && !BR2_PACKAGE_LIBGLVND
 
 config BR2_PACKAGE_PROVIDES_LIBGLES
-	default "mesa3d" if BR2_PACKAGE_MESA3D_OPENGL_ES
+	default "mesa3d" if BR2_PACKAGE_MESA3D_OPENGL_ES && !BR2_PACKAGE_LIBGLVND
 
 config BR2_PACKAGE_PROVIDES_LIBOPENCL
 	default "mesa3d" if BR2_PACKAGE_MESA3D_OPENCL
package/mesa3d/mesa3d.mk +11 -4
index 4e083979cc..2f61b4d219 100644
@@ -162,9 +162,9 @@ MESA3D_CONF_OPTS += -Dopengl=true
 # we do not need libva support in mesa3d, therefore disable this option
 MESA3D_CONF_OPTS += -Dgallium-va=false
 
-# libGL is only provided for a full xorg stack
+# libGL is only provided for a full xorg stack, without libglvnd
 ifeq ($(BR2_PACKAGE_MESA3D_OPENGL_GLX),y)
-MESA3D_PROVIDES += libgl
+MESA3D_PROVIDES += $(if $(BR2_PACKAGE_LIBGLVND),,libgl)
 else
 define MESA3D_REMOVE_OPENGL_HEADERS
 	rm -rf $(STAGING_DIR)/usr/include/GL/
@@ -224,7 +224,7 @@ MESA3D_CONF_OPTS += \
 endif
 
 ifeq ($(BR2_PACKAGE_MESA3D_OPENGL_EGL),y)
-MESA3D_PROVIDES += libegl
+MESA3D_PROVIDES += $(if $(BR2_PACKAGE_LIBGLVND),,libegl)
 MESA3D_CONF_OPTS += \
 	-Degl=true
 else
@@ -233,7 +233,7 @@ MESA3D_CONF_OPTS += \
 endif
 
 ifeq ($(BR2_PACKAGE_MESA3D_OPENGL_ES),y)
-MESA3D_PROVIDES += libgles
+MESA3D_PROVIDES += $(if $(BR2_PACKAGE_LIBGLVND),,libgles)
 MESA3D_CONF_OPTS += -Dgles1=true -Dgles2=true
 else
 MESA3D_CONF_OPTS += -Dgles1=false -Dgles2=false
@@ -281,4 +281,11 @@ else
 MESA3D_CONF_OPTS += -Dzstd=false
 endif
 
+ifeq ($(BR2_PACKAGE_LIBGLVND),y)
+MESA3D_DEPENDENCIES += libglvnd
+MESA3D_CONF_OPTS += -Dglvnd=true
+else
+MESA3D_CONF_OPTS += -Dglvnd=false
+endif
+
 $(eval $(meson-package))
Signature · 1 line
2.20.1