Author Topic: Raspberry PI 4 Model B and hardware graphics acceleration  (Read 3045 times)

0 Members and 1 Guest are viewing this topic.

Offline radiolistenerTopic starter

  • Super Contributor
  • ***
  • Posts: 3155
  • Country: ua
Raspberry PI 4 Model B and hardware graphics acceleration
« on: July 27, 2023, 12:08:17 am »
Just got Raspberry PI 4 Model B 4 GB. But hdmi cable and hdmi/dvi converter is still in transit. So I'm using VNC connection through WiFi.

I'm using latest Raspberry PI OS x64 2023-05-03-raspios-bullseye-arm64.img

Just stuck with graphics hardware acceleration, I'm trying to run OpenGL app which needs hardware acceleration. But it seems that Open GL works with software renederer, so the app performance is very-very slow (0.1 fps).

I read that Open GL acceleration can be enabled with raspi-config from Advanced Options -> A2 GL driver. But that option is missing from my raspi-config. Some peoples wrote that there is some major changes in Raspberry PI 4, but it's not clear how to enable Open GL acceleration now. Can anybody help?

Here is inxi -Gx output:
Code: [Select]
Graphics:
  Device-1: bcm2711-hdmi0 driver: vc4_hdmi v: N/A bus ID: N/A
  Device-2: bcm2711-hdmi1 driver: vc4_hdmi v: N/A bus ID: N/A
  Device-3: bcm2711-vc5 driver: vc4_drm v: N/A bus ID: N/A
  Display: x11 server: X.Org 1.20.11 driver: loaded: modesetting
  unloaded: fbdev s-res: 1280x1024
  OpenGL: renderer: V3D 4.2 v: 2.1 Mesa 20.3.5 direct render: Yes

In my app glGetString(GL_RENDERER) returns "V3D 4.2".

I'm not sure if it means that it uses hardware renderer or software one, but performance of my app is definitely too slow, also glxgears shows just 1 fps and youtube in firefox is too slow, so I suspect it uses software renderer.

Probably it may be slow because there is no display connected to HDMI outputs. But I'm not sure, because I cannot check it, currently I don't have HDMI cable and display and using it through SSH and VNC connection. Can somebody help to solve it?

This is my first raspberry pi, so I'm not familiar with their details. How to enable hardware acceleration for graphics on Raspberry PI 4?
« Last Edit: July 27, 2023, 12:54:46 am by radiolistener »
 

Offline radiolistenerTopic starter

  • Super Contributor
  • ***
  • Posts: 3155
  • Country: ua
Re: Raspberry PI 4 Model B and hardware graphics acceleration
« Reply #1 on: July 28, 2023, 04:02:04 am »
found that opengl acceleration exists. The problem with low frame rate is probably beacuse I connect through VNC and it works for 1 fps. I can check it when I get hdmi cable with DVI converter.

But found another two strange issues:

1) Chromium works with extreme high lags, but CPU load is almost zero... Any idea how to fix it?

2) cat /proc/cpuinfo shows the following:
Code: [Select]
pi@raspi:~ $ cat /proc/cpuinfo
processor       : 0
BogoMIPS        : 108.00
Features        : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd08
CPU revision    : 3

processor       : 1
BogoMIPS        : 108.00
Features        : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd08
CPU revision    : 3

processor       : 2
BogoMIPS        : 108.00
Features        : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd08
CPU revision    : 3

processor       : 3
BogoMIPS        : 108.00
Features        : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd08
CPU revision    : 3

Hardware        : BCM2835
Revision        : c03115
Serial          : 10000000********
Model           : Raspberry Pi 4 Model B Rev 1.5

Note that it shows BCM2835 CPU, but this is old single core CPU used in raspberry pi 1. Actual chip marking on my board is Broadcom 2711. WTF?
 

Offline Whales

  • Super Contributor
  • ***
  • Posts: 1887
  • Country: au
    • Halestrom
Re: Raspberry PI 4 Model B and hardware graphics acceleration
« Reply #2 on: July 28, 2023, 04:16:43 am »

Hardware accelerated OpenGL will probably only work with full Xorg.  Default vncserver doesn't do that on my (desktop Radeon) computer, but I think there are workarounds like X0vnc which run a full Xorg server + vnc watching it.

Quote
1) Chromium works with extreme high lags, but CPU load is almost zero... Any idea how to fix it?

Could be related to the above, not sure.  Test with a real monitor as a comparison.

Quote
Note that it shows BCM2835 CPU, but this is old single core CPU used in raspberry pi 1. Actual chip marking on my board is Broadcom 2711. WTF?

