# AMD Ryzen7, Vega 3 OpenGL with hardware acceleration



## f0r3ign3r (May 23, 2020)

After a fresh FreeBSD installation, I was trying to run blender in the laptop and I noticed that just grabbing the default cube and trying to rotate around it performs really slow and sluggy/jumpy instead of making a smooth movement.

This are the pkgs installed:

```
#installed pkgs
mesa-demos-8.4.0_2             OpenGL demos distributed with Mesa
mesa-dri-19.0.8                OpenGL hardware acceleration drivers for DRI2+
mesa-libs-19.0.8               OpenGL libraries that support GLX and EGL clients
xf86-video-amdgpu-19.1.0_1     X.Org amdgpu display driver
drm-devel-kmod-5.0.g20200507   DRM modules for the linuxkpi-based KMS components (development version)
libdrm-2.4.99,1                Userspace interface to kernel Direct Rendering Module services
```

After some research, I discovered that using `$ LIBGL_ALWAYS_SOFTWARE=1 blender` makes the user interface smooth again.

That "might" be a tempral solution, but I wanted to go deeper. This machine has a dedicated gpu, and it'll be a waste if it couldn't run OpenGL properly, so I tried the program `gears`.
According to freedesktop, if the frames per second are less than 500-1000, then something could be wrong.
I'm getting 60 fps ~

The next step was to check out if the machine was falling back to software rendering, but apparently it's not:

```
$ LIBGL_DEBUG=verbose glxinfo | grep render
libGL: Using DRI3 for screen 0
direct rendering: Yes
```

At the Freenode chat I was told to check which vendor was `glxinfo` displaying. I checked it:

```
$ glxinfo | grep OpenGL

OpenGL vendor string: X.Org
OpenGL renderer string: AMD RAVEN (DRM 3.27.0, 13.0-CURRENT, LLVM 8.0.1)
OpenGL core profile version string: 4.5 (Core Profile) Mesa 19.0.8
OpenGL core profile shading language version string: 4.50
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 4.5 (Compatibility Profile) Mesa 19.0.8
OpenGL shading language version string: 4.50
OpenGL context flags: (none)
OpenGL profile mask: compatibility profile
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.2 Mesa 19.0.8
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
OpenGL ES profile extensions:
```

It should be AMD instead of X.Org, or at least that was what I understood in the chat. Never mind, I cannot get `gears` to go more thant 60fps. Maybe there's some parameter making some kind of v-sync but I'm unable to find it. Neither I can run blender using gpu acceleration, its user interface is slow.

I've been checking xorg.conf.d files, dmesg and xorg.0.log reports to try and find what can be causing the problem.

I found that the module `amdgpu` has "X.Org" as vendor

```
[   134.604] (II) LoadModule: "amdgpu"
[   134.605] (II) Loading /usr/local/lib/xorg/modules/drivers/amdgpu_drv.so
[   134.615] (II) Module amdgpu: vendor="X.Org Foundation"
```
and the module `fb` also shares vendor name:

```
[   148.966] (II) Loading sub module "fb"
[   148.967] (II) LoadModule: "fb"
[   148.967] (II) Loading /usr/local/lib/xorg/modules/libfb.so
[   148.969] (II) Module fb: vendor="X.Org Foundation"
```
but maybe it's unrelated.

One strange thing I found in `dmesg` related to drm was this:

```
[drm] BIOS signature incorrect 0 fe
```
but I have no idea what can it mean.

The 10-amdgpu.conf looks like this:

```
#10-amdgpu.conf
Section "Device"
        Identifier "AMDgpu"
        Driver "amdgpu"
        Option "DRI" "3"
        Option "PrimaryGPU" "Yes"
EndSection
```

Inside /etc/rc.conf this line is enabled:

```
kld_list="/boot/modules/amdgpu.ko"
```

And /boot/loader.conf has syscons disabled.

Here's a complete xorg.0.log pastebin and here's a complete dmesg pastebin


At this point, I'm unable to figure out what's wrong with the gpu. Has anyone an idea on how to get going with it?

Thanks in advance.


----------



## Alexander88207 (May 24, 2020)

Your graphics card is configured correctly, but you have to know that you are using the developer version of the amdgpu kernel modules and i even had problems myself with my RX 570 on -CURRENT. It's also normal that the vendor is "X.Org Foundation" so nothing to worry about. To reach more FPS than your monitor refresh rate with `glxgears` use the command `vblank_mode=0 glxgears`

I would also like to point out that you are using an unsupported version of FreeBSD see: Topics about unsupported FreeBSD versions


----------



## Alain De Vos (May 24, 2020)

Is "xf86-video-amdgpu" required ? (when the linuxkpi driver is used)


----------



## Alexander88207 (May 24, 2020)

Alain De Vos said:


> Is "xf86-video-amdgpu" required ? (when the linuxkpi driver is used)



Its not strictly requiered but if you want the best perfomance then yes...

If you dont have setup x11-drivers/xf86-video-amdgpu then Xorg will take the non accelerated driver "modesetting" and you dont have the variable refresh rate (FreeSync) feature. But FreeSync is not interesting for now.


----------



## christhegeek (May 25, 2020)

You are using vega with efi ? how ?  mine won't start xorg !  I need to disable syscons and then it stuck on efi framebuffer information and i can't do anything at all i can't even switch to another terminal.(trying to make my laptop to work ryzen3 vega3)


----------



## f0r3ign3r (May 27, 2020)

christhegeek said:


> You are using vega with efi ? how ?  mine won't start xorg !  I need to disable syscons and then it stuck on efi framebuffer information and i can't do anything at all i can't even switch to another terminal.(trying to make my laptop to work ryzen3 vega3)


In order to get it working I had to jump into FreeBSD 13-CURRENT so I can run the latest `drm-devel-kmod`, otherwise I had the same problem you mention booting the system with efi and vega.


----------



## christhegeek (May 28, 2020)

I have tried FreeBSD 13 , started with a minimal installation with slim and openbox i succeed running it about three times !
Then i tried another display manager and desktop and was unable to start xorg stuck on EFI Framebuffer !!
I will try installing freebsd without any efi partitions only freebsd-boot and see if my laptop  could boot  from there something i don't believe.
I will try again using only slim and openbox just in case.




f0r3ign3r said:


> In order to get it working I had to jump into FreeBSD 13-CURRENT so I can run the latest `drm-devel-kmod`, otherwise I had the same problem you mention booting the system with efi and vega.


----------



## Raffeale (Jun 9, 2020)

try to compile /usr/ports/graphics/mesa-dri , checked VAAPI and VDPAU option in menu. and then then reboot , it will work.
the mesa-dri don't not support hardware acceleration with amd cpu (VEGA vga card) , maybe the maintainer forget compile that in it. so you have to compile it manualy


----------



## f0r3ign3r (Jun 28, 2020)

Raffeale said:


> try to compile /usr/ports/graphics/mesa-dri , checked VAAPI and VDPAU option in menu. and then then reboot , it will work.
> the mesa-dri don't not support hardware acceleration with amd cpu (VEGA vga card) , maybe the maintainer forget compile that in it. so you have to compile it manualy



Thanks for the hint, I didn't know about that. What should exactly work? I've just built `mesa-dri` from source enabling VAAPI and VDPAU, and blender stills lagging in the viewport. 
`pkg info mesa-dri` confirms options:

```
VAAPI : on
VDPAU : on
WAYLAND : on
```


----------



## Raffeale (Dec 20, 2020)

maybe the software didn't support video accerleration or you didn't do right setting!


----------



## Doctorj1 (Oct 24, 2022)

Sorry to revive the thread, but did you ever get this working? I'm having similar issues on my RX480. It was working fine until a recent pkg update, pkg upgrade and pkg autoremove


----------

