Jump to content

Accelerated video - options for installing and running


eshelton

Recommended Posts

I'm looking to try an OPi5 for GPGPU. After seeing trunk recently added the patches needed to use the "gofaster" option for panfork, and having seen reports of glmark2 scores of 4000 and 5000 while never coming close to that myself, I decided to pull together the various bits of info out there and just try all of the options. A number of things done below are often described vaguely -- hopefully it's helpful here to lay out a concrete set of steps to follow and what to expect.

 

There are two options for accelerated video: panfork and ARM's closed source "blob" driver. With either option, it sounds like you should switch from X11 to Wayland. If you are looking at doing OpenCL or Vulkan, you will have to use the blob driver for the foreseeable future. FYI, OpenCL benchmarks at 470 Gflops single precision, 910 Gflops half precision.

 

Option 1: Installing panfork

This is pretty much explained on the project page for this SBC, but maybe it will help someone to see each step in detail. I started with installing the latest nightly build. Then I ran the following in a terminal:

sudo add-apt-repository ppa:liujianfeng1994/panfork-mesa
wget https://github.com/JeffyCN/rockchip_mirrors/raw/libmali/firmware/g610/mali_csffw.bin
sudo cp mali_csffw.bin /lib/firmware/
sudo chmod 664 /lib/firmware/mali_csffw.bin
sudo add-apt-repository ppa:liujianfeng1994/rockchip-multimedia
sudo vi /etc/apt/preferences.d/rockchip-multimedia-ppu
[save the following three lines in this file]
Package: *
Pin: release o=LP-PPA-liujianfeng1994-rockchip-multimedia
Pin-Priority: 600
sudo vi /etc/apt/preferences.d/panfork-mesa-ppu
[save the following three lines in this file]
Package: *
Pin: release o=LP-PPA-liujianfeng1994-panfork-mesa
Pin-Priority: 600
sudo apt update
sudo apt dist-upgrade
sudo vi /etc/udev/rules.d/98-mali-accel.rules
[save the following four lines in this file]
KERNEL=="mpp_service", MODE="0660", GROUP="video"
KERNEL=="rga", MODE="0660", GROUP="video"
KERNEL=="system-dma32", MODE="0666", GROUP="video"
KERNEL=="system-uncached-dma32", MODE="0666", GROUP="video" RUN+="/usr/bin/chmod a+rw /dev/dma_heap"
sudo apt install chromium-browser=$(apt-cache show chromium-browser|grep Version|grep rkmpp|cut -d " " -f2) chromium-codecs-ffmpeg-extra=$(apt-cache show chromium-browser|grep Version|grep rkmpp|cut -d " " -f2) libv4l-rkmpp v4l-utils
sudo ln -s /lib /usr/lib64
cd /usr/lib64/ && sudo ln -s aarch64-linux-gnu/libv4l2.so.0.0.0 libv4l2.so
sudo vi /etc/rc.local
[add the following six lines to this file]
echo dec > /dev/video-dec0
chown root:video /dev/video-dec0
chmod 0660 /dev/video-dec0
echo enc > /dev/video-enc0
chown root:video /dev/video-enc0
chmod 0660 /dev/video-enc0
sudo vi /etc/chromium-browser/default
CHROMIUM_FLAGS="--use-gl=egl"
sudo apt install gnome-shell ubuntu-gnome-desktop glmark2-es2-wayland
sudo reboot

 

From there you are running Wayland and the panfork accelerated driver.

 

glmark2 benchmarking of various options for panfork:

For this, you need to use glmark2-es2-wayland (installed above).

 

First, I ran glmark2 on the system fresh from the above reboot:

foobar@orangepi5:~/install$ glmark2-es2-wayland
=======================================================
    glmark2 2021.02
=======================================================
    OpenGL Information
    GL_VENDOR:     Panfrost
    GL_RENDERER:   Mali-G610 (Panfrost)
    GL_VERSION:    OpenGL ES 3.1 Mesa 23.0.0-devel
=======================================================
. . . (test component scores omitted to shorten this post) . . .
=======================================================
                                  glmark2 Score: 943
=======================================================

 

I was pretty underwhelmed given the scores I'd seen reported, so next I tried using the "gofaster" option for panfork (done by setting an environment variable, as shown below):

foobar@orangepi5:~/install$ PAN_MESA_DEBUG=gofaster glmark2-es2-wayland
=======================================================
    glmark2 2021.02
