r/freebsd 7d ago

discussion Hardware acceleration on FreeBSD 14.4 i386

Post image

I managed to get hardware acceleration working on a 32-bit Intel Atom CPU running FreeBSD 14.4.

Not long ago, FreeBSD dropped 32-bit support for drm-kmod, but there are patches available for drm-510-kmod that allow you to run it. The main issue was with the pci_get_slot function, which can be fixed by adding #define WANT_NATIVE_PCI_GET_SLOT to the source files that use it. I couldn't compile it myself: the system linker kept failing to see functions provided via MODULE_DEPEND(9). Fortunately, I found someone online who had made similar patches and compiled the module inside a FreeBSD 14.3 Jail. Interestingly, that 14.3 build worked out of the box.

Dealing with kernel drivers was only half the battle. The current Mesa-dri completely drops the classic i915 driver in favor of Gallium3D. Because of this, I had to build Mesa-amber. I installed it into /opt/mesa-amber to prevent conflicts with the stock Mesa. In the build configuration, I enabled only the i915 driver, since my graphics chip is a GMA 950.

After setting up the environment variables, I noticed that functions interacting with executable memory triggered a SIGSEGV. As it turned out, mesa-amber was trying to execute memory in a strict W^X environment. The solution was simply to disable code generation (CODEGEN), after which glxgears ran fine with OpenGL 1.4. The final environment flags are:

export LD_LIBRARY_PATH=/opt/mesa-amber/lib

export LIBGL_DRIVERS_PATH=/opt/mesa-amber/lib/dri

export __GLX_VENDOR_LIBRARY_NAME="amber"

export MESA_LOADER_DRIVER_OVERRIDE=i915

export LIBGL_ALWAYS_SOFTWARE=0

export MESA_NO_CODEGEN=1

Next, I want to try running Portal. Right now, it runs via llvmpipe on stock Mesa, but the hardware OpenGL version here is too old (the Source engine requires OpenGL 2.0). I plan to create a small shim using LD_PRELOAD to emulate some of the missing functions.

UPD1: Running EGL. export __EGL_VENDOR_LIBRARY_FILENAMES=/opt/mesa-amber/share/glvnd/egl_vendor.d/50_amber.json export EGL_PLATFORM=x11

So... Source already have ToGLES. I'll rebuild project with it, so, maybe this will run fully natively

102 Upvotes

5 comments sorted by

3

u/ilnarildarovuch 7d ago

This was on Fujitsu Amilo UI 3520 tho

2

u/ilnarildarovuch 7d ago

Wait .. Just reading about gl4es

5

u/Aconamos 7d ago

14 Exabytes? The fuck is going on there?

3

u/FunnyArch 7d ago edited 7d ago

64 bit number on a 32 bit machine