A rough overview of using NVIDIA Optimus on FreeBSD.

Initial port/PR: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=192617

Make sure nVIDIA Optimus is enabled in BIOS.

Install graphics/libjpeg-turbo and lang/gcc47. Make sure to tick the PIC option on make config for libjpeg-turbo.

Now download VirtualGL and build it (fairly simple, CMake based. You might need to tweak a single file or two to account for a certain function being defined elsewhere on FreeBSD, I forgot. Also, set CC=gcc47 and CXX=g++47 beforehand).

Now, install x11/nvidia-driver. Be warned that when you next update graphics/libGL, it will try to create a symlink from the nVIDIA libGL.so in %LOCALBASE%/lib/.nvidia to %LOCALBASE%/lib/libGL.so! Don't let it do that.

Now you must configure a /etc/X11/xorg.conf.nv. Mine looks a little like this:

Section "ServerLayout"
    Identifier "Layout0"
    Option "AutoAddDevices" "false"
    InputDevice "fake" "CorePointer"
EndSection
Section "Device"
    Identifier "Device1"
    Driver "nvidia"
    VendorName "NVIDIA Corporation"
    BusID "PCI:01:00:0"
    Option "NoLogo" "true"
    Option "UseEDID" "false"
    Option "ConnectedMonitor" "DFP"
EndSection

Section "InputDevice"
        Identifier "fake"
        Driver ""
EndSection

Modify xmj's turn_off_nvidia.sh replacing all _OFF/DOFF/SDOF and so on to read ON instead. Execute it. Now kldload nvidia

We can test this now. Run X -conf xorg.conf.nv -sharevts -noreset :8 in bg. Now run /opt/VirtualGL/bin/vglrun -ld /usr/local/lib/.nvidia/ -d ":8" glxgears Did it work? Congratulations!

And to turn off nVIDIA, simply end the running X server on the nVIDIA card, kldunload nvidia, and execute turn_off_nvidia.sh

OptimusVideoSupport (last edited 2015-12-03 03:22:07 by WarrenBlock)