=======================================================
    OpenGL Information
    GL_VENDOR:     Panfrost
    GL_RENDERER:   Mali-G610 (Panfrost)
    GL_VERSION:    OpenGL ES 3.1 Mesa 23.0.0-devel
=======================================================
. . . (test component scores omitted to shorten this post) . . .
=======================================================
                                  glmark2 Score: 2299
=======================================================

A significant improvement, but still short of the reports I had seen.

 

Finally, I adjusted the governors for the CPUs and DMC (Dynamic Memory Controller) to "performance" (example of how to do that shown below). Here things really shined. Adjusting the DMC is an important component of this:

foobar@orangepi5:~/install$ echo performance | sudo tee /sys/bus/cpu/devices/cpu[046]/cpufreq/scaling_governor /sys/class/devfreq/dmc/governor
performance
foobar@orangepi5:~/install$ PAN_MESA_DEBUG=gofaster glmark2-es2-wayland
=======================================================
    glmark2 2021.02
=======================================================
    OpenGL Information
    GL_VENDOR:     Panfrost
    GL_RENDERER:   Mali-G610 (Panfrost)
    GL_VERSION:    OpenGL ES 3.1 Mesa 23.0.0-devel
=======================================================
. . . (test component scores omitted to shorten this post) . . .
=======================================================
                                  glmark2 Score: 4489
=======================================================

 

Since the score of 5000 was reported for an overclocked system, I called this done. It beats the out of the box score for the Khadas Edge2.

 

Option 2: installing the ARM blob driver

I also gave this a try -- partly due to interest in evaluating OpenCL performance, and partly to see if the vendor-provided driver could go even faster. I couldn't find a decent set of instructions for how to install the blob driver, so I took a different approach -- I used the package files produced by Khadas for building their Edge2 Ubuntu images. Maybe there are packages already available through Armbian, and I just couldn't identify them.

The package files can be found in these four repos:

https://github.com/numbqq/mali-debs
https://github.com/numbqq/mpp-rockchip-debs
https://github.com/numbqq/rga-rockchip-debs
https://github.com/numbqq/gstreamer-rockchip-debs
Altogether, I found the following package files:

gstreamer1.0-rockchip1_1.14-5_arm64.deb
rockchip-mpp-dev_1.5.0-8_arm64.deb
rockchip-mpp-sample_1.5.0-8_arm64.deb
rockchip-mpp_1.5.0-8_arm64.deb
rockchip-rga-dev_2.2.0-6_arm64.deb
rockchip-rga-sample_2.2.0-6_arm64.deb
rockchip-rga_2.2.0-6_arm64.deb
linux-gpu-mali-wayland_1.0-g610-20220510_arm64.deb

The last one had to be installed with "--force-overwrite" because of a file duplicated with an existing package. I also installed the ubuntu-desktop package to switch over to Wayland. On my first login, "echo $XDG_SESSION_TYPE" reported x11. I logged back out, and logged in again checking the gear icon to make sure the Wayland-related one was selected. I don't know if the gear icon was needed, but that time Wayland was active.

 

glmark2 benchmarking of various options for the blob driver:

First, I did a run with the default governor settings:

foobar@orangepi5:~/install$ glmark2-es2-wayland
arm_release_ver of this libmali is 'g6p0-01eac0', rk_so_ver is '6'.
arm_release_ver of this libmali is 'g6p0-01eac0', rk_so_ver is '6'.
=======================================================
    glmark2 2021.02
=======================================================
    OpenGL Information
    GL_VENDOR:     ARM
    GL_RENDERER:   Mali-LODX
    GL_VERSION:    OpenGL ES 3.2 v1.g6p0-01eac0.ba52c908d926792b8f5fe28f383a2b03
=======================================================
. . . (omitted as above) . . .
=======================================================
                                  glmark2 Score: 2564
=======================================================

Around 11% better than panfork "gofaster."

 

Then I did a run with the governors set to "performance":

foobar@orangepi5:~/install$ echo performance | sudo tee /sys/bus/cpu/devices/cpu[046]/cpufreq/scaling_governor /sys/class/devfreq/dmc/governor
performance
foobar@orangepi5:~/install$ glmark2-es2-wayland
arm_release_ver of this libmali is 'g6p0-01eac0', rk_so_ver is '6'.
arm_release_ver of this libmali is 'g6p0-01eac0', rk_so_ver is '6'.
=======================================================
    glmark2 2021.02
=======================================================
    OpenGL Information
    GL_VENDOR:     ARM
    GL_RENDERER:   Mali-LODX
    GL_VERSION:    OpenGL ES 3.2 v1.g6p0-01eac0.ba52c908d926792b8f5fe28f383a2b03
=======================================================
. . . (omitted as above) . . .
=======================================================
                                  glmark2 Score: 3961
=======================================================

So, in performance mode, panfork is the winner by 13%.

Link to comment
Share on other sites

Excelent work. Thank you for all that information in one place. Tested. Works. My glmark result=4480.  So nice to see 4k/2k@60fps youtube with no lost frames or almost no lost frames and CPU usage~20%. I had that state few times before on orange pi 5 armbian when tested a lot of solutions.

Now I try to play high resolution hevc files on armbian with above cofiguration presented by @eshelton. After one hour of trials same results on VLC and MPV. First few seconds of video are ok, and then as below. Any ideas? 

3NFXigv.png

Edited by MarcAndro
Link to comment
Share on other sites

i did everything u did but after the first horse demo i get 

 

DRM_IOCTL_PANFROST_CREATE_BO failed: Cannot allocate memory
mmap(GPU BO): Cannot allocate memory

 

with the es2 benchmark but the other wayland benchmark works fine. only 1600 score tho. also short clips from, say,  reddit has a green screen with chromium. i must've installed something that conflicts with this

Link to comment
Share on other sites

I got the same error "could not initialize canvas". After I made sure I was using Wayland the benchmark worked fine (like eshelton wrote: " I also installed the ubuntu-desktop package to switch over to Wayland. On my first login, "echo $XDG_SESSION_TYPE" reported x11. I logged back out, and logged in again checking the gear icon to make sure the Wayland-related one was selected. I don't know if the gear icon was needed, but that time Wayland was active.").

 

Link to comment
Share on other sites

 

On 2/4/2023 at 5:15 PM, MarcAndro said:

Excelent work. Thank you for all that information in one place. Tested. Works. My glmark result=4480.  So nice to see 4k/2k@60fps youtube with no lost frames or almost no lost frames and CPU usage~20%. I had that state few times before on orange pi 5 armbian when tested a lot of solutions.

Now I try to play high resolution hevc files on armbian with above cofiguration presented by @eshelton. After one hour of trials same results on VLC and MPV. First few seconds of video are ok, and then as below. Any ideas? 

3NFXigv.png

 

I´ve got almost similar error, at first, it goes perfect, but at 4th video y saw on Youtube, then all the online streamig videos render as a flat screen. Even a reboot or shutdown/restart doesnt solve the problem.

Link to comment
Share on other sites

I got the same error "could not initialize canvas" while running glmark2-es2-wayland.

 

It also crashes if I switch the login manager to gdm3 (after logout or reboot). Running:

 

/usr/bin/gnome-session --session=gnome --debug

 

and gnome-session showed error info about could not enable the hardware acceleration for Wayland then crashs.image.thumb.png.f8aaa01883167566472f1d1d766bd6c9.png

Link to comment
Share on other sites

u guys might try to switch to nightly kernel if u havent already done so. did a kernel update today and now the es2 benchmark runs w/o errors for a 4300 score. not sure how much power the cpu draws on performance governor - not sure its worth it as i dont see a difference in chromium, like webgl demos, or mpv shaders. still geting green screen on shorts vids tho - panfork is still rough around the edges

Link to comment
Share on other sites

