4

Distro: Pop OS 19.10
Laptop: HP Notebook 15-bs185tx

Graphics Card:

  • AMD Radeon™ 520 Graphics (2 GB DDR3 dedicated)
  • Intel Corporation UHD Graphics 620

I've tried almost all the solutions available online but nothing works. Both VGA and Display Controller are running on my built-in Intel graphics. I've used multiple commands including this one lspci -k | grep -EA3 'VGA|3D|Display' to see my active graphics adapters. Please let me know if you have any questions regarding the problem.

Thank you!

0

1 Answer 1

5

TL;DR (but the values 1 0 might not be correct on your system):

$ xrandr --setprovideroffloadsink 1 0
$ export DRI_PRIME=1
$ glxinfo | grep "OpenGL renderer string"

If this feature doesn't exist at the hardware level then that's not possible, but an alternative exists.

This is shown in the VGA Switcheroo documentation:

vga_switcheroo is the Linux subsystem for laptop hybrid graphics. These come in two flavors:

  • muxed: Dual GPUs with a multiplexer chip to switch outputs between GPUs.
  • muxless: Dual GPUs but only one of them is connected to outputs. The other one is merely used to offload rendering, its results are copied over PCIe into the framebuffer. On Linux this is supported with DRI PRIME.

Hybrid graphics started to appear in the late Naughties and were initially all muxed. Newer laptops moved to a muxless architecture for cost reasons. A notable exception is the MacBook Pro which continues to use a mux.

So I'm assuming your hardware is muxless, like this:

      ╔═══════════════╗
      ║               ║
      ║    display    ║
      ║               ║
      ╚═══════════════╝
           │
       ╭───╯       X
       │           ┊
┌────────┐       ┌────────┐
│        │       │        │
│  iGPU  │───────│  dGPU  │
│        │       │        │
└────────┘       └────────┘

While some good documentation can be found (eg: on Archlinux), I couldn't find some official definitive documentation authoritative for the usage of DRI_PRIME. The only maybe semi-official documentation I found was for... Nvidia's nouveau driver and the play-on-words Optimus/PRIME:

Using Optimus/Prime

'PRIME GPU offloading' and 'Reverse PRIME' is an attempt to support muxless hybrid graphics in the Linux kernel.

While the name probably originated from initial Nvidia support, it's of course generic and works with AMD.

You can query and change settings using the xrandr command:

--listproviders
Report information about the providers available.

--setprovideroutputsource provider source
Set source as the source of display output images for provider. This is only possible if source and provider have the Source Output and Sink Output capabilities, respectively. If source is 0x0, then provider is disconnected from its current output source.

--setprovideroffloadsink provider sink
Set provider as a render offload device for sink. This is only possible if provider and sink have the Source Offload and Sink Offload capabilities, respectively. If sink is 0x0, then provider is disconnected from its current render offload sink.

For example, also with a laptop using an Intel iGPU and some AMD dGPU:

$ xrandr --listproviders
Provider 0: id: 0x68 cap: 0xb, Source Output, Sink Output, Sink Offload crtcs: 4 outputs: 3 associated providers: 0 name:Intel
Provider 1: id: 0x41 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 2 outputs: 0 associated providers: 0 name:AMD Radeon (TM) HD8530M @ pci:0000:04:00.0

Note that Provider 1 has outputs: 0: not able to output, whatever the other properties Source Output and Sink Output might say. If your system does display a value different than 0 for the dGPU's outputs: property, then you might have other options available (direct display, possibly also in conjunction with Reverse PRIME using --setprovideroutputsource) that won't be covered by this answer.

To prepare the use for (3D) GPU tasks offloaded to the dGPU, with the previous example this can be done:

$ xrandr --setprovideroffloadsink 'AMD Radeon (TM) HD8530M @ pci:0000:04:00.0' Intel

Instead of names, the ids, or even more simply index can be used. The two commands below would do the same. One has to take care of not inverting directions or bad things can happen.

$ xrandr --setprovideroffloadsink 0x41 0x68
$ xrandr --setprovideroffloadsink 1 0

And now:

$ xrandr --listproviders
Providers: number : 2
Provider 0: id: 0x68 cap: 0xb, Source Output, Sink Output, Sink Offload crtcs: 4 outputs: 3 associated providers: 1 name:Intel
Provider 1: id: 0x41 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 2 outputs: 0 associated providers: 1 name:AMD Radeon (TM) HD8530M @ pci:0000:04:00.0

the two providers are now associated, and exporting the special (to mesa) variable DRI_PRIME=1 selects the dGPU to render with:

$ DRI_PRIME=0 glxinfo | grep "OpenGL renderer string"
OpenGL renderer string: Mesa DRI Intel(R) Haswell Mobile 
$ DRI_PRIME=1 glxinfo | grep "OpenGL renderer string"
OpenGL renderer string: AMD Radeon (TM) HD8530M (OLAND, DRM 3.36.0, 5.6.3-amd64, LLVM 6.0.0)

So to run a GPU-intensive 3D program called myhungrygame, you'd probably do (if dGPU comes after iGPU):

$ xrandr --setprovideroffloadsink 1 0 # X11-wide setting
$ export DRI_PRIME=1
$ ./myhungrygame

If you manage to do the first two things before the desktop environment is loaded, then all will use the dGPU for 3D offloading by default, which is probably not a good idea for a laptop.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .