# Does FreeBSD support DRI PRIME or similar switchable graphics yet?



## agregate (Mar 20, 2021)

I understand this question has been asked before on the forums over the years but I would like to request an update for 2021, and given 13.0-RELEASE is right around the corner, perhaps some things have been added that I am not yet aware of.

I'm running a ThinkPad T400 with an Intel Mobile 4 Series Chipset and an AMD ATI Mobility Radeon HD 3450/3470. Intel graphics work just fine on BSD using either one of the drm-kmod or xf86-video-intel driver but running `xrandr --listproviders` shows me only the Intel sink and AMD is nowhere to be found.

Upon inspection of the Xorg log, both drivers are loaded and then I get

`(WW) VGA arbiter: cannot open kernel arbiter, no multi-card support`

and the radeon driver is unloaded again, so that X starts with Intel only. I haven't bothered uploading an Xorg log because I have a bad feeling the answer to my question will be a simple 'no'. If not, I'll readily upload whatever information is required.

On Linux I can quite easily prefix the `DRI_PRIME=1` variable to any command to run it through the dGPU and in context of games this works flawlessly. I want to switch to BSD very badly but this is the one thing hindering my approval.

Does anybody know of a recent method that allows both Intel and AMD gpu's to work _together?_ I understand they work separately if I disable one or the other through BIOS but I am looking for the ability to use my 'hybrid graphics' as AMD advertised it.

PS: I'm on 12.2-RELEASE.

Cheers.


----------



## zirias@ (Mar 20, 2021)

I assume the answer is no, according to this search on the source:








						Search · CONFIG_VGA_ARB · freebsd/drm-kmod
					

drm driver for FreeBSD. Contribute to freebsd/drm-kmod development by creating an account on GitHub.




					github.com
				




My guess is that this is Linux' kernel config knob for the feature, and it isn't enabled anywhere, which probably has reasons…


----------



## agregate (Mar 20, 2021)

Zirias said:


> I assume the answer is no, according to this search on the source:
> 
> 
> 
> ...


And while the encapsulated functions are called they don't do anything either... That's a shame I suppose - though is drm-kmod the only way?


----------



## Snurg (Mar 20, 2021)

You might want to try without KMS.

Just remove the i915kms.ko and radeonkms.ko kernel modules as well as drm-kmod.
According to tests made by reputable people, the xf86-video-intel driver seems to work fine without KMS.

Personally, I had not yet the opportunity to test on actual hardware, whether the xf86-video-ati driver still works without KMS.
So you might want to give it a try.


----------



## zirias@ (Mar 20, 2021)

I think this is rather pointless, as the goal is to actually use accelerated 3d-rendering on the second card for a specific application while normally using the primary card in the X session.

I'm not sure *why* this option isn't active, I assume there *are* reasons, but it might make sense to ask about it on a mailing list (freebsd-desktop and freebsd-x11 would come to mind? Is there a better suited one?) or directly on the drm-kmod github project.



agregate said:


> is drm-kmod the only way?


Well, this is about rendering performance, right? So, yes, drm-kmod are the only kernel rendering drivers available on FreeBSD, they are imported from Linux.

For now, if the Radeon is the more powerful GPU and you need that, your only option would be to use it exclusively.


----------



## Snurg (Mar 20, 2021)

Zirias said:


> I think this is rather pointless, as the goal is to actually use accelerated 3d-rendering on the second card for a specific application while normally using the primary card in the X session.


Is this possible only with KMS?


----------



## zirias@ (Mar 20, 2021)

Snurg said:


> Is this possible only with KMS?


You won't get *any* accelerated 3d rendering without a kernel driver.


----------



## kpedersen (Mar 20, 2021)

I have very little knowledge of this (I actually thought multi-GPU in desktops / laptops was a novelty from ~2012 that has lost popularity).

I don't suppose opening up an EGL context with direct access to the GPU rather than via XServer could still function?

https://developer.nvidia.com/blog/egl-eye-opengl-visualization-without-x-server/


----------



## Snurg (Mar 20, 2021)

Zirias said:


> You won't get *any* accelerated 3d rendering without a kernel driver.


Are you sure?
As far as I understand, the xf86-video-ati and xf86-video-amdgpu as well as the  xf86-video-intel are made by their respective vendors.
So I wonder, don't they have full functionality (incl. 3D)?

TearFree is just an example why many people use these drivers, as the kernel driver apparently lacks a lot of the functionality of the vendors' drivers.

But I don't really know, so I ask.


----------



## zirias@ (Mar 20, 2021)

Yes, I'm sure. For 3d acceleration, DRI/DRM is used, which is an interface with the kernel driver. And btw, they aren't "made by vendors" either.


----------



## Snurg (Mar 20, 2021)

Zirias said:


> Yes, I'm sure. For 3d acceleration, DRI/DRM is used, which is an interface with the kernel driver.


Thank you, that were the right pointers. https://dri.freedesktop.org/wiki/


Zirias said:


> And btw, they aren't "made by vendors" either.


To me it seems that the vendors have at least some role in the driver development, as the copyrights suggest.

https://gitlab.freedesktop.org/xorg/driver/xf86-video-amdgpu/-/blob/master/src/amdgpu_drv.h :

```
* Copyright 2000 ATI Technologies Inc., Markham, Ontario, and
 *                VA Linux Systems Inc., Fremont, California.
 *
 * All Rights Reserved.
```
https://gitlab.freedesktop.org/xorg/driver/xf86-video-intel/-/blob/master/src/intel_device.c :

```
Copyright 2013 Intel Corporation.  All Rights Reserved.
```


----------



## zirias@ (Mar 20, 2021)

Well sure, they probably contribute (a lot of?) code, but the drivers are managed in the XOrg project, at least as far as I know.


----------



## agregate (Mar 20, 2021)

Zirias said:


> I think this is rather pointless, as the goal is to actually use accelerated 3d-rendering on the second card for a specific application while normally using the primary card in the X session.


You're right. X is run on the Intel iGPU and rendering is deferred upon request to the dGPU which is then passed back to X.



Zirias said:


> Well, this is about rendering performance, right? So, yes, drm-kmod are the only kernel rendering drivers available on FreeBSD, they are imported from Linux.


As far as I know the only drivers on Linux I have come from the xf86 set but regardless, I'm going to have to wait for drm-kmod to hopefully provide support one day...


----------



## zirias@ (Mar 20, 2021)

agregate said:


> As far as I know the only drivers on Linux I have come from the xf86 set but regardless, I'm going to have to wait for drm-kmod to hopefully provide support one day...


The drivers in drm-kmod are taken from Linux. On Linux, they are part of the official kernel. So, you didn't have to install anything, they were just auto-loaded.


----------



## Hakaba (Mar 20, 2021)

PRIME is not only for performance.
I have a laptop (MSI P65) where HDMI and Displayport are wired in the NVidia card and the internal screen is wired in the Intel card.
I am not able to use external screen and the internal screen at the same time.
As I know, there is no solution in FreeBSD.


----------



## zirias@ (Mar 20, 2021)

Hakaba I *assume* this should work if you sacrifice direct rendering for one of the displays. But I don't own such a machine, so can't test.


----------



## Deleted member 30996 (Mar 20, 2021)

Every picture tells a story Here's the rest of the Story  :

Thinkpad T400
Intel Core2 Duo P8600 @ 2.4GHz
8GB PC3-8500 RAM
250GB Scorpio Black HDD @ 7200RPM
Switchable Graphics with Intel GMA 4500MHD and ATI Mobility Radeon HD 3470
14.1" 1280x800 (WXGA) with LED backlight
Intel HD Audio
CD-RW/DVD
Intel Gigabit Ethernet (10/100/1000) PCI-Express
This has "Switchable Graphics" and needs to be put into "Discreet" graphics mode in the BIOS. It then defaults to the Radeon chip and runs fine without any tweaking. I installed both drivers when building X.

https://forums.freebsd.org/threads/notebook-laptop-compatibility-list.17308/page-5


----------



## agregate (Mar 20, 2021)

Trihexagonal said:


> This has "Switchable Graphics" and needs to be put into "Discreet" graphics mode in the BIOS. It then defaults to the Radeon chip and runs fine without any tweaking. I installed both drivers when building X.


By forcing it into a single-GPU mode you are by the very definition of the word *not* using switchable graphics.
It's nice to see other people using T400's too but unfortunately I cannot afford to change to BSD unless I can have both cards active at once.


----------



## Hakaba (Mar 22, 2021)

Zirias said:


> Hakaba I *assume* this should work if you sacrifice direct rendering for one of the displays. But I don't own such a machine, so can't test.


I did not find a way. I test a lot of config without succes.


----------



## Deleted member 30996 (Mar 22, 2021)

agregate said:


> By forcing it into a single-GPU mode you are by the very definition of the word *not* using switchable graphics.
> It's nice to see other people using T400's too but unfortunately I cannot afford to change to BSD unless I can have both cards active at once.



You ask if it can be done. I show you  it has been done. Then you tell me I'm doing it wrong? 

I've used the Intel and Radeon on different builds and Radeon is the one I want running all the time, Same goes with Optimus, I want the nvidia driver all the time. Too bad for you but I'll keep running mine as mine.

We'll have you over for supper on night, no doubt.


----------



## agregate (Mar 22, 2021)

Trihexagonal said:


> You ask if it can be done. I show you  it has been done. Then you tell me I'm doing it wrong?


I don't think you know what you're talking about. *Switchable *graphics means switching between graphics cards _*while the system is running*_ and setting a specific card in the BIOS is NOT what I am asking, nor is it the same thing.


Trihexagonal said:


> This has "Switchable Graphics" and needs to be put into "Discreet" graphics mode in the BIOS. It then defaults to the Radeon chip and runs fine without any tweaking. I installed both drivers when building X.


You are disabling the ability to switch graphics by putting it into discrete mode.... It doesn't 'default' to the card at all. You are selecting the card by manually setting it to discrete. The Radeon in these computers is the dGPU and the Intel the iGPU. Your computer doesn't get to choose which is which.


Trihexagonal said:


> We'll have you over for supper on night, no doubt.


I beg your pardon?


----------



## SirDice (Mar 22, 2021)

Settle down ladies, don't get your knickers in a twist over a simple misunderstanding.

AMD's "Dynamic Switchable Graphics" is similar to NVidia's Optimus. Graphics normally run through the low-power Intel graphics until you access things like OpenGL, then the AMD or NVidia GPU is kicked into gear and provides the rendering. This is done to save power during normal operation, which is rather important for laptops for example. It has nothing to do with being able to switch between IGD (Internal Graphics Device) or PEG (PCIe Graphics), although that function is often available in the BIOS/UEFI too.


----------



## shkhln (Mar 22, 2021)

s/simple/persistent/


----------

