I’d like to thank @alan_g and other members of the Mir team for working on graphics-core20

I’ve added graphics-core20
to a local branch of the OBS Studio snap, the diff is included below as it might be useful to others.
One thing to note, is I had to expose the environment variable coercion in an existing wrapper I use to launch OBS, as they didn’t take affect when added to environment:
stanzas in the snapcraft.yaml
. The wrapper, is also the last script in the command-chain. Here’s the diff:
diff --git a/snap/local/obs-wrapper b/snap/local/obs-wrapper
index 06ceb43..9936fc5 100755
--- a/snap/local/obs-wrapper
+++ b/snap/local/obs-wrapper
@@ -33,5 +33,11 @@ if [[ ${@} == *"usr/bin/obs"* ]]; then
fi
fi
+# Support for graphics-core20
+export LD_LIBRARY_PATH="${SNAP}/graphics/lib:${LD_LIBRARY_PATH}"
+export LIBGL_DRIVERS_PATH="${SNAP}/graphics/dri"
+export LIBVA_DRIVERS_PATH="${SNAP}/graphics/dri"
+export __EGL_VENDOR_LIBRARY_DIRS="${SNAP}/graphics/glvnd/egl_vendor.d"
+
unset SESSION_MANAGER
exec "${@}"
diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml
index d017bac..10df27b 100644
--- a/snap/snapcraft.yaml
+++ b/snap/snapcraft.yaml
@@ -9,6 +9,12 @@ architectures:
compression: lzo
plugs:
+ # Support for graphics-core20
+ # https://discourse.ubuntu.com/t/the-graphics-core20-snap-interface/23000
+ graphics-core20:
+ interface: content
+ target: $SNAP/graphics
+ default-provider: mesa-core20
# Support for common GTK themes
# https://forum.snapcraft.io/t/how-to-use-the-system-gtk-theme-via-the-gtk-common-themes-snap/6235
gtk-3-themes:
@@ -43,8 +49,12 @@ layout:
symlink: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libvulkan_radeon.so
/usr/share/alsa:
symlink: $SNAP/usr/share/alsa
- /usr/share/libdrm/amdgpu.ids:
- symlink: $SNAP/usr/share/libdrm/amdgpu.ids
+ # Used by mesa-core20 for app specific workarounds
+ /usr/share/drirc.d:
+ bind: $SNAP/graphics/drirc.d
+ # Needed by mesa-core20 on AMD GPUs
+ /usr/share/libdrm:
+ bind: $SNAP/graphics/libdrm
/usr/share/obs:
symlink: $SNAP/usr/share/obs
/usr/share/X11:
@@ -1159,6 +1169,8 @@ parts:
cleanup:
plugin: nil
+ build-snaps:
+ - mesa-core20
after:
- aom
- cef
@@ -1180,11 +1192,14 @@ parts:
usr/share/GConf \
usr/share/apport \
usr/share/bug \
+ usr/share/drirc.d \
usr/share/fonts \
+ usr/share/glvnd \
usr/share/icons/Adwaita \
usr/share/icons/Humanity* \
usr/share/icons/LoginIcons \
usr/share/icons/ubuntu-mono-* \
+ usr/share/libdrm \
usr/share/lintian \
usr/share/man \
usr/share/pkgconfig; do
@@ -1195,3 +1210,8 @@ parts:
rm -rf ${SNAPCRAFT_PRIME}/usr/share/doc/*/examples || true
rm ${SNAPCRAFT_PRIME}/usr/share/doc/*/README* 2>/dev/null || true
find ${SNAPCRAFT_PRIME}/usr -type d -empty -delete || true
+
+ # graphics-core20 cleanup
+ cd /snap/mesa-core20/current/egl/lib
+ find . -type f,l -exec rm -f $SNAPCRAFT_PRIME/usr/lib/${SNAPCRAFT_ARCH_TRIPLET}/{} \;
+ rm -fr "$SNAPCRAFT_PRIME/usr/lib/${SNAPCRAFT_ARCH_TRIPLET}/dri"
I was also able to get the OBS Studio snap running simply pushing ${SNAP}/usr/lib/${SNAP_LAUNCHER_ARCH_TRIPLET}
to the front of LD_LIBRARY_PATH. Here’s the diff.
diff --git a/snap/local/obs-wrapper b/snap/local/obs-wrapper
index 06ceb43..da2e38d 100755
--- a/snap/local/obs-wrapper
+++ b/snap/local/obs-wrapper
@@ -33,5 +33,7 @@ if [[ ${@} == *"usr/bin/obs"* ]]; then
fi
fi
+export LD_LIBRARY_PATH="${SNAP}/usr/lib/${SNAP_LAUNCHER_ARCH_TRIPLET}:${LD_LIBRARY_PATH}"
+
unset SESSION_MANAGER
exec "${@}"
My question for @alan_g @ijohnson and @jamesh is which of the above approaches is the most robust?