Big thanks @esheltonI too was able to get the same values (maybe a little higher :) ) in GLMark2 after performing a few of your tips (and learning a little more BASH at the same time). Too bad 'panfrost' can't do OpenGL3.3 otherwise this would be an awesome Blender device.  Yea I know, I need to Blender 2.79 but it seems to be a hassle from what I have read some have gone through to get it up and running, which isn't really worth borking a lot of dependencies. If you know of a way (it won't run in software mode, tried) to get Blender 3.01 running that would be great.  Also, have you looked into the poor performing network stack?  It seems three other Linux variants and Android 12 all seem to suffer with performance in this area.  I haven't spent much time, but I think we have the same issue here with it being set to something other than 'Default' or 'Performance' or the buffers being too small.

Edited by Owl Creek Technologies
mispelling
Link to comment
Share on other sites

Kernel pancsf-midstream (6.2) + mesa dev 23.0.0 

 

user@rock-5b:~$ glmark2-wayland 
=======================================================
    glmark2 2021.02
=======================================================
    OpenGL Information
    GL_VENDOR:     Mesa
    GL_RENDERER:   Mali-G610 (Panfrost)
    GL_VERSION:    3.0 Mesa 23.0.0-devel (git-cbe80448cc)
=======================================================
[build] use-vbo=false: FPS: 3016 FrameTime: 0.332 ms
[build] use-vbo=true: FPS: 3332 FrameTime: 0.300 ms
[texture] texture-filter=nearest: FPS: 4108 FrameTime: 0.243 ms
[texture] texture-filter=linear: FPS: 4244 FrameTime: 0.236 ms
[texture] texture-filter=mipmap: FPS: 3846 FrameTime: 0.260 ms
[shading] shading=gouraud: FPS: 2442 FrameTime: 0.410 ms
[shading] shading=blinn-phong-inf: FPS: 2412 FrameTime: 0.415 ms
[shading] shading=phong: FPS: 2168 FrameTime: 0.461 ms
[shading] shading=cel: FPS: 2061 FrameTime: 0.485 ms
[bump] bump-render=high-poly: FPS: 907 FrameTime: 1.103 ms
[bump] bump-render=normals: FPS: 3534 FrameTime: 0.283 ms
[bump] bump-render=height: FPS: 3930 FrameTime: 0.254 ms
[effect2d] kernel=0,1,0;1,-4,1;0,1,0;: FPS: 1688 FrameTime: 0.592 ms
[effect2d] kernel=1,1,1,1,1;1,1,1,1,1;1,1,1,1,1;: FPS: 611 FrameTime: 1.637 ms
[pulsar] light=false:quads=5:texture=false: FPS: 3574 FrameTime: 0.280 ms
[desktop] blur-radius=5:effect=blur:passes=1:separable=true:windows=4: FPS: 544 FrameTime: 1.838 ms
[desktop] effect=shadow:windows=4: FPS: 2041 FrameTime: 0.490 ms
[buffer] columns=200:interleave=false:update-dispersion=0.9:update-fraction=0.5:update-method=map: FPS: 528 FrameTime: 1.894 ms
[buffer] columns=200:interleave=false:update-dispersion=0.9:update-fraction=0.5:update-method=subdata: FPS: 515 FrameTime: 1.942 ms
[buffer] columns=200:interleave=true:update-dispersion=0.9:update-fraction=0.5:update-method=map: FPS: 628 FrameTime: 1.592 ms
[ideas] speed=duration: FPS: 1522 FrameTime: 0.657 ms
[jellyfish] <default>: FPS: 2001 FrameTime: 0.500 ms
[terrain] <default>: FPS: 107 FrameTime: 9.346 ms
[shadow] <default>: FPS: 1412 FrameTime: 0.708 ms
[refract] <default>: FPS: 119 FrameTime: 8.403 ms
[conditionals] fragment-steps=0:vertex-steps=0: FPS: 3830 FrameTime: 0.261 ms
[conditionals] fragment-steps=5:vertex-steps=0: FPS: 2578 FrameTime: 0.388 ms
[conditionals] fragment-steps=0:vertex-steps=5: FPS: 3247 FrameTime: 0.308 ms
[function] fragment-complexity=low:fragment-steps=5: FPS: 3020 FrameTime: 0.331 ms
[function] fragment-complexity=medium:fragment-steps=5: FPS: 2516 FrameTime: 0.397 ms
[loop] fragment-loop=false:fragment-steps=5:vertex-steps=5: FPS: 3061 FrameTime: 0.327 ms
[loop] fragment-steps=5:fragment-uniform=false:vertex-steps=5: FPS: 3276 FrameTime: 0.305 ms
[loop] fragment-steps=5:fragment-uniform=true:vertex-steps=5: FPS: 2567 FrameTime: 0.390 ms
=======================================================
                                  glmark2 Score: 2284 
=======================================================

Link to comment
Share on other sites

Awesome is this Panfrost-Panfrost, ie not Panfork?
Id'e love to try it but do not have experience trying out different kernels.

Ive seen the/a 'midstream' kernel and that it includes the wip/new pancsf.

Could you make some 1-2-3 steps instruction for making an install that has this?
I would really love to try it. 

Edited by fredrum
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines