amonakov / primus

Low-overhead client-side GPU offloading
ISC License
216 stars 20 forks source link

match_fbconfig returns NULL on nvidia-352 #183

Closed cnlohr closed 8 years ago

cnlohr commented 8 years ago

Not sure if I'm the only one, but I've got a laptop with a 940M and I'm on Linux Mint Mate 17. Bumblebee runs great, optirun -b virtualgl works just fine, but, primusrun or optirun -b primus both crash, pretty hard.

I ended up tracking it down to match_fbconfig. Something about the flags being passed in cause it to return 0. If, however, I modify the list to only include

int ncfg, attrs[] = { GLX_DOUBLEBUFFER, 0, None };

Everything works well. Not sure what's going on here, or if this is an acceptable longer-term solution.

amonakov commented 8 years ago

Please check that normal (Mesa/Intel) libGL is correctly set up, there's glsanity to help with that (provide output of glsanity-bbee here if unsure).

cnlohr commented 8 years ago

I am thoroughly confused. It seems that this is not needed if I compile with -m32 on my 64-bit system. No idea why.

With 64-bit, stock: won't run glxgears

Checking native (usually Mesa/i965) GL Running 32-bit tests info: libGL.so.1: loaded from: /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 info: libGL.so.1: symlink to: /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1.2.0 info: X display: :0.0 info: X Ext. "GLX": present info: X Ext. "NV-GLX": not present; OK for non-nVidia drivers info: GLX server: SGI info: GLX client: Mesa Project and SGI info: GL vendor: VMware, Inc. info: GL renderer: Gallium 0.4 on llvmpipe (LLVM 3.4, 256 bits) info: GL version: 2.1 Mesa 10.1.3 info: GL hw accelerated: no Running 64-bit tests info: libGL.so.1: loaded from: /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 info: libGL.so.1: symlink to: /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1.2.0 info: X display: :0.0 info: X Ext. "GLX": present info: X Ext. "NV-GLX": not present; OK for non-nVidia drivers info: GLX server: SGI info: GLX client: Mesa Project and SGI info: GL vendor: VMware, Inc. info: GL renderer: Gallium 0.4 on llvmpipe (LLVM 3.4, 256 bits) info: GL version: 2.1 Mesa 10.1.3 info: GL hw accelerated: no Checking secondary (usually NVIDIA) GL Running 32-bit tests info: libGL.so.1: loaded from: /usr/lib/nvidia-352/libGL.so.1 info: libGL.so.1: symlink to: /usr/lib/nvidia-352/libGL.so.352.79 info: X display: :8 info: X Ext. "GLX": present info: X Ext. "NV-GLX": present info: GLX server: NVIDIA Corporation info: GLX client: NVIDIA Corporation info: GL vendor: NVIDIA Corporation info: GL renderer: GeForce 940M/PCIe/SSE2 info: GL version: 4.5.0 NVIDIA 352.79 Running 64-bit tests info: libGL.so.1: loaded from: /usr/lib/nvidia-352/libGL.so.1 info: libGL.so.1: symlink to: /usr/lib/nvidia-352/libGL.so.352.79 info: X display: :8 info: X Ext. "GLX": present info: X Ext. "NV-GLX": present info: GLX server: NVIDIA Corporation info: GLX client: NVIDIA Corporation info: GL vendor: NVIDIA Corporation info: GL renderer: GeForce 940M/PCIe/SSE2 info: GL version: 4.5.0 NVIDIA 352.79 Testing offloading with primus Running 32-bit tests info: libGL.so.1: loaded from: /usr/lib/x86_64-linux-gnu/primus/libGL.so.1 info: X display: :0.0 info: X Ext. "GLX": present info: X Ext. "NV-GLX": not present; OK for non-nVidia drivers info: GLX server: NVIDIA Corporation info: GLX client: primus info: GL vendor: NVIDIA Corporation info: GL renderer: GeForce 940M/PCIe/SSE2 info: GL version: 4.5.0 NVIDIA 352.79 Running 64-bit tests info: libGL.so.1: loaded from: /usr/lib/x86_64-linux-gnu/primus/libGL.so.1 info: X display: :0.0 info: X Ext. "GLX": present info: X Ext. "NV-GLX": not present; OK for non-nVidia drivers info: GLX server: NVIDIA Corporation info: GLX client: primus info: GL vendor: NVIDIA Corporation info: GL renderer: GeForce 940M/PCIe/SSE2 info: GL version: 4.5.0 NVIDIA 352.79

