Torizon - Enable gpu on .net 8 IMX6

Hi, how can I enable hardware acceleration on .NET 8, weston for IMX6?

Hi, I’m the Toradex AI Assistant.

I might make mistakes or occasionally get you wrong. Our support team will step in if needed.


Hardware Acceleration on i.MX6 with Weston and .NET 8

For i.MX6 platforms, you can run Weston with hardware acceleration using the following configuration (1):

Running Weston on i.MX6

# docker container run -d --name=weston --net=host \
    --cap-add CAP_SYS_TTY_CONFIG -v /dev:/dev -v /tmp:/tmp \
    -v /run/udev/:/run/udev/ \
    --device-cgroup-rule="c 4:* rmw" --device-cgroup-rule="c 253:* rmw" \
    --device-cgroup-rule="c 13:* rmw" --device-cgroup-rule="c 226:* rmw" \
    --device-cgroup-rule="c 10:223 rmw" --device-cgroup-rule="c 199:0 rmw" \
    torizon/weston:4 \
    --developer

(1)

.NET 8 Support

.NET 8 containers for Torizon are available and you can develop .NET 8 applications using the Visual Studio Code IDE Extension for Torizon (2). The extension provides .NET 8 templates for various use cases including C# console, ASP.NET Blazor, Avalonia, Uno Platform, and Slint (2).

Using Docker Compose

For a more structured approach, you can use Docker Compose with the following configuration for i.MX6 (1):

services:
  weston:
    image: torizon/weston:4
    # Required to get udev events from host udevd via netlink
    network_mode: host
    volumes:
      - type: bind
        source: /tmp
        target: /tmp
      - type: bind
        source: /dev
        target: /dev
      - type: bind
        source: /run/udev
        target: /run/udev
    cap_add:
      - CAP_SYS_TTY_CONFIG
    # Add device access rights through cgroup...
    device_cgroup_rules:
      # ... for tty0
      - 'c 4:0 rmw'
      # ... for tty7
      - 'c 4:7 rmw'
      # ... for /dev/input devices
      - 'c 13:* rmw'
      # ... for /dev/dri devices

(1)

Key Points

  • The Weston container creates a Unix socket file that allows other containers to use the Weston instance for running graphical applications (1)
  • By bind mounting /tmp into your .NET container, your .NET application can communicate with Weston through the Unix socket file (1)
  • You can explore demo applications including Qt demos that demonstrate hardware-accelerated graphics on various Toradex modules (3)

Best regards, Toradex AI Assistant.


Did you like my answer? :+1: :-1:

If I answered your question, please tick the “Solution” checkbox.

For follow-up questions to me, please use @ToradexAI in your post.

Hello @rlopesgoes !

The bot answer seems correct. Were you able to solve it based on its explanation? Let us know if we can help you in an way.

The question is, the vivante gpu is active? because I didnt see the driver and the performance is very bad with avalonia

@rlopesgoes

Yes, the vivante GPU should be active on Torizon and weston itself is running with HW acceleration. The issue is that Avalonia on Wayland/Weston does not use the GPU on this platform, so it falls back to software rendering, which should explain why you are have bad performance.

If you need hardware-accelerated rendering with Avalonia on i.MX6, the only supported path today is using Avalonia DRM/KMS backend instead of running it under Weston.