# Optimus : eselect-opengl et USE libglvnd (X_GLXSwapBuffers)

## pti-rem

Bonjour,

Il y a du nouveau pour moi en ~amd64 maintenant ; pour Optimus et avec le drapeau libglvnd que je ne connais pas.

Je ne comprends pas bien quoi faire ni quel tuto suivre aujourd'hui pour faire fonctionner primusrun - qui est censé donner les meilleurs résultats.

Ma puce nvidia GF108M [GeForce GT 620M/630M/635M/640M LE] [10de:0de9] me donne à masquer les pilotes >=x11-drivers/nvidia-drivers-391.0.0

Ma puce Intel est une [8086:0116]

J'essaie avec https://wiki.gentoo.org/wiki/NVIDIA/Bumblebee et j'ai lu un peu de certains bugs à propos libglvnd mais c'est difficile de s'y retrouver et au final, je n'y arrive pas.

J'ai lu aussi que eselect-opengl n'était plus nécessaire ?

Merci de bien vouloir m'aider pour la méthode à appliquer.

Ou aussi pour m'éclaircir les idées...

```
rem@n73sm ~ $ grep VIDEO_CARDS /etc/portage/make.conf

VIDEO_CARDS="i965 i915 intel nvidia"

rem@n73sm ~ $
```

primusrun glxgears ou primusrun glxspheres64 me donne une fenêtre toute noire et un Mpixels/sec très bas.

```
rem@n73sm ~ $ primusrun glxspheres64 # fenêtre toute noire

Polygons in scene: 62464 (61 spheres * 1024 polys/spheres)

Visual ID of window: 0xcc

Context is Direct

OpenGL Renderer: llvmpipe (LLVM 9.0.1, 256 bits)

16.907070 frames/sec - 18.868290 Mpixels/sec

16.943435 frames/sec - 18.908874 Mpixels/sec

16.895330 frames/sec - 18.855189 Mpixels/sec

17.068582 frames/sec - 19.048537 Mpixels/sec

16.604216 frames/sec - 18.530305 Mpixels/sec

rem@n73sm ~ $
```

```
rem@n73sm ~ $ emerge -pv eselect-opengl

These are the packages that would be merged, in order:

Calculating dependencies... done!

[ebuild  N     ] app-eselect/eselect-opengl-1.3.1-r4::gentoo  0 KiB

[blocks B      ] app-eselect/eselect-opengl ("app-eselect/eselect-opengl" is blocking x11-base/xorg-server-1.20.7, x11-drivers/nvidia-drivers-390.132-r2, media-libs/mesa-20.0.2)

Total: 1 package (1 new), Size of downloads: 0 KiB

Conflict: 1 block (1 unsatisfied)

 * Error: The above package list contains packages which cannot be

 * installed at the same time on the same system.

  (app-eselect/eselect-opengl-1.3.1-r4:0/0::gentoo, ebuild scheduled for merge) pulled in by

    eselect-opengl

  (media-libs/mesa-20.0.2:0/0::gentoo, installed) pulled in by

    media-libs/mesa required by @selected 

  (x11-drivers/nvidia-drivers-390.132-r2:0/390::gentoo, installed) pulled in by

    x11-drivers/nvidia-drivers required by @selected 

For more information about Blocked Packages, please refer to the following

section of the Gentoo Linux x86 Handbook (architecture is irrelevant):

https://wiki.gentoo.org/wiki/Handbook:X86/Working/Portage#Blocked_packages

rem@n73sm ~ $
```

```
rem@n73sm ~ $ emerge -pv sys-power/bbswitch x11-misc/bumblebee x11-misc/primus nvidia-drivers xf86-video-intel mesa xorg-server

These are the packages that would be merged, in order:

Calculating dependencies... done!

[ebuild   R    ] media-libs/mesa-20.0.2::gentoo  USE="X classic dri3 egl gallium gbm gles2 libglvnd llvm zstd -d3d9 -debug -gles1 -lm-sensors -opencl -osmesa (-selinux) -test -unwind -vaapi -valgrind -vdpau -vulkan -vulkan-overlay -wayland -xa -xvmc" ABI_X86="32 (64) (-x32)" VIDEO_CARDS="i915 i965 intel (-freedreno) -iris (-lima) -nouveau (-panfrost) -r100 -r200 -r300 -r600 -radeon -radeonsi (-vc4) -virgl (-vivante) -vmware" 0 KiB

[ebuild   R    ] sys-power/bbswitch-0.8-r2::gentoo  0 KiB

[ebuild   R    ] x11-base/xorg-server-1.20.7:0/1.20.7::gentoo  USE="elogind ipv6 libglvnd suid udev xorg -debug -dmx -doc -kdrive -libressl -minimal (-selinux) -static-libs -systemd -unwind -wayland -xcsecurity -xephyr -xnest -xvfb" 0 KiB

[ebuild   R    ] x11-drivers/nvidia-drivers-390.132-r2:0/390::gentoo  USE="X acpi compat driver gtk3 libglvnd multilib static-libs tools -kms -uvm -wayland" ABI_X86="32 (64) (-x32)" 0 KiB

[ebuild   R    ] x11-drivers/xf86-video-intel-2.99.917_p20191209::gentoo  USE="dri sna udev xvmc -debug -tools -uxa" 0 KiB

[ebuild   R    ] x11-misc/bumblebee-3.2.1_p20170130::gentoo  USE="bbswitch" VIDEO_CARDS="nvidia -nouveau" 0 KiB

[ebuild   R    ] x11-misc/primus-0.2::gentoo  ABI_X86="(64) -32 (-x32)" 0 KiB

Total: 7 packages (7 reinstalls), Size of downloads: 0 KiB

rem@n73sm ~ $
```

Last edited by pti-rem on Thu Mar 26, 2020 1:29 pm; edited 2 times in total

----------

## pti-rem

J'ai avancé un peu :

```
rem@n73sm ~ $ grep "(EE)" /var/log/Xorg.8.log

   (WW) warning, (EE) error, (NI) not implemented, (??) unknown.

[   150.996] (EE) /dev/dri/card0: failed to set DRM interface version 1.4: Permission denied

[   151.442] (EE) NVIDIA(0): Failed to initialize the GLX module; please check in your X

[   151.442] (EE) NVIDIA(0):     log file that the GLX module has been loaded in your X

[   151.442] (EE) NVIDIA(0):     server, and that the module is the NVIDIA GLX module.  If

[   151.442] (EE) NVIDIA(0):     you continue to encounter problems, Please try

[   151.442] (EE) NVIDIA(0):     reinstalling the NVIDIA driver.

[   151.948] (EE) kbd: <default keyboard>: failed to set us as foreground pgrp (Inappropriate ioctl for device)

[   151.956] (EE) /dev/dri/card0: failed to set DRM interface version 1.4: Permission denied

rem@n73sm ~ $
```

```
rem@n73sm ~ $ grep -i GLX /var/log/Xorg.0.log

[    55.150] (II) LoadModule: "glx"

[    55.161] (II) Loading /usr/lib64/xorg/modules/extensions/libglx.so

[    55.171] (II) Module glx: vendor="X.Org Foundation"

[    55.217] (II) Initializing extension GLX

[    55.262] (II) AIGLX: Loaded and initialized i965

[    55.262] (II) GLX: Initialized DRI2 GL provider for screen 0

rem@n73sm ~ $
```

Le module GLX chargé n'est pas le NVIDIA GLX module.

----------

## pti-rem

J'ai cherché libglx.so :

```
n73sm ~ # locate libglx.so

/usr/lib64/extensions/nvidia/libglx.so

/usr/lib64/extensions/nvidia/libglx.so.390.132

/usr/lib64/xorg/modules/extensions/libglx.so

n73sm ~ #
```

J'ai modifié /etc/X11/xorg.conf.d/20opengl.conf :

```
n73sm ~ # cat /etc/X11/xorg.conf.d/20opengl.conf

Section "Files"

   ModulePath "/usr/lib64/extensions/nvidia" # ajout

   ModulePath "/usr/lib/xorg/modules"

   ModulePath "/usr/lib64/xorg/modules"

EndSection

n73sm ~ #
```

 /var/log/Xorg.0.log prend en compte la modification :

```
[   544.402] (II) LoadModule: "glx"

[   544.402] (II) Loading /usr/lib64/extensions/nvidia/libglx.so

[   544.410] (II) Module glx: vendor="NVIDIA Corporation"

[   544.410]    compiled for 4.0.2, module version = 1.0.0

[   544.410]    Module class: X.Org Server Extension

[   544.410] (II) NVIDIA GLX Module  390.132  Fri Nov  1 04:00:46 PDT 2019

```

Mais primusrun ne fonctionne toujours pas.

J'essaie alors avec le pilote nouveau... qui lui ne fonctionne pas du tout j'ai l'impression.

Installer nouveau puis revenir pour nvidia m'a permis de replacer des fichiers de configuration originaux ;

Il me manquait « Driver=nvidia » sous [bumblebeed] du /etc/bumblebee/bumblebee.conf !Last edited by pti-rem on Wed Mar 25, 2020 9:54 pm; edited 3 times in total

----------

## pti-rem

J'ai un progrès mais la fenêtre de glxspheres64 se ferme aussitôt lancée:

```
rem@n73sm ~ $ optirun -vv glxspheres64 

[ 4414.681599] [DEBUG]Reading file: /etc/bumblebee/bumblebee.conf

[ 4414.682034] [INFO]Configured driver: nvidia

[ 4414.682311] [DEBUG]optirun version 3.2.1-2017-01-30-Format:%h$ starting...

[ 4414.682338] [DEBUG]Active configuration:

[ 4414.682348] [DEBUG] bumblebeed config file: /etc/bumblebee/bumblebee.conf

[ 4414.682358] [DEBUG] X display: :8

[ 4414.682367] [DEBUG] LD_LIBRARY_PATH: /usr/lib64:/usr/lib:/usr/lib64/primus

[ 4414.682376] [DEBUG] Socket path: /var/run/bumblebee.socket

[ 4414.682398] [DEBUG] Accel/display bridge: primus

[ 4414.682411] [DEBUG] VGL Compression: rgb

[ 4414.682425] [DEBUG] VGLrun extra options: 

[ 4414.682440] [DEBUG] Primus LD Path: /usr/lib64/primus

[ 4416.135390] [INFO]Response: Yes. X is active.

[ 4416.135432] [INFO]Running application using primus.

[ 4416.135693] [DEBUG]Process glxspheres64 started, PID 9732.

Polygons in scene: 62464 (61 spheres * 1024 polys/spheres)

Visual ID of window: 0xce

Context is Direct

OpenGL Renderer: GeForce GT 630M/PCIe/SSE2

X Error of failed request:  BadMatch (invalid parameter attributes)

  Major opcode of failed request:  151 (GLX)

  Minor opcode of failed request:  11 (X_GLXSwapBuffers)

  Serial number of failed request:  40

  Current serial number in output stream:  41

primus: warning: timeout waiting for display worker

terminate called without an active exception

[ 4417.554423] [DEBUG]SIGCHILD received, but wait failed with No child processes

[ 4417.554498] [DEBUG]Socket closed.

[ 4417.554583] [DEBUG]Killing all remaining processes.

rem@n73sm ~ $
```

Je trouve ces messages lors de la tentative :

```
Mar 25 20:43:05 n73sm bumblebeed[9653]: [XORG] (WW) NVIDIA(0): Unable to get display device for DPI computation.

Mar 25 20:43:05 n73sm bumblebeed[9653]: [XORG] (WW) NVIDIA(0): Option "NoLogo" is not used

Mar 25 20:43:05 n73sm bumblebeed[9653]: [XORG] (EE) kbd: <default keyboard>: failed to set us as foreground pgrp (Inappropriate ioctl for device)

Mar 25 20:43:07 n73sm kernel: nvidia-nvlink: Unregistered the Nvlink Core, major device number 246

Mar 25 20:43:07 n73sm kernel: bbswitch: disabling discrete graphics

Mar 25 20:43:07 n73sm kernel: pci 0000:01:00.0: Refused to change power state, currently in D0
```

En cherchant X_GLXSwapBuffers, je trouve une parade : export __GLVND_DISALLOW_PATCHING=1

