You are not logged in.

#1 2010-03-05 08:54:24

slightlystoopid
Member
Registered: 2009-09-10
Posts: 61

eselect-opengl-like functionality for nvidia-utils and libgl

An easy solution for anyone who wishes to use mesa gl libraries, e.g. with nouveau, while still being able to fallback on nvidia gl libraries, e.g. for 3d performance.

Really, nvidia is the only driver that will run my displays correctly. nv fails, but I'm hoping nouveau will somehow be able to do it, so I find myself wanting to switch between the two libraries easily.

The conflict between libgl and nvidia*-utils appears to fall on three little symlinks.  We have to remove them from the packages, so grab extra/mesa from abs, libgl-git from aur, or equivalent.

In the libgl build function of the PKGBUILD, make these changes:

    bin/minstall lib/libGL.so* "${pkgdir}/usr/lib/" || return 1

+    # Allow nvidia compatibility through link switching
+    rm $pkgdir/usr/lib/libGL.so || return 1
+    rm $pkgdir/usr/lib/libGL.so.1 || return 1

    cd src/mesa/drivers/dri
    make -C swrast DESTDIR="${pkgdir}" install || return 1
    install -m755 libdricore.so "${pkgdir}/usr/lib/xorg/modules/dri/" || return 1
-    ln -s libglx.xorg "${pkgdir}/usr/lib/xorg/modules/extensions/libglx.so" || return 1
+    # Allow nvidia compatibility through link switching
+    #ln -s libglx.xorg "${pkgdir}/usr/lib/xorg/modules/extensions/libglx.so" || return 1

Grab your nvidia*-utils package from abs, and in the PKGBUILD, comment out/remove some junk like so:

-conflicts=('libgl')
-provides=('libgl')

...

    install -m755 bin/nvidia-{settings,xconfig,bug-report.sh} $pkgdir/usr/bin/ || return 1
    cd $pkgdir/usr/lib/
-    ln -s libGL.so.$pkgver libGL.so || return 1
-    ln -s libGL.so.$pkgver libGL.so.1 || return 1
+    # Allow mesa compatibility through link switching
+    #ln -s libGL.so.$pkgver libGL.so || return 1
+    #ln -s libGL.so.$pkgver libGL.so.1 || return 1
    ln -s libGLcore.so.$pkgver libGLcore.so.1 || return 1
    ln -s libnvidia-cfg.so.$pkgver libnvidia-cfg.so.1 || return 1
    ln -s libnvidia-tls.so.$pkgver libnvidia-tls.so.1 || return 1
    ln -s libcuda.so.$pkgver libcuda.so.1 || return 1
    ln -s libcuda.so.$pkgver libcuda.so || return 1
    ln -s libXvMCNVIDIA.so.$pkgver libXvMCNVIDIA_dynamic.so.1 || return 1

    cd $pkgdir/usr/lib/xorg/modules/extensions
-    ln -s libglx.so.$pkgver libglx.so || return 1
+    # Allow mesa compatiblity through link switching
+    #ln -s libglx.so.$pkgver libglx.so || return 1

Build, install. Now we have to set these symlinks ourselves to point where we want. I use the following script, so stick it somewhere in your $PATH; I use $HOME/bin. Run it whenever you want to switch link targets:

#!/bin/bash
#
# glselect - switch between mesa and nvidia gl libraries
#

newlib="$1"

if [ -e /usr/lib/libGLcore.so.1 ]
then
    for i in `ls -l /usr/lib/libGLcore.so.1`
    do
        nvver=${i//libGLcore.so.}
    done
elif [[ "$newlib" = "nvidia" ]]
then
    echo "You do not have nvidia*-utils installed."
    exit 1
fi

if [[ "$newlib" = "mesa" ]]
then
    ln -sf libGL.so.1.2 /usr/lib/libGL.so
    ln -sf libGL.so.1.2 /usr/lib/libGL.so.1
    ln -sf libglx.xorg /usr/lib/xorg/modules/extensions/libglx.so
elif [[ "$newlib" = "nvidia" ]]
then
    ln -sf libGL.so.${nvver} /usr/lib/libGL.so
    ln -sf libGL.so.${nvver} /usr/lib/libGL.so.1
    ln -sf libglx.so.${nvver} /usr/lib/xorg/modules/extensions/libglx.so
elif [[ "$newlib" = "show" ]]
then
    if [[ `readlink /usr/lib/libGL.so` = "libGL.so.1.2" ]]
    then
        echo "mesa"
    elif [[ `readlink /usr/lib/libGL.so` = "libGL.so.${nvver}" ]]
    then
        echo "nvidia"
    else
        echo "You have not setup symlinks yet."
        exit 1
    fi
else
    echo "Usage: glselect [ mesa | nvidia | show ]"
fi

exit

Now, modify your xorg.conf file to include two (or whatever) ServerLayout, Screen, and Card sections (and probably Monitor, whatever's appropriate), one for each driver, e.g. nvidia, nouveau, etc.

And if you're not using a display manager, you'll probably want some aliases in your .bashrc to point to the desired layout, e.g. `alias startxnvidia='startx -- -layout Nvidia'`.

That's it. Hope somebody finds this useful.


One nation, under the corporatocracy, indivisible, with liberty for them.

Really, I can understand the Supreme Court's rulings. Afterall, corporations are people just like us, with love and feelings, hopes and dreams, and a limited lifespan to do it all in... oh wait, nevermind. I was thinking of same-sex marriage.

Offline

#2 2010-03-14 00:42:33

shining
Pacman Developer
Registered: 2006-05-10
Posts: 2,043

Re: eselect-opengl-like functionality for nvidia-utils and libgl

That's definitely interesting. I wonder if there would be a strong opposition for making these changes official.
Allowing an easier and smoother switch between nvidia and nouveau is cool, I will try your packages next time I want to switch back.
I actually have a few things to test with the blob but I didn't because I am lazy to change it.


pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))

Offline

#3 2010-03-21 09:48:07

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 6,832

Re: eselect-opengl-like functionality for nvidia-utils and libgl

I'd recommend that the .install files be used to set initial symlinks, if this was to be made official. The last installed package would take precedence, that way. I'd like to easily switch between, as well.


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

#4 2010-03-21 16:49:08

some-guy94
Member
Registered: 2009-08-15
Posts: 360

Re: eselect-opengl-like functionality for nvidia-utils and libgl

It would be nice if this could have some integration with pacman(maybe just put it in the .install file?) so that if I removed nvidia-utils while it was being glselected, it would spit out a warning.

Offline

#5 2010-03-21 20:22:28

slightlystoopid
Member
Registered: 2009-09-10
Posts: 61

Re: eselect-opengl-like functionality for nvidia-utils and libgl


One nation, under the corporatocracy, indivisible, with liberty for them.

Really, I can understand the Supreme Court's rulings. Afterall, corporations are people just like us, with love and feelings, hopes and dreams, and a limited lifespan to do it all in... oh wait, nevermind. I was thinking of same-sex marriage.

Offline

#6 2010-03-22 03:11:22

some-guy94
Member
Registered: 2009-08-15
Posts: 360

Re: eselect-opengl-like functionality for nvidia-utils and libgl

Since I was thinking that it would be nice if there was a general way to do this (not have a glselect, jvmselect, etc), I started working on something.

I know it can be made better, suggestions/patches welcome.
pselect-git
nvidia-utils-pselect
libgl-git-pselect

Offline

Board footer

Powered by FluxBB