With stock, 32-bit, WILL run glxgears:

Checking native (usually Mesa/i965) GL Running 32-bit tests info: libGL.so.1: loaded from: /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 info: libGL.so.1: symlink to: /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1.2.0 info: X display: :0.0 info: X Ext. "GLX": present info: X Ext. "NV-GLX": not present; OK for non-nVidia drivers info: GLX server: SGI info: GLX client: Mesa Project and SGI info: GL vendor: VMware, Inc. info: GL renderer: Gallium 0.4 on llvmpipe (LLVM 3.4, 256 bits) info: GL version: 2.1 Mesa 10.1.3 info: GL hw accelerated: no Running 64-bit tests info: libGL.so.1: loaded from: /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 info: libGL.so.1: symlink to: /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1.2.0 info: X display: :0.0 info: X Ext. "GLX": present info: X Ext. "NV-GLX": not present; OK for non-nVidia drivers info: GLX server: SGI info: GLX client: Mesa Project and SGI info: GL vendor: VMware, Inc. info: GL renderer: Gallium 0.4 on llvmpipe (LLVM 3.4, 256 bits) info: GL version: 2.1 Mesa 10.1.3 info: GL hw accelerated: no Checking secondary (usually NVIDIA) GL Running 32-bit tests info: libGL.so.1: loaded from: /usr/lib/nvidia-352/libGL.so.1 info: libGL.so.1: symlink to: /usr/lib/nvidia-352/libGL.so.352.79 info: X display: :8 info: X Ext. "GLX": present info: X Ext. "NV-GLX": present info: GLX server: NVIDIA Corporation info: GLX client: NVIDIA Corporation info: GL vendor: NVIDIA Corporation info: GL renderer: GeForce 940M/PCIe/SSE2 info: GL version: 4.5.0 NVIDIA 352.79 Running 64-bit tests info: libGL.so.1: loaded from: /usr/lib/nvidia-352/libGL.so.1 info: libGL.so.1: symlink to: /usr/lib/nvidia-352/libGL.so.352.79 info: X display: :8 info: X Ext. "GLX": present info: X Ext. "NV-GLX": present info: GLX server: NVIDIA Corporation info: GLX client: NVIDIA Corporation info: GL vendor: NVIDIA Corporation info: GL renderer: GeForce 940M/PCIe/SSE2 info: GL version: 4.5.0 NVIDIA 352.79 Testing offloading with primus Running 32-bit tests info: libGL.so.1: loaded from: /usr/lib/nvidia-352/libGL.so.1 info: libGL.so.1: symlink to: /usr/lib/nvidia-352/libGL.so.352.79 info: X display: :0.0 info: X Ext. "GLX": present info: X Ext. "NV-GLX": not present; OK for non-nVidia drivers info: GLX server: SGI info: GLX client: NVIDIA Corporation info: GLX Context: direct rendering not available info: GL vendor: VMware, Inc. info: GL renderer: Gallium 0.4 on llvmpipe (LLVM 3.4, 256 bits) info: GL version: 1.4 (2.1 Mesa 10.1.3) info: GL hw accelerated: no Running 64-bit tests info: libGL.so.1: loaded from: /usr/lib/nvidia-352/libGL.so.1 info: libGL.so.1: symlink to: /usr/lib/nvidia-352/libGL.so.352.79 info: X display: :0.0 info: X Ext. "GLX": present info: X Ext. "NV-GLX": not present; OK for non-nVidia drivers info: GLX server: SGI info: GLX client: NVIDIA Corporation info: GLX Context: direct rendering not available info: GL vendor: VMware, Inc. info: GL renderer: Gallium 0.4 on llvmpipe (LLVM 3.4, 256 bits) info: GL version: 1.4 (2.1 Mesa 10.1.3) info: GL hw accelerated: no

64-bit, my version (Will run glxgears):

Checking native (usually Mesa/i965) GL Running 32-bit tests info: libGL.so.1: loaded from: /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 info: libGL.so.1: symlink to: /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1.2.0 info: X display: :0.0 info: X Ext. "GLX": present info: X Ext. "NV-GLX": not present; OK for non-nVidia drivers info: GLX server: SGI info: GLX client: Mesa Project and SGI info: GL vendor: VMware, Inc. info: GL renderer: Gallium 0.4 on llvmpipe (LLVM 3.4, 256 bits) info: GL version: 2.1 Mesa 10.1.3 info: GL hw accelerated: no Running 64-bit tests info: libGL.so.1: loaded from: /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 info: libGL.so.1: symlink to: /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1.2.0 info: X display: :0.0 info: X Ext. "GLX": present info: X Ext. "NV-GLX": not present; OK for non-nVidia drivers info: GLX server: SGI info: GLX client: Mesa Project and SGI info: GL vendor: VMware, Inc. info: GL renderer: Gallium 0.4 on llvmpipe (LLVM 3.4, 256 bits) info: GL version: 2.1 Mesa 10.1.3 info: GL hw accelerated: no Checking secondary (usually NVIDIA) GL Running 32-bit tests info: libGL.so.1: loaded from: /usr/lib/nvidia-352/libGL.so.1 info: libGL.so.1: symlink to: /usr/lib/nvidia-352/libGL.so.352.79 info: X display: :8 info: X Ext. "GLX": present info: X Ext. "NV-GLX": present info: GLX server: NVIDIA Corporation info: GLX client: NVIDIA Corporation info: GL vendor: NVIDIA Corporation info: GL renderer: GeForce 940M/PCIe/SSE2 info: GL version: 4.5.0 NVIDIA 352.79 Running 64-bit tests info: libGL.so.1: loaded from: /usr/lib/nvidia-352/libGL.so.1 info: libGL.so.1: symlink to: /usr/lib/nvidia-352/libGL.so.352.79 info: X display: :8 info: X Ext. "GLX": present info: X Ext. "NV-GLX": present info: GLX server: NVIDIA Corporation info: GLX client: NVIDIA Corporation info: GL vendor: NVIDIA Corporation info: GL renderer: GeForce 940M/PCIe/SSE2 info: GL version: 4.5.0 NVIDIA 352.79 Testing offloading with primus Running 32-bit tests info: libGL.so.1: loaded from: /usr/lib/x86_64-linux-gnu/primus/libGL.so.1 info: X display: :0.0 info: X Ext. "GLX": present info: X Ext. "NV-GLX": not present; OK for non-nVidia drivers info: GLX server: NVIDIA Corporation info: GLX client: primus info: GL vendor: NVIDIA Corporation info: GL renderer: GeForce 940M/PCIe/SSE2 info: GL version: 4.5.0 NVIDIA 352.79 Running 64-bit tests info: libGL.so.1: loaded from: /usr/lib/x86_64-linux-gnu/primus/libGL.so.1 info: X display: :0.0 info: X Ext. "GLX": present info: X Ext. "NV-GLX": not present; OK for non-nVidia drivers info: GLX server: NVIDIA Corporation info: GLX client: primus info: GL vendor: NVIDIA Corporation info: GL renderer: GeForce 940M/PCIe/SSE2 info: GL version: 4.5.0 NVIDIA 352.79`

32-bit version, my changes... Also runs fine.

Checking native (usually Mesa/i965) GL Running 32-bit tests info: libGL.so.1: loaded from: /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 info: libGL.so.1: symlink to: /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1.2.0 info: X display: :0.0 info: X Ext. "GLX": present info: X Ext. "NV-GLX": not present; OK for non-nVidia drivers info: GLX server: SGI info: GLX client: Mesa Project and SGI info: GL vendor: VMware, Inc. info: GL renderer: Gallium 0.4 on llvmpipe (LLVM 3.4, 256 bits) info: GL version: 2.1 Mesa 10.1.3 info: GL hw accelerated: no Running 64-bit tests info: libGL.so.1: loaded from: /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 info: libGL.so.1: symlink to: /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1.2.0 info: X display: :0.0 info: X Ext. "GLX": present info: X Ext. "NV-GLX": not present; OK for non-nVidia drivers info: GLX server: SGI info: GLX client: Mesa Project and SGI info: GL vendor: VMware, Inc. info: GL renderer: Gallium 0.4 on llvmpipe (LLVM 3.4, 256 bits) info: GL version: 2.1 Mesa 10.1.3 info: GL hw accelerated: no Checking secondary (usually NVIDIA) GL Running 32-bit tests info: libGL.so.1: loaded from: /usr/lib/nvidia-352/libGL.so.1 info: libGL.so.1: symlink to: /usr/lib/nvidia-352/libGL.so.352.79 info: X display: :8 info: X Ext. "GLX": present info: X Ext. "NV-GLX": present info: GLX server: NVIDIA Corporation info: GLX client: NVIDIA Corporation info: GL vendor: NVIDIA Corporation info: GL renderer: GeForce 940M/PCIe/SSE2 info: GL version: 4.5.0 NVIDIA 352.79 Running 64-bit tests info: libGL.so.1: loaded from: /usr/lib/nvidia-352/libGL.so.1 info: libGL.so.1: symlink to: /usr/lib/nvidia-352/libGL.so.352.79 info: X display: :8 info: X Ext. "GLX": present info: X Ext. "NV-GLX": present info: GLX server: NVIDIA Corporation info: GLX client: NVIDIA Corporation info: GL vendor: NVIDIA Corporation info: GL renderer: GeForce 940M/PCIe/SSE2 info: GL version: 4.5.0 NVIDIA 352.79 Testing offloading with primus Running 32-bit tests info: libGL.so.1: loaded from: /usr/lib/nvidia-352/libGL.so.1 info: libGL.so.1: symlink to: /usr/lib/nvidia-352/libGL.so.352.79 info: X display: :0.0 info: X Ext. "GLX": present info: X Ext. "NV-GLX": not present; OK for non-nVidia drivers info: GLX server: SGI info: GLX client: NVIDIA Corporation info: GLX Context: direct rendering not available info: GL vendor: VMware, Inc. info: GL renderer: Gallium 0.4 on llvmpipe (LLVM 3.4, 256 bits) info: GL version: 1.4 (2.1 Mesa 10.1.3) info: GL hw accelerated: no Running 64-bit tests info: libGL.so.1: loaded from: /usr/lib/nvidia-352/libGL.so.1 info: libGL.so.1: symlink to: /usr/lib/nvidia-352/libGL.so.352.79 info: X display: :0.0 info: X Ext. "GLX": present info: X Ext. "NV-GLX": not present; OK for non-nVidia drivers info: GLX server: SGI info: GLX client: NVIDIA Corporation info: GLX Context: direct rendering not available info: GL vendor: VMware, Inc. info: GL renderer: Gallium 0.4 on llvmpipe (LLVM 3.4, 256 bits) info: GL version: 1.4 (2.1 Mesa 10.1.3) info: GL hw accelerated: no`