Les trois mesures en Mpixels/sec avec glxspheres64 (seul, avec optirun et puis primusrun) sont équivalentes à 67 environ. C'est à n'y rien comprendre !

Autrement :

```
rem@n73sm ~ $ glxinfo | grep OpenGL

OpenGL vendor string: Intel Open Source Technology Center

OpenGL renderer string: Mesa DRI Intel(R) HD Graphics 3000 (SNB GT2)

OpenGL core profile version string: 3.3 (Core Profile) Mesa 20.0.2

OpenGL core profile shading language version string: 3.30

OpenGL core profile context flags: (none)

OpenGL core profile profile mask: core profile

OpenGL core profile extensions:

OpenGL version string: 3.0 Mesa 20.0.2

OpenGL shading language version string: 1.30

OpenGL context flags: (none)

OpenGL extensions:

OpenGL ES profile version string: OpenGL ES 3.0 Mesa 20.0.2

OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00

OpenGL ES profile extensions:
```

```
rem@n73sm ~ $ primusrun glxinfo | grep OpenGL

OpenGL vendor string: NVIDIA Corporation

OpenGL renderer string: GeForce GT 630M/PCIe/SSE2

OpenGL core profile version string: 4.6.0 NVIDIA 390.132

OpenGL core profile shading language version string: 4.60 NVIDIA

OpenGL core profile context flags: (none)

OpenGL core profile profile mask: core profile

OpenGL core profile extensions:

OpenGL version string: 4.6.0 NVIDIA 390.132

OpenGL shading language version string: 4.60 NVIDIA

OpenGL context flags: (none)

OpenGL profile mask: (none)

OpenGL extensions:

rem@n73sm ~ $
```

----------

## pti-rem

 *Quote:*   

> Les trois mesures en Mpixels/sec avec glxspheres64 (seul, avec optirun et puis primusrun) sont équivalentes à 67 environ. C'est à n'y rien comprendre !

 

J'ai de meilleurs résultats avec optirun en changeant deux paramètres dans /etc/bumblebee/bumblebee.conf ; sous [optirun] :

1) Bridge=virtualgl (au lieu de primus)

2) VGLTransport=proxy (au lieu de rgb)

```
rem@n73sm ~ $ primusrun glxspheres64

Polygons in scene: 62464 (61 spheres * 1024 polys/spheres)

Visual ID of window: 0xce

Context is Direct

OpenGL Renderer: GeForce GT 630M/PCIe/SSE2

61.933317 frames/sec - 69.117581 Mpixels/sec

60.042904 frames/sec - 67.007881 Mpixels/sec

60.132301 frames/sec - 67.107647 Mpixels/sec

60.138186 frames/sec - 67.114216 Mpixels/sec

60.122719 frames/sec - 67.096955 Mpixels/sec

rem@n73sm ~ $ optirun glxspheres64

Polygons in scene: 62464 (61 spheres * 1024 polys/spheres)

Visual ID of window: 0x20

Context is Direct

OpenGL Renderer: GeForce GT 630M/PCIe/SSE2

98.667052 frames/sec - 110.112430 Mpixels/sec

101.890222 frames/sec - 113.709488 Mpixels/sec

101.189265 frames/sec - 112.927220 Mpixels/sec

101.543137 frames/sec - 113.322141 Mpixels/sec

100.940412 frames/sec - 112.649500 Mpixels/sec

103.344858 frames/sec - 115.332862 Mpixels/sec

rem@n73sm ~ $ glxspheres64

Polygons in scene: 62464 (61 spheres * 1024 polys/spheres)

Visual ID of window: 0xce

Context is Direct

OpenGL Renderer: Mesa DRI Intel(R) HD Graphics 3000 (SNB GT2)

60.981114 frames/sec - 68.054923 Mpixels/sec

60.109638 frames/sec - 67.082356 Mpixels/sec

60.139925 frames/sec - 67.116156 Mpixels/sec

60.097374 frames/sec - 67.068669 Mpixels/sec

rem@n73sm ~ $
```

Bon, je suis satisfait : c'est un cadeau pour les 8 ans du portable.

----------