It's wrong.  It looks like it's a hardcoded string in your kernel, not actually from the CPU.

https://github.com/raspberrypi/linux/issues/3022

 
The following users thanked this post: radiolistener

Offline thermistor-guy

  • Frequent Contributor
  • **
  • Posts: 354
  • Country: au
Re: Raspberry PI 4 Model B and hardware graphics acceleration
« Reply #3 on: July 28, 2023, 05:18:47 am »
Just got Raspberry PI 4 Model B 4 GB. But hdmi cable and hdmi/dvi converter is still in transit. So I'm using VNC connection through WiFi.

I'm using latest Raspberry PI OS x64 2023-05-03-raspios-bullseye-arm64.img
...

I tried PiOS and Ubuntu on an rpi4 with 8GB, without much success. So now I'm running Debian server (Bookworm) 64-bit,
XFCE desktop, and tightvnc server on it. Works for me. The rpi4 is running headless, wifi off, gigabit ethernet on.

Just now I connected to it from a Win7+Cygwin PC, using Tigervnc viewer over an ssh tunnel. Started firefox on the rpi,
used it to watch a Tom and Jerry cartoon on YT, 720p quality, for research purposes of course. Works well enough.

So if you can't get PiOS to work, give Debian + XFCE a try.
 

Offline radiolistenerTopic starter

  • Super Contributor
  • ***
  • Posts: 3155
  • Country: ua
Re: Raspberry PI 4 Model B and hardware graphics acceleration
« Reply #4 on: July 28, 2023, 08:22:02 am »
Hardware accelerated OpenGL will probably only work with full Xorg.  Default vncserver doesn't do that on my (desktop Radeon) computer, but I think there are workarounds like X0vnc which run a full Xorg server + vnc watching it.

it works :)
It seems that the problem is that I don't have display, so it don't know refresh rate and limit it for 1 fps for some unknown reason.
I tried to disable vblank sync mode for process with vblank_mode=0 in command line and it works. See screenshot. :)

Well, speed is much slower than I was expected, but almost usable. And it even provides 4x hardware multisample filtering.

Any idea on how to improve Open GL hardware acceleration performance on raspberry pi 4? I want a little faster graphics... :)



Quote
1) Chromium works with extreme high lags, but CPU load is almost zero... Any idea how to fix it?

Could be related to the above, not sure.  Test with a real monitor as a comparison.

Yes, it seems that this problem is due to frame rate is 1 Hz for VNC. I tried to run it with manual vblank sync mode override and lags almost disappears, now chromium is usable and I'm writing this post from my raspberry pi 4 in chromium :)

I run it in the following way:
Code: [Select]
vblank_mode=0 chromium-browser
But before this I was installed the following packages:
Code: [Select]
sudo apt-get install libgles2-mesa libgles2-mesa-dev xorg-dev mesa-utils freeglut3-dev
and also enabled flag "Out-of-process 2D canvas rasterization." on chrome://flags page. It really helps to enable hw acceleration for out-of-process rasterization (can be checked on chrome://gpu page). So these tweaks may have effect.

Some people wrote that replace this string in /boot/config.txt:
Code: [Select]
dtoverlay=vc4-kms-v3d-pi4,cma-256
with this one
Code: [Select]
dtoverlay=vc4-fkms-v3d-pi4,cma-256

And it helps on some older version of raspi os. This change leads to switch from Full KMS video driver to a so called Fake KMS video driver. But I didn't tried it because it already works with Full KMS driver which is more fresh and supports more features.

Quote
Note that it shows BCM2835 CPU, but this is old single core CPU used in raspberry pi 1. Actual chip marking on my board is Broadcom 2711. WTF?

It's wrong.  It looks like it's a hardcoded string in your kernel, not actually from the CPU.

Probably you're right. But it also displays info about cores and part of that info is correct.

I run a little code to read info directly from CPU registers and it shows the following on my rpi 4:
Code: [Select]
MIDR_EL1: 0x410fd083
    [Reserved]:   0x0
    Implementer:  0x41
    Variant:      0x0
    Architecture: 0xf
    PartNum:      0xd08
    Revision:     0x3
VPIDR_EL2: SIGILL
REVIDR_EL1: 0
ID_AA64ISAR0_EL1: 0x10000
ID_AA64ISAR1_EL1: 0
MVFR0_EL1: 0x200
MVFR1_EL1: 0x10011100
MVFR2_EL1: 0
[/quote]

