Gotta Love Optimus

So just checking a few things regarding ClearLinux and my main laptop with is a shiny new Asus Q53F with the dreaded Optimus Nvidia as the discrete processor and an Intel as the main graphics device. I thought I’d see how Clear handled this.

My distro of choice is the distro that can make all other distros, Gentoo. Since Gentoo has not yet adopted Xorg 1.20 and it’s use of the GL vendor library changes in Mesa (libglvnd) to automatically offload to the more powerful Nvidia GPU I’ve had to do a lot of patching and custom ebuilds to get everything going (you can find this work now in the bobwya overlay). What a pain! How does ClearLinux do?

First, I don’t see libglvnd anywhere on the system or the manifests so I think I’m stuck with PRIME offloading for now.

First of all, I have NOT installed ClearLinux to the ASUS because I don’t want it to wipe out my bootloader and I’m just a bit touchy about that. So this is using the Liveboot only (build 29590).

So here goes:

  1. Which cards does X see?
    root@clr-live ~ # xrandr --listproviders
    Providers: number : 2
    Provider 0: id: 0x64 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 3 outputs: 2 associated providers: 0 name:modesetting
    Provider 1: id: 0x3f cap: 0x5, Source Output, Source Offload crtcs: 0 outputs: 0 associated providers: 0 name:nouveau

We have the intel in modesetting mode (good) and nouveau (hate that spelling) for the Nvidia. Looks like DRI3 is a go.

  1. root@clr-live ~ # glxinfo|grep vendor
    glxinfo: command not found
    To install glxinfo use: swupd bundle-add os-testsuite-phoronix-desktop

What? Seriously I have to install the WHOLE Phoronix test suite just to get the GL tools? How in the world do you test anything about GL without glxinfo and glxgears?

  1. I guess we’ll use glmark2.
    swupd bundle-add glmark2
    Good news, we have it.
    $ glmark2
    =======================================================
    glmark2 2017.07
    =======================================================
    OpenGL Information
    GL_VENDOR: Intel Open Source Technology Center
    GL_RENDERER: Mesa DRI Intel® HD Graphics (Whiskey Lake 3x8 GT2)
    GL_VERSION: 3.0 Mesa 19.2.0-devel
    =======================================================
    [build] use-vbo=false: FPS: 3518 FrameTime: 0.284 ms
    =======================================================
    glmark2 Score: 3518
    =======================================================
    As expected the Intel is driving the display.

  2. Verify it at PRIME 0
    clrlinux@clr-live ~ $ DRI_PRIME=0 glmark2
    =======================================================
    glmark2 2017.07
    =======================================================
    OpenGL Information
    GL_VENDOR: Intel Open Source Technology Center
    GL_RENDERER: Mesa DRI Intel® HD Graphics (Whiskey Lake 3x8 GT2)
    GL_VERSION: 3.0 Mesa 19.2.0-devel
    =======================================================
    [build] use-vbo=false: FPS: 3463 FrameTime: 0.289 ms
    =======================================================
    glmark2 Score: 3463
    =======================================================

  3. Check in the nvidia at PRIME 1
    clrlinux@clr-live ~ $ DRI_PRIME=1 glmark2
    nvc0_screen_create:1092 - Error allocating PGRAPH context for M2MF: -16
    libGL error: failed to create dri screen
    libGL error: failed to load driver: nouveau
    =======================================================
    glmark2 2017.07
    =======================================================
    OpenGL Information
    GL_VENDOR: Intel Open Source Technology Center
    GL_RENDERER: Mesa DRI Intel® HD Graphics (Whiskey Lake 3x8 GT2)
    GL_VERSION: 3.0 Mesa 19.2.0-devel
    =======================================================

