mesa: switch to dri glx backend instead of xlib

This commit is contained in:
Matheus
2026-03-08 12:00:56 -03:00
parent 77406cb509
commit 77ebe50d72
10 changed files with 330 additions and 5 deletions
+37
View File
@@ -0,0 +1,37 @@
diff --git libdrm-clean/include/drm/drm.h libdrm-workdir/include/drm/drm.h
index 4e4f7c2..f0d0f63 100644
--- libdrm-clean/include/drm/drm.h
+++ libdrm-workdir/include/drm/drm.h
@@ -43,8 +43,17 @@ typedef unsigned int drm_handle_t;
#else /* One of the BSDs */
-#include <stdint.h>
-#include <sys/ioccom.h>
+ #include <stdint.h>
+//#include <sys/ioccom.h>
+#ifdef __astral__
+#define _IOC(dir,type,nr,size) (((dir)<<30)|((size)<<16)|((type)<<8)|(nr))
+#define _IO(type,nr) _IOC(0,(type),(nr),0)
+#define _IOR(type,nr,size) _IOC(2,(type),(nr),sizeof(size))
+#define _IOW(type,nr,size) _IOC(1,(type),(nr),sizeof(size))
+#define _IOWR(type,nr,size) _IOC(3,(type),(nr),sizeof(size))
+#define _IOC_SIZE(nr) (((nr)>>16)&0x3fff)
+#define _IOC_DIR(nr) ((nr)>>30)
+#endif
#include <sys/types.h>
typedef int8_t __s8;
typedef uint8_t __u8;
diff --git libdrm-clean/xf86drm.h libdrm-workdir/xf86drm.h
index 6d91dfb..293580f 100644
--- libdrm-clean/xf86drm.h
+++ libdrm-workdir/xf86drm.h
@@ -58,7 +58,7 @@ extern "C" {
#else /* One of the *BSDs */
-#include <sys/ioccom.h>
+//#include <sys/ioccom.h>
#define DRM_IOCTL_NR(n) ((n) & 0xff)
#define DRM_IOC_VOID IOC_VOID
#define DRM_IOC_READ IOC_OUT
@@ -0,0 +1,33 @@
diff --git libxshmfence-clean/src/xshmfence_futex.h libxshmfence-workdir/src/xshmfence_futex.h
index 673ac0e..a79f535 100644
--- libxshmfence-clean/src/xshmfence_futex.h
+++ libxshmfence-workdir/src/xshmfence_futex.h
@@ -51,11 +51,27 @@ static inline int futex_wait(int32_t *addr, int32_t value) {
#include <values.h>
#include <linux/futex.h>
#include <sys/time.h>
+
+#ifndef __astral__
#include <sys/syscall.h>
+#endif
static inline long sys_futex(void *addr1, int op, int val1, struct timespec *timeout, void *addr2, int val3)
{
- return syscall(SYS_futex, addr1, op, val1, timeout, addr2, val3);
+#ifdef __astral__
+ long ret;
+ long err;
+ register uint64_t r_timeout asm("r10") = (uint64_t)timeout;
+ asm volatile("syscall"
+ : "=a"(ret), "=d"(err)
+ : "a"(51UL), "D"(addr1), "S"((long)op), "d"((long)val1), "r"(r_timeout)
+ : "memory", "rcx", "r11");
+ if (err)
+ return -err;
+ return ret;
+#else
+ return syscall(SYS_futex, addr1, op, val1, timeout, addr2, val3);
+#endif
}
static inline int futex_wake(int32_t *addr) {
+133 -1
View File
@@ -12,9 +12,18 @@ index 4e4f7c2..2e4d3e2 100644
typedef int8_t __s8;
typedef uint8_t __u8;
diff --git mesa-clean/meson.build mesa-workdir/meson.build
index 9fb4160..1a1a827 100644
index 9fb4160..f774dad 100644
--- mesa-clean/meson.build
+++ mesa-workdir/meson.build
@@ -118,7 +118,7 @@ with_any_opengl = with_opengl or with_gles1 or with_gles2
# Only build shared_glapi if at least one OpenGL API is enabled
with_shared_glapi = with_shared_glapi and with_any_opengl
-system_has_kms_drm = ['openbsd', 'netbsd', 'freebsd', 'gnu/kfreebsd', 'dragonfly', 'linux', 'sunos', 'android', 'managarm'].contains(host_machine.system())
+system_has_kms_drm = ['openbsd', 'netbsd', 'freebsd', 'gnu/kfreebsd', 'dragonfly', 'linux', 'sunos', 'android', 'managarm', 'astral'].contains(host_machine.system())
gallium_drivers = get_option('gallium-drivers')
if gallium_drivers.contains('auto')
@@ -1040,7 +1040,7 @@ if cc.has_function('fmemopen')
endif
@@ -61,6 +70,129 @@ index 2aab5bf..e8f9d69 100644
#ifdef HAVE_LINUX_UDMABUF_H
#include <fcntl.h>
#include <sys/mman.h>
diff --git mesa-clean/src/gallium/targets/dril/dril_target.c mesa-workdir/src/gallium/targets/dril/dril_target.c
index 593a07e..a8893b0 100644
--- mesa-clean/src/gallium/targets/dril/dril_target.c
+++ mesa-workdir/src/gallium/targets/dril/dril_target.c
@@ -332,8 +332,10 @@ init_dri2_configs(int fd)
/* dlopen/dlsym to avoid linkage */
egl = dlopen("libEGL.so.1", RTLD_LAZY | RTLD_LOCAL);
- if (!egl)
+ if (!egl) {
+ fprintf(stderr, "bad egl\n");
return false;
+ }
void * (*peglGetProcAddress)(const char *) = dlsym(egl, "eglGetProcAddress");
EGLDisplay (*peglGetPlatformDisplayEXT)(EGLenum, void *, const EGLint *) = peglGetProcAddress("eglGetPlatformDisplayEXT");
@@ -342,34 +344,47 @@ init_dri2_configs(int fd)
EGLBoolean (*peglGetConfigs)(EGLDisplay, EGLConfig*, EGLint, EGLint*) = peglGetProcAddress("eglGetConfigs");
EGLBoolean (*peglGetConfigAttrib)(EGLDisplay, EGLConfig, EGLint, EGLint *) = peglGetProcAddress("eglGetConfigAttrib");
const char *(*peglQueryString)(EGLDisplay, EGLint) = peglGetProcAddress("eglQueryString");
+ // Add after dlopen succeeds:
+ fprintf(stderr, "dril: EGL client extensions: %s\n", peglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS));
+ fflush(stderr);
struct gbm_device *gbm = NULL;
if (fd != -1) {
/* try opening GBM for hardware driver info */
gbm = gbm_create_device(fd);
- if (!gbm)
+ if (!gbm) {
+ fprintf(stderr, "bad gbm\n");
goto out;
+ }
}
- EGLDisplay dpy = peglGetPlatformDisplayEXT(EGL_PLATFORM_GBM_MESA, gbm ? gbm : EGL_DEFAULT_DISPLAY, NULL);
- if (!dpy)
+ EGLDisplay dpy = peglGetPlatformDisplayEXT(EGL_PLATFORM_SURFACELESS_MESA, gbm ? gbm : EGL_DEFAULT_DISPLAY, NULL);
+ if (!dpy) {
+ fprintf(stderr, "bad dpy\n");
goto out_gbm;
+ }
int maj, min;
- if (!peglInitialize(dpy, &maj, &min))
+ if (!peglInitialize(dpy, &maj, &min)) {
+ fprintf(stderr, "bad pegl\n");
goto out_gbm;
+ }
const char *egl_extension_list = peglQueryString(dpy, EGL_EXTENSIONS);
bool has_srgb = strstr(egl_extension_list, "EGL_KHR_gl_colorspace");
int num_configs = 0;
EGLConfig *eglconfigs = NULL;
- if (!peglGetConfigs(dpy, NULL, 0, &num_configs))
+ if (!peglGetConfigs(dpy, NULL, 0, &num_configs)) {
+ fprintf(stderr, "bad pegconfigs\n");
goto out_egl;
+ }
eglconfigs = malloc(sizeof(EGLConfig) * num_configs);
/* overestimate: num_configs * doubleBuffer * sRGB + NULL */
configs = calloc(num_configs * 2 * 2 + 1, sizeof(struct gl_config));
- if (!peglGetConfigs(dpy, eglconfigs, num_configs, &num_configs))
+ if (!peglGetConfigs(dpy, eglconfigs, num_configs, &num_configs)) {
+ fprintf(stderr, "more bad pegconfigs\n");
goto out_egl;
+ }
for (unsigned i = 0; i < num_configs; i++) {
/* verify that this is the right format */
@@ -381,6 +396,9 @@ init_dri2_configs(int fd)
!peglGetConfigAttrib(dpy, eglconfigs[i], EGL_SAMPLES, &samples))
continue;
+ fprintf(stderr, "dril: config %u format=0x%x depth=%d stencil=%d samples=%d\n", i, format, depth, stencil, samples);
+ fflush(stderr);
+
enum pipe_format pformat = fourcc_to_pipe_format(format);
/* srgb configs go after base configs */
@@ -412,6 +430,20 @@ init_dri2_configs(int fd)
/* check last format for srgbness too */
if (c && has_srgb)
c = add_srgb_config(configs, c, last_pformat, last_start);
+
+ fprintf(stderr, "c: %u\n", c);
+ /* surfaceless EGL returns no native visual IDs, populate directly */
+if (c == 0) {
+ configs = calloc(ARRAY_SIZE(drilConfigs) * 2 + 1, sizeof(struct gl_config));
+ for (unsigned i = 0; i < ARRAY_SIZE(drilConfigs); i++) {
+ /* single-buffered */
+ configs[c] = mem_dup(&drilConfigs[i], sizeof(drilConfigs[i]));
+ configs[c++]->doubleBufferMode = 0;
+ /* double-buffered */
+ configs[c] = mem_dup(&drilConfigs[i], sizeof(drilConfigs[i]));
+ configs[c++]->doubleBufferMode = 1;
+ }
+}
out_egl:
free(eglconfigs);
/* don't forget cleanup */
diff --git mesa-clean/src/glx/glxcmds.c mesa-workdir/src/glx/glxcmds.c
index 561d4c8..ffda2d0 100644
--- mesa-clean/src/glx/glxcmds.c
+++ mesa-workdir/src/glx/glxcmds.c
@@ -1832,6 +1832,9 @@ _X_HIDDEN GLboolean
__glxGetMscRate(struct glx_screen *psc,
int32_t * numerator, int32_t * denominator)
{
+#ifdef __astral__
+ return False;
+#else
#if !defined(GLX_USE_WINDOWSGL)
XF86VidModeModeLine mode_line;
int dot_clock;
@@ -1882,6 +1885,7 @@ __glxGetMscRate(struct glx_screen *psc,
#endif
return False;
+#endif
}
#endif
diff --git mesa-clean/src/util/detect_os.h mesa-workdir/src/util/detect_os.h
index 86286df..f3a5106 100644
--- mesa-clean/src/util/detect_os.h
@@ -10,6 +10,19 @@ index 071bd1a..68b2e26 100644
"/run/shm",
"/var/tmp",
"/tmp",
diff --git xorg-server-clean/configure.ac xorg-server-workdir/configure.ac
index 7ef8581..38c16fd 100644
--- xorg-server-clean/configure.ac
+++ xorg-server-workdir/configure.ac
@@ -1435,7 +1435,7 @@ AM_CONDITIONAL([XF86VIDMODE], [test "x$XF86VIDMODE" = xyes])
AC_DEFINE_DIR(COMPILEDDEFAULTFONTPATH, FONTPATH, [Default font path])
AC_DEFINE_DIR(SERVER_MISC_CONFIG_PATH, SERVERCONFIG, [Server miscellaneous config path])
AC_DEFINE_DIR(BASE_FONT_PATH, FONTROOTDIR, [Default base font path])
-dridriverdir=`$PKG_CONFIG --variable=dridriverdir dri`
+dridriverdir=`PKG_CONFIG_SYSROOT_DIR="" $PKG_CONFIG --variable=dridriverdir dri`
AC_DEFINE_DIR(DRI_DRIVER_PATH, dridriverdir, [Default DRI driver path])
AC_DEFINE_UNQUOTED(XVENDORNAME, ["$VENDOR_NAME"], [Vendor name])
AC_DEFINE_UNQUOTED(XVENDORNAMESHORT, ["$VENDOR_NAME_SHORT"], [Short vendor name])
diff --git xorg-server-clean/hw/xfree86/common/xf86Bus.c xorg-server-workdir/hw/xfree86/common/xf86Bus.c
index fd144db..b232e27 100644
--- xorg-server-clean/hw/xfree86/common/xf86Bus.c
@@ -94,6 +107,19 @@ index 5695e71..c9230aa 100644
#include <stdlib.h>
#include <errno.h>
diff --git xorg-server-clean/hw/xfree86/drivers/Makefile.am xorg-server-workdir/hw/xfree86/drivers/Makefile.am
index 954c9f1..b916149 100644
--- xorg-server-clean/hw/xfree86/drivers/Makefile.am
+++ xorg-server-workdir/hw/xfree86/drivers/Makefile.am
@@ -1,8 +1,5 @@
SUBDIRS =
-if XORG_DRIVER_MODESETTING
-SUBDIRS += modesetting
-endif
if XORG_DRIVER_INPUT_INPUTTEST
SUBDIRS += inputtest
endif
diff --git xorg-server-clean/hw/xfree86/fbdevhw/fbdevhw.c xorg-server-workdir/hw/xfree86/fbdevhw/fbdevhw.c
index 3d8b92e..31a0430 100644
--- xorg-server-clean/hw/xfree86/fbdevhw/fbdevhw.c
@@ -204,6 +230,21 @@ index 4984ccf..bb3e2f8 100644
char *device);
extern _X_EXPORT char *fbdevHWGetName(ScrnInfoPtr pScrn);
diff --git xorg-server-clean/hw/xfree86/os-support/bus/xf86Pci.h xorg-server-workdir/hw/xfree86/os-support/bus/xf86Pci.h
index 4dbe08b..ff713aa 100644
--- xorg-server-clean/hw/xfree86/os-support/bus/xf86Pci.h
+++ xorg-server-workdir/hw/xfree86/os-support/bus/xf86Pci.h
@@ -105,7 +105,10 @@
#include <X11/Xarch.h>
#include <X11/Xfuncproto.h>
#include "misc.h"
+
+#ifndef __astral__
#include <pciaccess.h>
+#endif
/*
* PCI cfg space definitions (e.g. stuff right out of the PCI spec)
diff --git xorg-server-clean/hw/xfree86/os-support/shared/posix_tty.c xorg-server-workdir/hw/xfree86/os-support/shared/posix_tty.c
index 0cb9788..d6df170 100644
--- xorg-server-clean/hw/xfree86/os-support/shared/posix_tty.c
+31
View File
@@ -0,0 +1,31 @@
name=libdrm
revision=1
from_source=libdrm
imagedeps="ninja-build build-essential"
hostdeps="xgcc xbinutils pkgconfig libtool"
deps="base"
configure() {
meson --cross-file ${base_dir}/util/crossfile --prefix=${prefix} --buildtype=release \
-Dintel=disabled \
-Dradeon=disabled \
-Damdgpu=disabled \
-Dnouveau=disabled \
-Dvmwgfx=disabled \
-Domap=disabled \
-Dexynos=disabled \
-Dfreedreno=disabled \
-Dvc4=disabled \
-Detnaviv=disabled \
-Dtegra=disabled \
-Dtests=false \
${source_dir}
}
build() {
ninja -j${parallelism}
}
package() {
DESTDIR=${dest_dir} ninja install
}
+18
View File
@@ -0,0 +1,18 @@
name=libxshmfence
revision=1
from_source=libxshmfence
imagedeps="build-essential"
hostdeps="xgcc xbinutils pkgconfig util-macros libtool pkgconfig"
deps="base xorgproto"
configure() {
${source_dir}/configure --prefix=${prefix} --host=x86_64-astral --enable-shared --disable-static
}
build() {
make -j${parallelism}
}
package() {
make DESTDIR=${dest_dir} install
}
+16 -2
View File
@@ -3,14 +3,28 @@ revision=1
from_source=mesa
imagedeps="gcc meson ninja-build python3-mako python3-setuptools python3-yaml"
hostdeps="xgcc xbinutils pkgconfig automake autoconf util-macros libtool libstdc++-v3"
deps="base llvm libexpat libxcb libx11 libxext zlib"
deps="base llvm libexpat libxcb libx11 libxext zlib libxfixes libxxf86vm libdrm libxshmfence libxrandr"
configure() {
cp -rp ${source_dir}/* .
mkdir -p build
cd build
meson --cross-file ${base_dir}/util/crossfile --prefix=${prefix} --buildtype=release -Dplatforms=x11 -Dglx=xlib -Dgallium-drivers=swrast -Dvulkan-drivers= -Dllvm=enabled -Dvalgrind=disabled -Dlibunwind=disabled ..
meson \
--cross-file ${base_dir}/util/crossfile \
--prefix=${prefix} \
--buildtype=release \
-Dplatforms=x11 \
-Dglx=dri \
-Dgallium-drivers=llvmpipe \
-Dvulkan-drivers= \
-Dllvm=enabled \
-Dvalgrind=disabled \
-Dlibunwind=disabled \
-Dbuild-tests=false \
-Degl=enabled \
-Ddri-drivers-path=/usr/lib/dri \
..
}
build() {
+2 -2
View File
@@ -3,10 +3,10 @@ revision=1
from_source=xorg-server
imagedeps="meson ninja-build build-essential"
hostdeps="xgcc xbinutils pkgconfig autoconf automake libtool pkgconfig util-macros xtrans fontutil"
deps="base libxcvt pixman xorgproto xtrans xkbfile libxfont2 fontutil libgcrypt freetype xkeyboardconfig xkbcomp libxi libxrender libxcb libxext pixman libxdamage"
deps="base libxcvt pixman xorgproto xtrans xkbfile libxfont2 fontutil libgcrypt freetype xkeyboardconfig xkbcomp libxi libxrender libxcb libxext pixman libxdamage libdrm mesa"
configure() {
${source_dir}/configure --prefix=/usr --localstatedir=/var --host=x86_64-astral --disable-pciaccess --disable-libdrm --disable-glx --disable-int10-module --disable-glamor --disable-vgahw --disable-dri3 --disable-dri2 --disable-dri --disable-xephyr --disable-xwayland --disable-xnest --disable-dmx --with-fontrootdir=${prefix}/share/fonts/X11 --enable-mitshm
CFLAGS="$CFLAGS -I${sysroot_dir}${prefix}/include/libdrm" LDFLAGS="-ldrm" dridriverdir=/usr/lib/dri ${source_dir}/configure --prefix=/usr --localstatedir=/var --host=x86_64-astral --disable-pciaccess --disable-int10-module --disable-glamor --disable-vgahw --disable-xephyr --disable-xnest --with-fontrootdir=${prefix}/share/fonts/X11 --enable-mitshm
}
build() {
+9
View File
@@ -0,0 +1,9 @@
name=libdrm
version=2.4.122
source_method=tarball
tarball_url="https://dri.freedesktop.org/libdrm/libdrm-${version}.tar.xz"
tarball_sha512="ea6bac94416d4ba0e9805e142ae62904236bc49f803d4fc10c92968a4df64c818dd42524ad7a4e988062836783a148e27094050bb2754f751a368627f794ad13"
prepare() {
true
}
+10
View File
@@ -0,0 +1,10 @@
name=libxshmfence
version=1.3.2
source_method=tarball
tarball_url="https://www.x.org/archive/individual/lib/libxshmfence-${version}.tar.xz"
tarball_sha512="e20a6827e370726cf50489a69f4a52b897f1c44e3eba8c72a4e626b08724e877d090770b8016765736d887d5d5eaba1fda9c29066e62d259b4d1e2064bc1626c"
hostdeps="autoconf automake util-macros pkgconfig libtool"
prepare() {
autoreconf -fvi
}