So, my rpi 4B CPU has MIDR_EL1=0x410fd083. I read that other people also seen such code for rpi 4.
But first rpi 4 models had MIDR_EL1 with different last two digits and cpuinfo.

Any other idea on how to identify actual CPU are welcome.

PS: posted this message from my rpi 4 :)
 

Offline radiolistenerTopic starter

  • Super Contributor
  • ***
  • Posts: 3155
  • Country: ua
Re: Raspberry PI 4 Model B and hardware graphics acceleration
« Reply #5 on: July 28, 2023, 09:05:09 am »
I can say rpi 4 is very hot when running firefox. I added a small heatsink on CPU from a high power motor controller, but it still heating above 70 °C under load.

I found that you can monitor it's cpu temperature and throttlling state with the following commands:
Code: [Select]
vcgencmd measure_temp
vcgencmd get_throttled

get_throttled also shows low voltage state. I don't know what is the bit meaning, just found this info about bit flags:
Code: [Select]
0: under-voltage
 1: arm frequency capped
2: currently throttled
16: under-voltage has occurred
17: arm frequency capped has occurred
18: throttling has occurred

my rpi 4 shows
Code: [Select]
throttled=0x80000
which probably means "arm frequency capped has occurred". It happens above 81 °C, probably it triggers at 82 °C and above, because at 80 and 81 °C it was still keep 0x0. Interesingly that PiOS shows red area on temperature chart (see attachment) when it reach 81 °C.

It needs to put rpi 4 into paper box to prevent ventialtion and run heavy load app in order to get trottled, but it definitely needs active heatsink to sit on youtube in firefox.

Regarding to a power consumption, I was pleasantly surprised that RPI 4 eats max 6 W from mains under heavy load and usual power consumption is just 2-5 W (I'm using original raspberry pi 15W power supply which provides 5 V @ 3 A according to specification).

I tried to measure current consumption, but it seems that it is very sensitive to voltage drop on cheap USB cable or USB-C adapter. It consume about 300-400 mA most of the time, sometime it can rise to 600-700 mA for a second. Unfortunately I don't have good high power USB-USB-C cable to measure full max power consumption, because it shows low voltage event even when I use high power cable with 5 A power supply and no voltage drop on the input of cable, this voltage drop definitely happens on a cheap USB-micro to USB-C adapter. Because I'm using good 3 A cable.

Probably 3 A PSU requirement is due to high sensitivity to voltage drop, but not because it really eats 3 Amps :)

Does anybody knows which voltage drop leads to low voltage warning on rpi 4 with a new power management chip?

Tried Raspberry Pi OS arm64 and armhf on my rpi 4 and found that arm64 is more stable and gives almost 30% less CPU load for firefox on youtube.
« Last Edit: July 28, 2023, 09:30:54 am by radiolistener »
 

Offline radiolistenerTopic starter

  • Super Contributor
  • ***
  • Posts: 3155
  • Country: ua
Re: Raspberry PI 4 Model B and hardware graphics acceleration
« Reply #6 on: July 28, 2023, 09:14:32 am »
Does anybody know how to setup some usable display refresh rate for VNC connection in Raspberry Pi OS instead of 1 Hz?

Currently it requires to run apps with vblank_mode=0 override, otherwise it is almost non usable. This is not comfortable.
« Last Edit: July 28, 2023, 09:16:24 am by radiolistener »
 

Offline Lindley

  • Regular Contributor
  • *
  • Posts: 195
  • Country: gb
Re: Raspberry PI 4 Model B and hardware graphics acceleration
« Reply #7 on: July 28, 2023, 07:53:53 pm »
Web pages like this show the typical cpu temperatures before and after fitting a small fan /heatsink/case  , almost any small fan will make a dramatic difference and improve its life.

https://www.jeffgeerling.com/blog/2019/best-way-keep-your-cool-running-raspberry-pi-4
 
The following users thanked this post: radiolistener

Offline radiolistenerTopic starter

  • Super Contributor
  • ***
  • Posts: 3155
  • Country: ua
Re: Raspberry PI 4 Model B and hardware graphics acceleration
« Reply #8 on: July 28, 2023, 10:55:41 pm »
Just notice that RPI 4 connects to my old WiFi router with 802.11n (2.4GHz) at 65 MBps rate. For comparison, my 10 years tablet nexus 10 connects to the same router at 130 MBps. So, I'm not sure is there some software limitation? Can I improve WiFi speed of my RPI 4?

RPI 4 shows about 20 Mbit download speed and about 40 Mbit upload speed on speedtest.net. This is also strange why down speed is smaller than up speed? The router has 100 Mbit internet connection, so there is some limitation on RPI 4 side.

Web pages like this show the typical cpu temperatures before and after fitting a small fan /heatsink/case  , almost any small fan will make a dramatic difference and improve its life.

https://www.jeffgeerling.com/blog/2019/best-way-keep-your-cool-running-raspberry-pi-4

S2Pi ICE Tower looks cool :) Just wonder what max temperature it keeps without fan on RPI 4?
« Last Edit: July 28, 2023, 10:58:53 pm by radiolistener »
 

Offline radiolistenerTopic starter

  • Super Contributor
  • ***
  • Posts: 3155
  • Country: ua
Re: Raspberry PI 4 Model B and hardware graphics acceleration
« Reply #9 on: July 30, 2023, 01:55:35 am »
just installed mono and tried my OpenGL projects, it's incredible, it can run pretty heavy opengl game client for online game which uses a lot of shape drawing and it is almost playable (it have some lags, but I'm not sure if it happens due to VNC connection, needs to test it with real display).  :)

Here is the test of multisample antialiasing filtering, the max multisample level is x4, it is not the best, but still better than missing at all :)
 

Offline Lindley

  • Regular Contributor
  • *
  • Posts: 195
  • Country: gb
Re: Raspberry PI 4 Model B and hardware graphics acceleration
« Reply #10 on: July 30, 2023, 09:39:13 am »

Have you seen these free online magazines all about using and getting the most from the RPI  ..

https://magpi.raspberrypi.org/articles/how-to-overclock-raspberry-pi-4
 

Offline radiolistenerTopic starter

  • Super Contributor
  • ***
  • Posts: 3155
  • Country: ua
Re: Raspberry PI 4 Model B and hardware graphics acceleration
« Reply #11 on: July 31, 2023, 09:03:23 am »
I know about overclocking, but I don't want to do it, because it requires overvoltage and as result it may lead to chip damage or quick degradation. And of course it will increase heating, but it is already too hot.

Regarding to heating, I tried to add 12 mm silent fan from PC case, it easily cool down CPU below 40 °C even under heavy load. But its preferred for me to keep it fan less and noise free... :)

As I read, the BCM2711 CPU doesn't have hardware cryptographic acceleration, it seems that they forgot to add license for hardware AES instruction when designed chip. So all cryptography eats a lot of CPU and add heating, and since these days TLS cryptography is everywhere (any HTTPS connection requires it, SSH and VNC, disk encryption and many other things), it leads to additional significant CPU load and heating.

It looks that they tried to improve situation by enable NEON acceleartion support in openssl, but it just improve performance for a little, it can't replace hardware cryptography acceleration instructions which give 10-20x speed improvement.

Since VNC uses AES encryption, it seems that it may affect CPU load. So, I'm waiting for hdmi cable and adapter to test it on real display...
« Last Edit: July 31, 2023, 09:16:30 am by radiolistener »
 

Offline radiolistenerTopic starter

  • Super Contributor
  • ***
  • Posts: 3155
  • Country: ua
Re: Raspberry PI 4 Model B and hardware graphics acceleration
« Reply #12 on: August 04, 2023, 04:55:02 am »
Just got hdmi adapter and connected my RPI4 to display :) It works much more smoothly than through VNC. But I found another issue related with vblank sync. All video playback and OpenGL app shows image tearing due to delayed frame swap from vblank event. It looks terrible. But I found it can be fixed with disable Compositor (xcompmgr) from raspi-config (on Advanced menu). With disabled xcompmgr image tearing disappears and vblank sync works as expected.

glxgears test shows about 990-1000 fps with enabled xcompmgr and about 1450 fps with disabled xcompmgr, so disable xcompmgr also improves OpenGL performance:
Code: [Select]
$ vblank_mode=0 glxgears
ATTENTION: default value of option vblank_mode overridden by environment.
7029 frames in 5.0 seconds = 1405.637 FPS
7296 frames in 5.0 seconds = 1459.048 FPS
7317 frames in 5.0 seconds = 1463.390 FPS
7357 frames in 5.0 seconds = 1471.392 FPS
7302 frames in 5.0 seconds = 1460.214 FPS
7287 frames in 5.0 seconds = 1457.341 FPS
7261 frames in 5.0 seconds = 1452.113 FPS

Any further ideas to improve OpenGL performance are welcome. I want to see for at least 2000-3000 fps in glxgears
« Last Edit: August 04, 2023, 05:00:21 am by radiolistener »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf