opengl: Use glxgallium Mesa when VirtualGL is not appropriate
This commit is contained in:
@@ -26,7 +26,7 @@ self: super: pkgs: with pkgs; {
|
|||||||
|
|
||||||
minia = callPackage ./minia.nix { };
|
minia = callPackage ./minia.nix { };
|
||||||
|
|
||||||
inherit (callPackage ./opengl/default.nix { inherit super; }) libGL;
|
inherit (callPackage ./opengl/default.nix { inherit super; }) libGL mesa_glxgallium;
|
||||||
|
|
||||||
inherit (callPackages ./octopus/octopus.nix { stdenv = overrideCC stdenv gcc5; gfortran = gfortran5; }) octopus72;
|
inherit (callPackages ./octopus/octopus.nix { stdenv = overrideCC stdenv gcc5; gfortran = gfortran5; }) octopus72;
|
||||||
octopus7 = octopus72;
|
octopus7 = octopus72;
|
||||||
|
|||||||
@@ -3,7 +3,9 @@
|
|||||||
# Add a setup hook to the mesa_noglu package that automatically adds
|
# Add a setup hook to the mesa_noglu package that automatically adds
|
||||||
# a libvglfaker.so dependency to executables that depend on libGL.so.
|
# a libvglfaker.so dependency to executables that depend on libGL.so.
|
||||||
|
|
||||||
{ super, lib, buildEnv, makeSetupHook, file, bash, xorg }:
|
{ super, stdenv, buildEnv, substituteAll, bash
|
||||||
|
, autoreconfHook, pkgconfig, python2
|
||||||
|
, xorg, llvmPackages, expat, mesa_glxgallium, mesa_noglu, libglvnd }:
|
||||||
|
|
||||||
let
|
let
|
||||||
autoVirtualGLHook =
|
autoVirtualGLHook =
|
||||||
@@ -15,28 +17,105 @@ let
|
|||||||
|
|
||||||
libGL = super.libGL;
|
libGL = super.libGL;
|
||||||
libGLU = super.libGLU.override { inherit libGL; };
|
libGLU = super.libGLU.override { inherit libGL; };
|
||||||
libGLU_combined = (buildEnv {
|
libGLU_combined = buildEnv {
|
||||||
name = "libGLU-combined";
|
name = "libGLU-combined";
|
||||||
paths = [ libGL libGLU ];
|
paths = [ libGL libGLU ];
|
||||||
extraOutputsToInstall = [ "dev" ];
|
extraOutputsToInstall = [ "dev" ];
|
||||||
});
|
};
|
||||||
|
|
||||||
virtualglLib = (super.virtualglLib.override { inherit libGLU_combined fltk; });
|
virtualglLib = (super.virtualglLib.override { inherit libGLU_combined fltk; });
|
||||||
fltk = super.fltk.override { inherit libGLU_combined freeglut; };
|
fltk = super.fltk.override { inherit libGLU_combined freeglut; };
|
||||||
freeglut = super.freeglut.override { inherit libGL libGLU; };
|
freeglut = super.freeglut.override { inherit libGL libGLU; };
|
||||||
in
|
in
|
||||||
makeSetupHook {
|
substituteAll {
|
||||||
name = "insert-virtualgl";
|
src = ./insert-virtualgl.sh;
|
||||||
deps = [ file virtualglLib ];
|
bash = "${bash}/bin/bash";
|
||||||
substitutions = { inherit virtualglLib bash; inherit (xorg) libXext; };
|
virtualglLib = "${virtualglLib}/lib/libvglfaker.so";
|
||||||
} ./insert-virtualgl.sh;
|
};
|
||||||
|
|
||||||
in {
|
in {
|
||||||
libGL = super.libGL.overrideAttrs ( attrs: {
|
|
||||||
# Done as a non-standard build command, so have to add it in this way
|
|
||||||
|
|
||||||
buildCommand = attrs.buildCommand + ''
|
# Mesa build for glxgallium software rendering (works with all X11 forwarding)
|
||||||
echo '${autoVirtualGLHook}' >> $dev/nix-support/propagated-build-inputs
|
|
||||||
|
mesa_glxgallium = stdenv.mkDerivation rec {
|
||||||
|
version = super.mesa_noglu.version;
|
||||||
|
name = "mesa-glxgallium-${version}";
|
||||||
|
src = super.mesa_noglu.src;
|
||||||
|
|
||||||
|
outputs = [ "out" "dev" ];
|
||||||
|
|
||||||
|
configureFlags = [
|
||||||
|
"--with-gallium-drivers=swrast"
|
||||||
|
"--with-platforms=x11" # surfaceless would make sense, but egl requires dri
|
||||||
|
"--disable-dri"
|
||||||
|
"--enable-glx=gallium-xlib" # gallium-xlib requires no dri
|
||||||
|
"--enable-gallium-osmesa"
|
||||||
|
"--enable-llvm"
|
||||||
|
"--disable-egl" # egl requries dri for some reason
|
||||||
|
"--disable-gbm" # gbm requires dri for some reason
|
||||||
|
"--enable-llvm-shared-libs"
|
||||||
|
"--disable-opencl"
|
||||||
|
];
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
autoreconfHook pkgconfig
|
||||||
|
python2
|
||||||
|
];
|
||||||
|
propagatedBuildInputs = [ ];
|
||||||
|
buildInputs = [
|
||||||
|
llvmPackages.llvm
|
||||||
|
xorg.xorgproto xorg.libX11 xorg.libXext xorg.libxcb
|
||||||
|
expat
|
||||||
|
];
|
||||||
|
|
||||||
|
enableParallelBuilding = true;
|
||||||
|
|
||||||
|
meta = with stdenv.lib; {
|
||||||
|
description = "An open source implementation of OpenGL";
|
||||||
|
homepage = https://www.mesa3d.org/;
|
||||||
|
license = licenses.mit; # X11 variant, in most files
|
||||||
|
platforms = platforms.linux;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
# Duplicate mesa_noglu.stub with mesa_glxgallium stuffed in as the libGL source
|
||||||
|
|
||||||
|
libGL = stdenv.mkDerivation {
|
||||||
|
name = "libGL-${libglvnd.version}";
|
||||||
|
outputs = [ "out" "dev" ];
|
||||||
|
|
||||||
|
nativeBuildInputs = [ xorg.lndir ];
|
||||||
|
|
||||||
|
# Use stub libraries from mesa_glxgallium and libglvnd and headers from lib_noglu
|
||||||
|
buildCommand = ''
|
||||||
|
mkdir -p $out/lib
|
||||||
|
lndir -silent ${mesa_glxgallium.out}/lib $out/lib
|
||||||
|
lndir -silent ${libglvnd.out}/lib $out/lib
|
||||||
|
|
||||||
|
mkdir -p $dev/{,lib/pkgconfig,nix-support}
|
||||||
|
echo "$out" > $dev/nix-support/propagated-build-inputs
|
||||||
|
echo ${autoVirtualGLHook} >> $dev/nix-support/propagated-build-inputs
|
||||||
|
ln -s ${mesa_noglu.dev}/include $dev/include
|
||||||
|
|
||||||
|
genPkgConfig() {
|
||||||
|
local location="$1"
|
||||||
|
local name="$2"
|
||||||
|
local lib="$3"
|
||||||
|
|
||||||
|
cat <<EOF >$dev/lib/pkgconfig/$name.pc
|
||||||
|
Name: $name
|
||||||
|
Description: $lib library
|
||||||
|
Version: ${mesa_noglu.version}
|
||||||
|
Libs: -L$location/lib -l$lib
|
||||||
|
Cflags: -I${mesa_noglu.dev}/include
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
genPkgConfig ${mesa_glxgallium.out} gl GL
|
||||||
|
genPkgConfig ${libglvnd.out} egl EGL
|
||||||
|
genPkgConfig ${libglvnd.out} glesv1_cm GLESv1_CM
|
||||||
|
genPkgConfig ${libglvnd.out} glesv2 GLESv2
|
||||||
'';
|
'';
|
||||||
} );
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -205,29 +205,22 @@ VGL_patch() {
|
|||||||
#
|
#
|
||||||
# mv "$file" "${file%/*}/.${file##*/}.vgl"
|
# mv "$file" "${file%/*}/.${file##*/}.vgl"
|
||||||
# cat > "$file" <<EOF
|
# cat > "$file" <<EOF
|
||||||
#! @bash@/bin/bash
|
#! @bash@
|
||||||
# exec -a "\$0" "$(patchelf --print-interpreter "${file%/*}/.${file##*/}.vgl")" \${VGL_DISPLAY:+--preload "@virtualglLib@/lib/libvglfaker.so"} "${file%/*}/.${file##*/}.vgl" "\$@"
|
# exec -a "\$0" "$(patchelf --print-interpreter "${file%/*}/.${file##*/}.vgl")" \${VGL_DISPLAY:+--preload "@virtualglLib@"} "${file%/*}/.${file##*/}.vgl" "\$@"
|
||||||
# EOF
|
# EOF
|
||||||
# chmod +x "$file"
|
# chmod +x "$file"
|
||||||
|
|
||||||
# VGL version may need fixing up to ensure libglfaker.so gets loaded at the start
|
# VGL version may need fixing up to ensure libglfaker.so gets loaded at the start
|
||||||
|
|
||||||
printf 'Wrapping and patching for VirtualGL: %q\n' "$file" >&2
|
printf 'Wrapping and patching for VirtualGL: %q\n' "$file" >&2
|
||||||
cp -a "$file" "${file%/*}/.${file##*/}.vgl-yes"
|
cp -a "$file" "${file%/*}/.${file##*/}.vgl-yes"
|
||||||
VGL_elfFilterLibsS "${file%/*}/.${file##*/}.vgl-yes" 'VGL_testSuffixNoneS '"$(VGL_quote '[[ $1 =~ ^(.*/)?libvglfaker.so ]]')"' @virtualglLib@/lib/libvglfaker.so'
|
VGL_elfFilterLibsS "${file%/*}/.${file##*/}.vgl-yes" 'VGL_testSuffixNoneS '"$(VGL_quote '[[ $1 =~ ^(.*/)?libvglfaker.so ]]')"' @virtualglLib@/lib/libvglfaker.so'
|
||||||
# patchelf --add-needed @virtualglLib@/lib/libvglfaker.so "${file%/*}/.${file##*/}.vgl-yes"
|
|
||||||
|
|
||||||
# Non-VGL versions may need fixing to load libXext so NVIDIA binary libs are happy
|
|
||||||
#
|
|
||||||
# Ugly, but putting this here instead of with the NVIDIA libs, allows us not to to fix one version for all
|
|
||||||
|
|
||||||
|
# Non-VGL is fine as we link it against mesa_glxgallium
|
||||||
mv "$file" "${file%/*}/.${file##*/}.vgl-no"
|
mv "$file" "${file%/*}/.${file##*/}.vgl-no"
|
||||||
VGL_elfFilterLibsS "${file%/*}/.${file##*/}.vgl-no" 'VGL_testSuffixNoneS '"$(VGL_quote '[[ $1 =~ ^(.*/)?libXext.so ]]')"' libXext.so.6'
|
|
||||||
VGL_elfFilterRPathS "${file%/*}/.${file##*/}.vgl-no" 'VGL_testSuffixNoneS '"$(VGL_quote '[[ $1 = @libXext@/lib ]]')"' @libXext@/lib'
|
|
||||||
|
|
||||||
# Replace with chooser script based on whether VGL_DISPLAY is set or not
|
# Replace with chooser script based on whether VGL_DISPLAY is set or not
|
||||||
cat > "$file" <<EOF
|
cat > "$file" <<EOF
|
||||||
#! @bash@/bin/bash
|
#! @bash@
|
||||||
|
|
||||||
if [ -z "\$VGL_DISPLAY" ]; then
|
if [ -z "\$VGL_DISPLAY" ]; then
|
||||||
exec -a "\$0" "${file%/*}/.${file##*/}.vgl-no" "\$@"
|
exec -a "\$0" "${file%/*}/.${file##*/}.vgl-no" "\$@"
|
||||||
|
|||||||
Reference in New Issue
Block a user