No go. The nVidia can’t open a DRI display. No good for DRI3.

  1. Sometimes though the mapping can be force. We’ll try that.
    $ xrandr --setprovideroffloadsink 1 0
    DRI_PRIME=1 glmark2
    nvc0_screen_create:1092 - Error allocating PGRAPH context for M2MF: -16
    libGL error: failed to create dri screen
    libGL error: failed to load driver: nouveau
    =======================================================
    glmark2 2017.07
    =======================================================
    OpenGL Information
    GL_VENDOR: Intel Open Source Technology Center
    GL_RENDERER: Mesa DRI Intel® HD Graphics (Whiskey Lake 3x8 GT2)
    GL_VERSION: 3.0 Mesa 19.2.0-devel
    =======================================================
    Same thing.

  2. One last shot. Let’s disable DRI3 and try DRI3. This forces use to do the mapping, which we have already done. So we’ll just disable DRI3.
    $ LIBGL_DRI3_DISABLE=1 DRI_PRIME=1 glmark2
    =======================================================
    glmark2 2017.07
    =======================================================
    OpenGL Information
    GL_VENDOR: Intel Open Source Technology Center
    GL_RENDERER: Mesa DRI Intel® HD Graphics (Whiskey Lake 3x8 GT2)
    GL_VERSION: 3.0 Mesa 19.2.0-devel
    =======================================================

It went right to the Intel. DRI2 seems a bust unless … we need to reverse map it.

  1. Since this might cause a black screen that won’t let me work any more and in LiveBoot I’ll lose EVERYTHING, I’ll post and then edit.

$ xrandr --setprovideroutputsource 0 1
X Error of failed request: BadValue (integer parameter out of range for operation)
Major opcode of failed request: 139 (RANDR)
Minor opcode of failed request: 35 (RRSetProviderOutputSource)
Value in failed request: 0x3f
Serial number of failed request: 16
Current serial number in output stream: 17

No taco on taco night. It seems at least with the LiveBoot ClearLinux Optimus is a dead animal. I would think though the GL vendor mapping would be the answer since ClearLinux has all the right gear (Xorg 1.20.4 and Mesa 1.8) Any I think Mesa 1.8. I don’t see a good way to verify that using swupd though libGL is marked 1.2.0. Edit: AH I see glmark2 gives us ehte Mesa version which is 19 and capable of doing the GLVND mappings. Hopefully in the future ClearLinux will fully support Mesa 19 and GLVND so we can use the nVidia GPU for real work.

It might be possible to use DRI2 and bbswitch (Bumblebee) with a proprietary driver. This just seems a hard test in the limit disk space of the LiveBoot. Perhaps in the future.

Optimus anyone?

Interesting! Thanks for sharing your experience. I can’t say I have had the pleasure of using NVIDIA Optimus on Linux :slight_smile:. As you pointed out and based on the light reading I did, it looks like like a complicated process regardless of distro and the proprietary driver would be the best shot.

P.S. The forums accept markdown style formatting so you can format a text block from the console by putting a line with 3 backticks (```) before and after, which will make those sections easier to read.

1 Like

Thanks for the formatting tip.

Yes Optimus is a major problem because there is no hardware standard on how to hook up the outputs (mux or no mux, discrete with connections to video port or not, etc.). But with the libglvnd, Mesa 19 and Xorg 1.20.4 (??) you don’t have to worry about it. But I don’t think the nouveau driver supports libglvnd yet. Hopefully soon.

Anyway, point is out of the box (bundle) ClearLinux could support Optimus using libglvnd and it would be a big win for laptop users. Just a thought.

Optimus is the only thing keeping me from using clearlinux. Aside from this, CL is the most performant distro I have ever used.

1 Like

optimus works with nouveau not able to get it working with nvidia

Can you please share instructions or steps how you got optimus working. Coz the last time I tried it I really had a hard time it.

for nvidia driver optimus doesnt work for me . i have a old geforce 820m with last supported driver being 391.141 .for newer cards i have no idea whether it works or not .for me @specter istructions worked.blacklisting igpu and making some other changes.
with nouveau tho i can run both igpu and nouveau same time