The key differences between 'works' and 'doesn't work' (32- and 64- stock differences)

diff /tmp/glstuff32 /tmp/glstuff64 51,52c51 _< info: libGL.so.1: loaded from: /usr/lib/nvidia-352/libGL.so.1

_< info: libGL.so.1: symlink to: /usr/lib/nvidia-352/libGL.so.352.79

_> info: libGL.so.1: loaded from: /usr/lib/x8664-linux-gnu/primus/libGL.so.1 56,62c55,59 < info: GLX server: SGI < info: GLX client: NVIDIA Corporation < info: GLX Context: direct rendering not available < info: GL vendor: VMware, Inc. < info: GL renderer: Gallium 0.4 on llvmpipe (LLVM 3.4, 256 bits) _< info: GL version: 1.4 (2.1 Mesa 10.1.3)

_< info: GL hw accelerated: no

> info: GLX server: NVIDIA Corporation > info: GLX client: primus > info: GL vendor: NVIDIA Corporation > info: GL renderer: GeForce 940M/PCIe/SSE2 > info: GL version: 4.5.0 NVIDIA 352.79 64,65c61 < info: libGL.so.1: loaded from: /usr/lib/nvidia-352/libGL.so.1

_< info: libGL.so.1: symlink to: /usr/lib/nvidia-352/libGL.so.352.79

