Page 1 of 1

Optimus laptop configuration

Posted: Wed Sep 18, 2019 21:46
by msdobrescu
Hello, I have a laptop with Optimus.
It always used the Intel card and there is no way to disable it.
Lately, KDE started to look strange, like it wouldn't work in full colors, transparency went noisy and ugly.
How could I make it start on nVidia?
I've tried a lot of articles, from Gentoo and Arch and Ubuntu too.
But, despite adding xrandr tcommands to SDDM scripts, I had no luck, and the scripts added in xorg.conf.d seem to break the setup and SDDM doesn't start after adding the xord.config file.
What could I do?

Re: Optimus laptop configuration

Posted: Sat Sep 21, 2019 17:01
by msdobrescu
Hi, nobody has such setup?
Is there a way to skip/stop the Intel card?
Does the modesetting work?

Re: Optimus laptop configuration

Posted: Sat Sep 21, 2019 21:54
by msdobrescu
What I have learned today: my laptop is of MUXless kind, meaning it is not possible to disable the Intel card in BIOS.

After reading and reading and reading again and after some more reading, after trying again and again, setting and trying, I've partially made it run.
By comparison to the proposed setups, seems that my system needs to declare/define both cards and to specify which one to work with my built-in display. In the articles read, it was present only one screen, 0 in some, 1 in others. In this case, seems to require to have both.

So, I have added the following in the newly created file on /etc/X11/xorg.conf.d/10-nvidia.conf:

Code: Select all

Section "ServerLayout"
  Identifier "layout"
  Screen 1 "nvidia"
  Screen 0 "intel"
  Inactive "intel"
EndSection

Section "Device"
  Identifier "nvidia"
  Driver "nvidia"
  BusID "PCI:1:0:0"
EndSection

Section "Screen"
  Identifier "nvidia"
  Device "nvidia"
  Option "AllowEmptyInitialConfiguration"
  Option "UseDisplayDevice" "none"
EndSection

Section "Device"
  Identifier "intel"
  Driver "modesetting"
  Option "AccelMethod" "none"
  BusID "PCI:0:2:0"
EndSection

Section "Screen"
  Identifier "intel"
  Device "intel"
