Skip to contentSkip to conversation

mesa: enable glvnd support

PATCH Superseded Vincent Davis Jr 3 participants 6 messages Oct 24, 2022 – Oct 25, 2022

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mesa: enable glvnd support

Allows mesa to be built with glvnd support. Thus, creates libEGL_mesa.so* and libGLX_mesa.so* libraries meant to coexist with vendor neutral dispatch libraries from libglvnd.

---
 meta/conf/distro/include/default-providers.inc |  1 +
 meta/recipes-graphics/mesa/mesa.inc            | 17 ++++++++++++++---
 2 files changed, 15 insertions(+), 3 deletions(-)
meta/conf/distro/include/default-providers.inc +1 -0
index 6defdca12d..3a4e989c1f 100644
@@ -5,6 +5,7 @@ PREFERRED_PROVIDER_virtual/xserver ?= "xserver-xorg"
 PREFERRED_PROVIDER_virtual/xserver-xf86 ?= "xserver-xorg"
 PREFERRED_PROVIDER_virtual/egl ?= "mesa"
 PREFERRED_PROVIDER_virtual/libgl ?= "mesa"
+PREFERRED_PROVIDER_virtual/libglx ?= "mesa"
 PREFERRED_PROVIDER_virtual/libgl-native ?= "mesa-native"
 PREFERRED_PROVIDER_virtual/nativesdk-libgl ?= "nativesdk-mesa"
 PREFERRED_PROVIDER_virtual/libgles1 ?= "mesa"
meta/recipes-graphics/mesa/mesa.inc +14 -3
index 8a74e0a80a..9e8f1591ab 100644
@@ -29,6 +29,11 @@ UPSTREAM_CHECK_GITTAGREGEX = "mesa-(?P<pver>\d+(\.\d+)+)"
 #because we cannot rely on the fact that all apps will use pkgconfig,
 #make eglplatform.h independent of MESA_EGL_NO_X11_HEADER
 do_install:append() {
+    # sed can't find EGL/eglplatform.h as it doesn't get installed when glvnd enabled
+    if ${@bb.utils.contains('PACKAGECONFIG', 'openglx', 'true', 'false', d)}; then
+        return 0
+    fi
+
     if ${@bb.utils.contains('PACKAGECONFIG', 'egl', 'true', 'false', d)}; then
         sed -i -e 's/^#elif defined(__unix__) && defined(EGL_NO_X11)$/#elif defined(__unix__) \&\& defined(EGL_NO_X11) || ${@bb.utils.contains('PACKAGECONFIG', 'x11', '0', '1', d)}/' ${D}${includedir}/EGL/eglplatform.h
     fi
@@ -38,6 +43,7 @@ DEPENDS = "expat makedepend-native flex-native bison-native libxml2-native zlib
 EXTRANATIVEPATH += "chrpath-native"
 PROVIDES = " \
     ${@bb.utils.contains('PACKAGECONFIG', 'opengl', 'virtual/libgl', '', d)} \
+    ${@bb.utils.contains('DISTRO_FEATURES', 'opengl x11', 'virtual/libglx', '', d)} \
     ${@bb.utils.contains('PACKAGECONFIG', 'gles', 'virtual/libgles1 virtual/libgles2 virtual/libgles3', '', d)} \
     ${@bb.utils.contains('PACKAGECONFIG', 'egl', 'virtual/egl', '', d)} \
     ${@bb.utils.contains('PACKAGECONFIG', 'gbm', 'virtual/libgbm', '', d)} \
@@ -116,6 +122,7 @@ VULKAN_DRIVERS:append ="${@bb.utils.contains('PACKAGECONFIG', 'broadcom', ',broa
 PACKAGECONFIG[vulkan] = "-Dvulkan-drivers=${@strip_comma('${VULKAN_DRIVERS}')}, -Dvulkan-drivers='',glslang-native vulkan-loader vulkan-headers"
 
 PACKAGECONFIG[opengl] = "-Dopengl=true, -Dopengl=false"
+PACKAGECONFIG[openglx] = "-Dglvnd=true, -Dglvnd=false,libglvnd"
 
 # "gles" requires "opengl"
 PACKAGECONFIG[gles] = "-Dgles1=enabled -Dgles2=enabled, -Dgles1=disabled -Dgles2=disabled"
@@ -204,6 +211,7 @@ RDEPENDS:libopencl-mesa += "${@bb.utils.contains('PACKAGECONFIG', 'opencl', 'lib
 PACKAGES =+ "libegl-mesa libegl-mesa-dev \
              libosmesa libosmesa-dev \
              libgl-mesa libgl-mesa-dev \
+             libglx-mesa libglx-mesa-dev \
              libglapi libglapi-dev \
              libgbm libgbm-dev \
              libgles1-mesa libgles1-mesa-dev \
@@ -222,7 +230,7 @@ do_install:append () {
     rm -f ${D}${libdir}/gallium-pipe/*.la
     rm -f ${D}${libdir}/gbm/*.la
 
-    # it was packaged in libdricore9.1.3-1 and preventing upgrades when debian.bbclass was used 
+    # it was packaged in libdricore9.1.3-1 and preventing upgrades when debian.bbclass was used
     chrpath --delete ${D}${libdir}/dri/*_dri.so || true
 
     # libwayland-egl has been moved to wayland 1.15+
@@ -240,6 +248,7 @@ python __anonymous() {
         suffix = "-native"
     for p in (("egl", "libegl", "libegl1"),
               ("opengl", "libgl", "libgl1"),
+              ("openglx", "libglx",),
               ("gles", "libgles1", "libglesv1-cm1"),
               ("gles", "libgles2", "libglesv2-2"),
               ("gles", "libgles3",),
@@ -298,20 +307,22 @@ PACKAGES_DYNAMIC:class-native = "^mesa-driver-.*-native"
 FILES:mesa-megadriver = "${libdir}/dri/* ${datadir}/drirc.d"
 FILES:mesa-vulkan-drivers = "${libdir}/libvulkan_*.so ${datadir}/vulkan"
 FILES:${PN}-vdpau-drivers = "${libdir}/vdpau/*.so.*"
-FILES:libegl-mesa = "${libdir}/libEGL.so.*"
+FILES:libegl-mesa = "${libdir}/libEGL*.so.*"
 FILES:libgbm = "${libdir}/libgbm.so.*"
 FILES:libgles1-mesa = "${libdir}/libGLESv1*.so.*"
 FILES:libgles2-mesa = "${libdir}/libGLESv2.so.*"
 FILES:libgl-mesa = "${libdir}/libGL.so.*"
+FILES:libglx-mesa = "${libdir}/libGLX*.so.* ${datadir}/glvnd"
 FILES:libopencl-mesa = "${libdir}/libMesaOpenCL.so.* ${libdir}/gallium-pipe/*.so ${sysconfdir}/OpenCL/vendors/mesa.icd"
 FILES:libglapi = "${libdir}/libglapi.so.*"
 FILES:libosmesa = "${libdir}/libOSMesa.so.*"
 FILES:libxatracker = "${libdir}/libxatracker.so.*"
 
 FILES:${PN}-dev = "${libdir}/pkgconfig/dri.pc ${includedir}/vulkan ${libdir}/vdpau/*.so"
-FILES:libegl-mesa-dev = "${libdir}/libEGL.* ${includedir}/EGL ${includedir}/KHR ${libdir}/pkgconfig/egl.pc"
+FILES:libegl-mesa-dev = "${libdir}/libEGL*.so.* ${includedir}/EGL ${includedir}/KHR ${libdir}/pkgconfig/egl.pc"
 FILES:libgbm-dev = "${libdir}/libgbm.* ${libdir}/pkgconfig/gbm.pc ${includedir}/gbm.h"
 FILES:libgl-mesa-dev = "${libdir}/libGL.* ${includedir}/GL ${libdir}/pkgconfig/gl.pc"
+FILES:libglx-mesa-dev = "${libdir}/libGLX*.*"
 FILES:libglapi-dev = "${libdir}/libglapi.*"
 FILES:libgles1-mesa-dev = "${libdir}/libGLESv1*.* ${includedir}/GLES ${libdir}/pkgconfig/glesv1*.pc"
 FILES:libgles2-mesa-dev = "${libdir}/libGLESv2.* ${includedir}/GLES2 ${libdir}/pkgconfig/glesv2.pc"
Signature · 1 line
2.34.1
#1 lore raw

One issue. Can't seem to get libGLX_mesa.so* included unless I add libglx to the RDEPENDS of another recipe.

#2 lore raw
Quoted 2 lines · Vincent Davis Jr via lists.openembedded.org

One issue. Can't seem to get libGLX_mesa.so* included unless I add libglx to the RDEPENDS of another recipe.

Included in an image? That’s right: you split it into a separate library package, and if nothing depends on it then it won’t get included.

Ross

#3 lore raw

Yeah, but I couldn't find where runtime depend for libegl is set and libEGL_mesa.* gets include in image as runtime dependency without me directly setting it. A bit of confusion there for me. Feel as if I shouldn't need to RDEPENDS:${PN} = "libglx" in recipe that requires it. Should just be included in image as libegl is. Is there a way to avoid RDEPENDS:${PN} = "libglx"?

#4 lore raw
Quoted 7 lines · Vincent Davis Jr

Yeah, but I couldn't find where runtime depend for libegl is set and libEGL_mesa.* gets include in image as runtime dependency without me directly setting it. A bit of confusion there for me. Feel as if I shouldn't need to RDEPENDS:${PN} = "libglx" in recipe that requires it. Should just be included in image as libegl is. Is there a way to avoid RDEPENDS:${PN} = "libglx"?

It would not be necessary if something that dynamically links with these libraries is included in the image. Then the package task for that something will find out that these libraries are needed, will trace them to the packages that contain them, and insert RDEPENDS for those packages automatically.

If the libraries are open with dlopen( ) at runtime, then yocto's packaging does not detect that, and you need to add a manual RDEPENDS.

Alex

#5 lore raw
In reply to Vincent Davis Jr

meta/recipes-graphics/mesa/mesa.inc UPSTREAM_CHECK_GITTAGREGEX = "mesa-(?P<pver>\d+(\.\d+)+)" · line 39

Quoted 8 lines · Vincent Davis Jr
meta/recipes-graphics/mesa/mesa.inc +5 -0
+    # sed can't find EGL/eglplatform.h as it doesn't get installed when glvnd enabled
+    if ${@bb.utils.contains('PACKAGECONFIG', 'openglx', 'true', 'false', d)}; then
+        return 0
+    fi
+
     if ${@bb.utils.contains('PACKAGECONFIG', 'egl', 'true', 'false', d)}; then
         sed -i -e 's/^#elif defined(__unix__) && defined(EGL_NO_X11)$/#elif defined(__unix__) \&\& defined(EGL_NO_X11) || ${@bb.utils.contains('PACKAGECONFIG', 'x11', '0', '1', d)}/' ${D}${includedir}/EGL/eglplatform.h
     fi

This needs to be replaced with a direct check of EGL/eglplatform.h existence in the existing if block.

meta/recipes-graphics/mesa/mesa.inc DEPENDS = "expat makedepend-native flex-native bison-native libxml2-native zlib · line 46

Quoted 5 lines
meta/recipes-graphics/mesa/mesa.inc +1 -0
@@ -38,6 +43,7 @@ DEPENDS = "expat makedepend-native flex-native bison-native libxml2-native zlib
 EXTRANATIVEPATH += "chrpath-native"
 PROVIDES = " \
     ${@bb.utils.contains('PACKAGECONFIG', 'opengl', 'virtual/libgl', '', d)} \
+    ${@bb.utils.contains('DISTRO_FEATURES', 'opengl x11', 'virtual/libglx', '', d)} \

Why DISTRO_FEATURES and not PACKAGECONFIG like others?

meta/recipes-graphics/mesa/mesa.inc VULKAN_DRIVERS:append ="${@bb.utils.contains('PACKAGECONFIG', 'broadcom', ',broa · line 125

Quoted 8 lines
meta/recipes-graphics/mesa/mesa.inc +1 -0
     ${@bb.utils.contains('PACKAGECONFIG', 'gles', 'virtual/libgles1 virtual/libgles2 virtual/libgles3', '', d)} \
     ${@bb.utils.contains('PACKAGECONFIG', 'egl', 'virtual/egl', '', d)} \
     ${@bb.utils.contains('PACKAGECONFIG', 'gbm', 'virtual/libgbm', '', d)} \
@@ -116,6 +122,7 @@ VULKAN_DRIVERS:append ="${@bb.utils.contains('PACKAGECONFIG', 'broadcom', ',broa
 PACKAGECONFIG[vulkan] = "-Dvulkan-drivers=${@strip_comma('${VULKAN_DRIVERS}')}, -Dvulkan-drivers='',glslang-native vulkan-loader vulkan-headers"
 
 PACKAGECONFIG[opengl] = "-Dopengl=true, -Dopengl=false"
+PACKAGECONFIG[openglx] = "-Dglvnd=true, -Dglvnd=false,libglvnd"

Packageconfig option should be named glvnd too.

Alex