_> info: libGL.so.1: loaded from: /usr/lib/x8664-linux-gnu/primus/libGL.so.1 69,75c65,69 < info: GLX server: SGI < info: GLX client: NVIDIA Corporation < info: GLX Context: direct rendering not available < info: GL vendor: VMware, Inc. < info: GL renderer: Gallium 0.4 on llvmpipe (LLVM 3.4, 256 bits) _< info: GL version: 1.4 (2.1 Mesa 10.1.3)

_< info: GL hw accelerated: no

> info: GLX server: NVIDIA Corporation > info: GLX client: primus > info: GL vendor: NVIDIA Corporation > info: GL renderer: GeForce 940M/PCIe/SSE2 _> info: GL version: 4.5.0 NVIDIA 352.79

amonakov commented 8 years ago

On your system Mesa is using software llvmpipe driver for the integrated card instead of the proper i965 DRI driver. You can run LIBGL_DEBUG=verbose glxgears (or any other OpenGL test like glsanity-glx) to find out why the i965 driver is not used.

cnlohr commented 8 years ago

You are correct about my system not using the intel card drivers... libGL: screen 0 does not appear to be DRI3 capable libGL error: pci id for fd 4: 8086:191b, driver (null) libGL: OpenDriver: trying /usr/lib/x86_64-linux-gnu/dri/tls/i965_dri.so libGL: OpenDriver: trying /usr/lib/x86_64-linux-gnu/dri/i965_dri.so i965_dri.so does not support the 0x191b PCI ID. libGL error: failed to create dri screen libGL error: failed to load driver: i965 libGL: OpenDriver: trying /usr/lib/x86_64-linux-gnu/dri/tls/swrast_dri.so libGL: OpenDriver: trying /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so libGL: driver does not expose __driDriverGetExtensions_swrast(): /usr/lib/x86_64

Apparently my GPU is unspported till a much later version. When I do upgrade my intel card drivers to support my GPU, which does work it breaks primus, etc... this is all I can get out of optimus/primus/bumblebee.

[ 187.869605] [ERROR]Cannot access secondary GPU - error: XORG intel(0): [drm] failed to set drm interface version: Permission denied [13]. ... Bumblebee's log shows: rmmod: ERROR: Module nvidia_uvm is not currently loaded modprobe: FATAL: Error running remove command for nvidia

Seems that the new libdrm-nouveau.so.2 (Which is required for the new intel video drivers - why they did this awful things is well beyond me, but they definitely link to nouveau_drm_new) breaks a fair bit of the functionality in bumblebee/primus/optimus. To add more frustration, the packages seem to be even more of a rats nest now than they used to be, so trying different versions of things is harder than it used to be.

All of this aside, why would you not allow support in primus for older GPU APIs? Or at least detect when a 'null' is returned there. Perhaps by looking for the failure condition, it could fall back to getting just a basic window context?

cnlohr commented 8 years ago

Errr... okay... I got it working again by adding the following to /etc/bumblebee/xorg.conf.nvidia

Section "Screen" Identifier "Default Screen" Device "DiscreteNvidia" EndSection

Optimus works with glxgears. But... primus is now super stuttery. Though it claims 60 FPS even, only about 4FPS makes it to the display. :-/ I don't even know how to begin debugging this, now.

amonakov commented 8 years ago

Hi, sorry for being away,

But... primus is now super stuttery. Though it claims 60 FPS even, only about 4FPS makes it to the display. :-/ I don't even know how to begin debugging this, now.

Have you been able to do any analysis on your end? This seems quite unusual. Does normal glxgears look ok? I'd try prepending PRIMUS_VERBOSE=2 to the command line for some profiling info. Perhaps also with LIBGL_DRI3_DISABLE=1.

cnlohr commented 8 years ago

I did give this a shot. It is a pretty big hastle to switch back and forth between video drivers. Though my current combination results in animated gifs and videos not working in Chrome. I don't know if it's worth getting back around to this. If anyone else runs into this bug, they should probably re-open the task, otherwise I guess we can call it close, since I may be the only person in the world who's got this bizarre bug.