EndSection
This being said, the noisy translucency of Breeze KDE theme is gone. Now looks smooth.
By comparison to the previous setup, which used the Intel card, I've lost windows Windows effects, like Wobbly and Magic Lamp, and probably more.
This would be explained by the fact that opengl is still xorg. Although nvidia opengl can be set with eselect, looks to break immediately some KDE Plasma apps, like the shutdown or logout application that simply can't run, but this happens to behave the same after some KDE updates or kernel upgrade. Also KDE System Settings crashes in some points. The most annoying thing is that I can't check the stability of the system after a restart because it is not possible to get SDDM work after selecting nvidia opengl. A black screen with a mouse pointer is displayed, but the logon screen never occurs. What starts after switching to nvidia is nvidia-settings application, that is able to start now (won't start under Intel) and it closes without a message in one point, when the info panel is chosen.

I've added the following in ~/.xinitrc:

Code: Select all

xrandr --setprovideroutputsource modesetting NVIDIA-0
xrandr --auto
and/or in /usr/share/sddm/scripts/Xsetup, but doesn't seem to work for some reason I can't find.

Any ideas?

Re: Optimus laptop configuration

Posted: Sun Sep 22, 2019 7:18
by msdobrescu
Today I have noticed there is a module setting config for nvidia in the 20opengl.conf. I have moved the xorg config after.
There is no difference.
Beside that, I've forgot to mention that after login I see TWO KDE splashes, one small, in the top left corner of the screen, above the expected one (which takes all the screen). I have no clue what it is.

Another issue found:

Code: Select all

glxinfo | grep OpenGL
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
OpenGL vendor string: VMware, Inc.
OpenGL renderer string: llvmpipe (LLVM 8.0, 256 bits)
OpenGL core profile version string: 3.3 (Core Profile) Mesa 19.1.6
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.1 Mesa 19.1.6
OpenGL shading language version string: 1.40
OpenGL context flags: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.0 Mesa 19.1.6
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00
OpenGL ES profile extensions:
X Error of failed request:  GLXBadContext
  Major opcode of failed request:  149 (GLX)
  Minor opcode of failed request:  6 (X_GLXIsDirect)
  Serial number of failed request:  114
  Current serial number in output stream:  113
Could anybody clarify this?

Re: Optimus laptop configuration

Posted: Sun Sep 22, 2019 15:37
by msdobrescu
I've made it! Although I don't get it... It was kind of hit him when he's down solution...
Please, devs of Sabayon, clarify this for me! Let me explain, first.

The actual setup is like this:

1. /etc/X11/xorg.conf.d/10-nvidia.conf:

Code: Select all

Section "ServerLayout"
  Identifier "layout"
# the index of the nvidia video card is 1 in my case, and so the screen
  Screen 1 "nvidia"
#  Screen 0 "intel" <---don't add it here
  Inactive "intel"
EndSection

Section "Device"
  Identifier "nvidia"
  Driver "nvidia"
  BusID "PCI:1:0:0"
EndSection

Section "Screen"
  Identifier "nvidia"
  Device "nvidia"
  Option "AllowEmptyInitialConfiguration"
#  Option "UseDisplayDevice" "none"
EndSection

Section "Device"
  Identifier "intel"
  Driver "modesetting"
#  Option "AccelMethod" "none"
  BusID "PCI:0:2:0"
EndSection

Section "Screen"
  Identifier "intel"
  Device "intel"
EndSection
2. /etc/modprobe.d/nvidia.conf untouched, as it is configured by Sabayon

3. /etc/modprobe.d/nvidia-rmmod.conf, as it is configured by Sabayon

4. /etc/modprobe.d/nvidia-drm.conf, added by me, not sure if necessary:

Code: Select all

options nvidia_drm modeset=1
5. /usr/share/sddm/scripts/Xsetup

Code: Select all

#!/bin/sh
# Xsetup - run as root before the login dialog appears
xrandr --setprovideroutputsource modesetting NVIDIA-0
xrandr --auto
xrandr --dpi 96
My dpi of choice, otherwise might be too high.

6. it seems ~/.xinitrc, usually having the same content as /usr/share/sddm/scripts/Xsetup above, it's not necessary. I don't have it at all.

7. Run this and restart:

Code: Select all

 # eselect opengl set nvidia
Some helpful commands:

1. During the setup... as root/su/sudo:

Code: Select all

lspci | grep -E "VGA|3D"
00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09)
01:00.0 VGA compatible controller: NVIDIA Corporation GK107M [GeForce GT 650M] (rev a1)
2. After the setup, to check if nvidia is actually working...
... as root:

Code: Select all

 # xrandr --listproviders
Providers: number : 2
Provider 0: id: 0x2f0 cap: 0x1, Source Output crtcs: 4 outputs: 1 associated providers: 1 name:NVIDIA-0
Provider 1: id: 0x44 cap: 0x2, Sink Output crtcs: 3 outputs: 2 associated providers: 1 name:modesetting

Code: Select all

 # glxinfo | grep -i "direct rendering"
direct rendering: Yes

Code: Select all

 # xrandr --verbose|grep PRIME
        PRIME Synchronization: 1 
        PRIME Synchronization: 1

Code: Select all

 # glxinfo | grep OpenGL
OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: GeForce GT 650M/PCIe/SSE2
OpenGL core profile version string: 4.6.0 NVIDIA 430.26
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 430.26
OpenGL shading language version string: 4.60 NVIDIA
OpenGL context flags: (none)
OpenGL profile mask: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.2 NVIDIA 430.26
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
OpenGL ES profile extensions:

