Hybrid Graphics and Fedora Workstation 25

When we started the Fedora Workstation effort one thing we wanted to do was to drain the proverbial swamp of make sure that running Linux on a laptop is a first rate experience. As you see from my last blog entry we have been working on building a team dedicated to that task. There are many facets to this effort, but one that we kept getting asked about was sorting out hybrid graphics. So be aware that some of this has been covered in previous blog entries, but I want to be thorough here. So this blog will cover the big investments of time and effort we are putting into Wayland and X Windows, GNOME Shell and Nouveau (the open source driver for NVidia GPU hardware).

A big part of this story is also that we are trying to make it easier to run the NVidia binary driver on Fedora in general which is actually a fairly large undertaking as there are a lot challenges with trying to do that without requiring any manual configuration from the user and making sure it works fully in the hybrid graphics usecase. This is one of the most requested areas of improvement for Fedora. Many users are trying to run Fedora on their existing laptops or other hardware. Rather than allow this gap to be a reason for people to not run Fedora, we want to provide a better experience. Of course users will have the freedom to make their own choice about installing these drivers, using information provided by Software.

Hybrid graphics is the term used for when you have a laptop with two GPUs, usually one Intel and one NVidia GPU, but there are also some laptops available which comes with Intel/AMD CPU + AMD GPU. The purpose of hybrid graphics is to have your (Intel) Integrated GPU be your ‘day to day GPU’ for running your desktop yet not drawing to much power, but then if you want to for instance play a game on your system you can activate your secondary GPU which got a lot more power, but which also draws more electricity.

What complicated this even more was the fact that most users who wanted to use this setup wanted to use it in combination with the binary NVidia driver, in order to get top performance from their second GPU, which is not surprising since that is the whole point of switching to it. The main challenge with this was that the Mesa and binary NVidia driver both provided an OpenGL implementation that due to the way things works in the X Window System ended up overwriting each other, basically breaking the overwritten driver. The solution for this was a system called Bumblebee which employed some clever hacks to work around this issue, but Bumblebee is a solution to a problem we shouldn’t have to begin with.

Of course dealing with the OpenGL stack wasn’t the only challenge here. For instance different display outputs ended up being connected to different GPUs, with one of the most common setups being that the internal screen is connected to your Intel GPU and your external HDMI and DisplayPort connections are connected to your NVidia or AMD GPU. One some systems there where hardware connectors allowing you to display using either GPU to any screen, but a setup we see becoming more common is that the drivers for both card needs to be initialized in all cases, allowing the display connected GPU to slave itself to the other GPU to allow rendering on one GPU and displaying on the other. Within Mesa this is fairly straightforward to handle, so if both Intel and NVidia as rendering using Mesa things are fairly straightforward. What makes this a lot more challenging here is the NVidia binary driver, so once you install the binary driver we need to find a way to bridge and interoperate between these two stacks.

And of course that is just the highlights, like anything complex like this there are a long laundry list of items from the point where you can checkbox having a feature to it working really well and seamless.

What to expect in Fedora Workstation 25
Lets start with a word of caution here, we are working on a tight deadline here to get all the pieces lined up, so I can not be 100% sure what will make it for the day of release. What we are confident about though is that we will have all the low level plumbing sorted so that we can improve this over the course of the Fedora 25 lifecycle. As always I hope the community will join us in testing and developing this, to ensure we have even the corner cases worked out for Fedora Workstation 26.

The initial step we took and this is quite some time ago was that Dave Airlie worked on making sure we could handle two GPUs within the Mesa stack. As a bit of wordplay on the NVidia solution being called Optimus the open source Mesa solution was named Prime. This work basically allowed you to use Mesa for your Intel card and use Mesa (Nouveau) for your NVidia card and launch applications on the NVidia card while the screen was connected to the Intel card. You can choose which one is used by setting the DRI_PRIME=1 environment variable.

The second step was Adam Jackson collaborating with NVidia on something called libglvnd. Libglvnd stands for GL Vendor Neutral Dispatch and it is basically a dispatch layer that allows your OpenGL calls to be dispatched to more than one OpenGL implementation. Nvidia created this specification and have been steadily working on supporting it in their binary driver, but Adam Jackson stepped up to help review their patches and work on supporting glvnd in the Mesa drivers. This means that for Fedora Workstation 25 you should for the first time ever be able to have both the binary NVidia driver and Mesa installed without any file conflicts. So the X server now has the infrastructure to route your OpenGL call to the correct stack when that DRI_PRIME variable is set. That said there is a major catch here, due to the way things currently work once the NVidia binary driver is installed it expects to be rendering the screen all the time. So we need for the short term to figure out a way to allow it to do that, and in the long run we need to work with NVidia to figure out how the Intel open source driver can collaborate with the Nvidia driver to allow us to only use the Intel driver at times (to save on power for instance). We are still pushing hard on trying to have the short term fix in place, but as I write this we haven’t fully nailed this down yet.

The third step is work that Ben Skeggs has been doing on dealing with the monitor handling here, which includes adding MST support to Nouveau, because a lot of external ports and docking stations have not been working with these hybrid graphics setups due to the external screens all being routed through the NVidia chip. These patches just got accepted upstream and we will be including them in Fedora Workstation 25.

The fourth step has been work that Hans de Goede has been doing around Prime, fixing the modesetting driver and fixing cursor handling with hybrid graphics. In some sense the work Hans has been doing, and check his blog entry linked, is part of that washlist I talked about, the many smaller items that needs to work smoothly for this to go from ‘checkbox works’ to ‘actually works’. He is also working with the DNF team to allow us to control the kernel updates if you use the binary NVidia driver, meaning that we will only bump up your kernel driver when we have the binary NVidia driver module ready too. If for any reason the binary Nvidia driver doesn’t work we want to have graceful fallback to Nouveau.

Fifth step has been Jonas Ådahls work on enabling the binary NVidia driver for Wayland. He has put together a set of patches to be able to support NVidias EGLStreams interface, which means that starting from Fedora Workstation 25 you will be able to use Wayland also with NVidias binary driver.
You can see his work in progress patches here. Jonas will also be looking at implementing hybrid graphics support in Wayland, so we ensure that also for this usecase Wayland is on par with X for Fedora Workstation 26.

The sixth step has been work done by Bastien Nocera to ensure we expose this functionality in the user interface. The idea is that you should be able to configure on a per application basis which GPU they are being launched on. It also means that you can now get all your GPU information in the GNOME about screen also when you have dual-GPU systems. More details in his blog post here.


Choosing discete GPU in GNOME Shell

The seventh step is the work that Simone Caronni from Negativo17 has been doing on working with us on packaging the binary NVidia driver in a way that makes all this work. You can find his repo here on Negativo17, but Simone has also been working with Kalev Lember and Richard Hughes to ensure the driver show up correctly in GNOME Software once you have the repository enabled.

NVidia driver in GNOME Software

NVidia driver in GNOME Software

The plan is to offer the driver in Fedora Workstation 25 as third party software, but we haven’t yet made the formal proposal due to wanting to be sure we ironed out all important bugs first, both on our side and on NVidia side.

So as you can see from all of this there are a lot of components involved and since we are trying to support both X and Wayland with all of this the job hasn’t exactly been easy. There are for sure some things that will not be ready in time for Fedora Workstation 25, for instance if you want to use the binary NVidia driver we will not be able to make that work with XWayland. So native Wayland applications will be fine, including games using SDL on top of Wayland, but due to how the stack is architected we haven’t gotten around to implementing bridging OpenGL from Xwayland down to the binary NVidia driver. With Nouveau it should work however. This corner case we will have to figure out for Fedora Workstation 26, but for now we have decided that if we detect a Optimus system we will default you to X instead of Wayland.

Get involved
As always we love for more people to join us in this effort and one good way to get started with that is to join our Hybrid graphics test day on Thursday the 3rd of November!

