tech-x11 archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

libdrm+kernel patches/fixes from wayland porting work



I am back on my project of trying to get my wlroots style Wayland
compositor running on NetBSD.

A little background, my compositor uses an OpenGLESv2 renderer
to draw everything to the screen.  It takes DMA-BUF handles from
client programs and uses those for rendering, to avoid a lot of
data copying and trips into and out of the graphics hardware.
The short answer is, the contraption is a DRM master, and all the
wayland programs need to be hardware accelerated.  Which means the
full accelerated pipeline needs to be working.

My experience with NetBSD is that X11 ends up running anything with
OpenGL via the LLVMpipe software renderer, and I think I figured
out why.

The libdrm routines that Mesa uses to initialize itself for both the
compositor and the client apps leans heavily on the GET_UNIQUE ioctl.
However, only the master node has a unique string, and the render
nodes do not.  For both the compositor and the client, Mesa calls
GET_UNIQUE on the render node's device fd, gets back an error and
then gives up on setting up full acceleration.

OpenBSD and DragonflyBSD solve this by hardcoding the bus type as
PCI and using a second ioctl to get the PCI device information.

I went and implemented an analogous ioctl for NetBSD and modified
libdrm to use it.  This allowed me to get my compositor up and
running against 10.1.

I did my work using libdrm+Mesa from pkgsrc-2024q4 rather than
xsrc, but I ported my patch back to the libdrm in the xsrc tree.
It looks like there are calls to drmSetInterfaceVersion hiding in
xorg-server and some of the video drivers, so this might turn on all
sorts of code paths that haven't really been used, and thus break
stuff, but also, it's necessary for full graphics acceleration,
so it could make everyone's workstations even more awesome!  :-)

I've included three patches, one for the kernel code and two for
libdrm.  The one for pkgsrc is meant to replace the diff portion
of the patch for xf86drm.c in x11/libdrm.  xsrc-10.1-xf86drm_c.patch
should be a direct patch for the version of xf86drm.c in the NetBSD
sources.  Let me know if you need to rebase them onto current, or
if there are any other questions/concerns.

Thanks!
Jeff

Attachment: syssrc-10.1-pciinfo_ioctl.patch
Description: Binary data

Attachment: xsrc-10.1-xf86drm_c.patch
Description: Binary data

Attachment: pkgsrc2024q4-xf86drm_c.patch
Description: Binary data



Home | Main Index | Thread Index | Old Index