Code: Select all

 # ldconfig -p | grep -i gl.so
        libwayland-egl.so.1 (libc6,x86-64) => /usr/lib64/libwayland-egl.so.1
        libwayland-egl.so.1 (libc6) => /usr/lib32/libwayland-egl.so.1
        libwayland-egl.so (libc6,x86-64) => /usr/lib64/libwayland-egl.so
        libwayland-egl.so (libc6) => /usr/lib32/libwayland-egl.so
        libmypaint-gegl.so.0 (libc6,x86-64) => /usr/lib64/libmypaint-gegl.so.0
        libmypaint-gegl.so (libc6,x86-64) => /usr/lib64/libmypaint-gegl.so
        libftgl.so.2 (libc6,x86-64) => /usr/lib64/libftgl.so.2
        libftgl.so (libc6,x86-64) => /usr/lib64/libftgl.so
        libfltk_gl.so.1.3 (libc6,x86-64) => /usr/lib64/fltk/libfltk_gl.so.1.3
        libfltk_gl.so (libc6,x86-64) => /usr/lib64/fltk/libfltk_gl.so
        libcogl.so.20 (libc6,x86-64) => /usr/lib64/libcogl.so.20
        libcogl.so (libc6,x86-64) => /usr/lib64/libcogl.so
        libQt5OpenGL.so.5 (libc6,x86-64) => /usr/lib64/libQt5OpenGL.so.5
        libQt5OpenGL.so (libc6,x86-64) => /usr/lib64/libQt5OpenGL.so
        libQtOpenGL.so.4 (libc6,x86-64) => /usr/lib64/qt4/libQtOpenGL.so.4
        libOpenGL.so.0 (libc6,x86-64) => /usr/lib64/opengl/nvidia/lib/libOpenGL.so.0
        libOpenGL.so.0 (libc6) => /usr/lib32/opengl/nvidia/lib/libOpenGL.so.0
        libOpenGL.so (libc6,x86-64) => /usr/lib64/opengl/nvidia/lib/libOpenGL.so
        libOpenGL.so (libc6) => /usr/lib32/opengl/nvidia/lib/libOpenGL.so
        libGL.so.1 (libc6,x86-64) => /usr/lib64/opengl/nvidia/lib/libGL.so.1
        libGL.so.1 (libc6,x86-64) => /usr/lib64/libGL.so.1
        libGL.so.1 (libc6) => /usr/lib32/opengl/nvidia/lib/libGL.so.1
        libGL.so.1 (libc6) => /usr/lib32/libGL.so.1
        libGL.so (libc6,x86-64) => /usr/lib64/opengl/nvidia/lib/libGL.so
        libGL.so (libc6,x86-64) => /usr/lib64/libGL.so
        libGL.so (libc6) => /usr/lib32/opengl/nvidia/lib/libGL.so
        libGL.so (libc6) => /usr/lib32/libGL.so
        libEGL.so.1 (libc6,x86-64) => /usr/lib64/opengl/nvidia/lib/libEGL.so.1
        libEGL.so.1 (libc6,x86-64) => /usr/lib64/libEGL.so.1
        libEGL.so.1 (libc6) => /usr/lib32/opengl/nvidia/lib/libEGL.so.1
        libEGL.so.1 (libc6) => /usr/lib32/libEGL.so.1
        libEGL.so (libc6,x86-64) => /usr/lib64/opengl/nvidia/lib/libEGL.so
        libEGL.so (libc6,x86-64) => /usr/lib64/libEGL.so
        libEGL.so (libc6) => /usr/lib32/opengl/nvidia/lib/libEGL.so
        libEGL.so (libc6) => /usr/lib32/libEGL.so
... as regular user:

Code: Select all

 # nvidia-xconfig --query-gpu-info | grep 'BusID : ' | cut -d ' ' -f6
PCI:1:0:0

Code: Select all

 # nvidia-xconfig --query-gpu-info
Number of GPUs: 1

GPU #0:
  Name      : GeForce GT 650M
  UUID      : GPU-d56e38b9-ef11-0ef1-f936-6cb707b47df8
  PCI BusID : PCI:1:0:0

  Number of Display Devices: 0
Now, here is the strange thing... to me, at least.
I've operated under KDE, usually, under Krusader or console, mainly, as root.
Even the eselect switch to nvidia opengl was done in command line under KDE.
After restart, usually, a black screen with a mouse cursor remained displayed before the SDDM login.
I've switcvhed back to xorg-x11 opengl in command line in order to get KDE back.
And I've tried several things, unsuccessfully, basically going KDE-console-KDE-console...

At some point, I've issued a switch command to nvidia opengl under console, when the black screen appeared and stayed in error...
Was some mistake, but I was tired and issued a restart immediately after and ... SURPRISE! Worked!
What is the difference in doing that under KDE console vs console in error? I have no clue! But worked.

Now, please, please, please, somebody, think about it! And provide an explanation, if possible.
Some eselect module should have been provided for this kind of operation... It's not so exotic, I guess. I see so many people failing on this over the Internet!

One thing remained, at login screen and immediately after the login, in KDE, the mouse pointer is not centred, it's somewhere to the top-left to the centre of the screen, like there remained that second little screen. It's probably related to the initial resolution of the screen...