16 thoughts on “Hybrid Graphics and Fedora Workstation 25

  1. Thanks for the work on this.

    Question: why Negativo17’s version and not RPMFusion? And the fact that it could be attained from either place begs the question of whether it’s time for Red Hat / Fedora to finally have a third party repo that’s official that supports non-free software, but not problematic software – in other words support Nvidia Binary, but not MPEG playback.

    • There where a set of smaller items that made us go with negativo17. The initial contact with Simone happened simply because he was the one packaging the NVidia driver in what the Red Hat graphics team considered the ‘right way’. The negativo setup of individual repositories for each thing offered was also a good fit for what was needed. And last, but not least when reaching out to Simone he was very positive and willing to work with us on further improvements to the packaging. So it looked the most like what we wanted to begin with and Simone being very responsive and nice to work with sealed the deal.

  2. Are you going to support GBM and EGLStreams forever or is this temporary until Mesa and Nvidia can agree on a solution?

    • It is temporary until a unified solution is available. That said I assume it wouldn’t be a single day cutover, instead the two backends would continue to live on for quite a while until we can feel confident the vast majority of our users are on new enough drivers to only support the future solution.

  3. Sorry if this is a bit offtopic, but the first sentence was very interesting to me as I’m a Fedora 24 laptop user right now.

    So what I wanted to ask is are there any plans to improve the trackpad experience on Fedora (and hopefully every distro in the process) ? It’s not ultra awful as it is, but it’s a long way off a Macbook in my experience.

    To make the comparison clear in terms of my experience using both: when I’m using OSX on a Macbook I probably wouldn’t consider using a mouse even if it was available. On Linux (in general) I dread when I have to use the trackpad.

    It’s the little things, transitioning from two finder scroll to moving the cursor, palm rejection reliability, scroll experience etc. Choppy scrolling on linux vs smooth scrolling on OSX, also kinetic scrolling not working as well on linux/synaptic driver when enabled. What I mean by working well is not the scrolling itself but how usable it is. For eg. if you enable the kinetic scroll on linux, and scroll a webpage on any webrowser and press CTRL while the kinetic scroll still “decelerates” the page will zoom in/out because the shortcut is activated and this is infuriating for me!

    • We are constantly trying to improve trackpad support, in fact our input expert Peter Hutterer posted a request on Google Plus today asking for people with touch/trackpad issues to come forward. Post this comment on his Google plus post and you are probably a good step forward with getting what you want.

  4. Hi there.. no hybrid amd gpupro support? I read they just released driver for red hat

    • There is, and I did mention it in my blog post. Hans de Goede got such a laptop recently from our friends at Dell that he is using for verifying that all of this also works with AMD.

      • You mentioned Hans and AMD separately, but neither the Hans-reference here nor his linked blog post specifically mention AMD at the same time.

    • I don’t know any of the details, but I think I’m right to say that generally speaking the AMD case is rather simpler because we don’t need to worry about the proprietary driver. In AMD-land the free driver is much better, probably to the point where you’re as likely to want it as the proprietary driver on any random system, and it’s constantly getting better (and the proprietary driver getting worse). So we just don’t really worry about the proprietary driver for AMD adapters any more, and all we need to be concerned with is enabling the hybrid support with the free driver stack, which is a simpler problem.

  5. As someone who bought a Optimus laptop 2 years ago without being aware of the issue with Linux beforehand, the content of this blog post has got me very, very excited!

    So far Fedora (Cinnamon spin) has been the most stable and elegant linux distribution that I’ve used and these upcoming changes, especially being able to use Wayland on my system within the next twelve months, are just (for me) another example of why you produce such a fantastic os.

    The fact that you are collaborating with nVidia on this one is also very heartening. Thank you for making Fedora such a nice distribution to use.

  6. Wow that’s a lot of work. I don’t even know if my laptops have hybrid graphics, Intel is good enough. How dare you work on Fedora features that don’t directly benefit me, I want my money back ;-)

    “MST support” was new to me, is it software support for “multi-stream transport” in Display Port connections?

Comments are closed.