From 1295332d3e210ea70a500f2acd95701d61d37096 Mon Sep 17 00:00:00 2001 From: Valentine Burley Date: Mon, 9 Mar 2026 14:12:36 +0100 Subject: [PATCH 1/7] util: Add more libdrm stubs drmGetNodeTypeFromFd and drmGetRenderDeviceNameFromFd will be used in EGL. Signed-off-by: Valentine Burley --- src/util/libdrm.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/util/libdrm.h b/src/util/libdrm.h index d8ef0b55182..8876ebef675 100644 --- a/src/util/libdrm.h +++ b/src/util/libdrm.h @@ -131,6 +131,18 @@ drmFreeDevices(drmDevicePtr devices[], int count) {} static inline char* drmGetDeviceNameFromFd2(int fd) { return NULL;} +static inline int +drmGetNodeTypeFromFd(int fd) +{ + return -1; +} + +static inline char * +drmGetRenderDeviceNameFromFd(int fd) +{ + return NULL; +} + typedef struct _drmVersion { int version_major; /**< Major version */ int version_minor; /**< Minor version */ From 73718fed727841ce8d71c1129a8e52462853f7e2 Mon Sep 17 00:00:00 2001 From: Valentine Burley Date: Mon, 9 Mar 2026 14:13:27 +0100 Subject: [PATCH 2/7] egl: Use util/libdrm.h instead of xf86drm.h This will allow for building and running zink on systems without libdrm by using Mesa's internal stubs. Signed-off-by: Valentine Burley --- src/egl/drivers/dri2/platform_android.c | 2 +- src/egl/drivers/dri2/platform_wayland.c | 2 +- src/egl/drivers/dri2/platform_x11.c | 2 +- src/egl/drivers/dri2/platform_x11_dri3.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c index 7db9f6bccb6..73f0ae5b547 100644 --- a/src/egl/drivers/dri2/platform_android.c +++ b/src/egl/drivers/dri2/platform_android.c @@ -33,7 +33,7 @@ #include #include #include -#include +#include "util/libdrm.h" #include #include #include diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c index 89c046d8d48..e59d4fe4875 100644 --- a/src/egl/drivers/dri2/platform_wayland.c +++ b/src/egl/drivers/dri2/platform_wayland.c @@ -35,7 +35,7 @@ #include #include #include -#include +#include "util/libdrm.h" #include "drm-uapi/drm_fourcc.h" #include #include diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c index 62ae615c6f3..96c38aacd93 100644 --- a/src/egl/drivers/dri2/platform_x11.c +++ b/src/egl/drivers/dri2/platform_x11.c @@ -42,7 +42,7 @@ #include /* clang-format on */ #ifdef HAVE_LIBDRM -#include +#include "util/libdrm.h" #include "platform_x11_dri3.h" #endif #include "util/bitscan.h" diff --git a/src/egl/drivers/dri2/platform_x11_dri3.c b/src/egl/drivers/dri2/platform_x11_dri3.c index ab44c5333bc..2c4353ae1f5 100644 --- a/src/egl/drivers/dri2/platform_x11_dri3.c +++ b/src/egl/drivers/dri2/platform_x11_dri3.c @@ -31,7 +31,7 @@ #include #if defined(HAVE_WAYLAND_PLATFORM) -#include +#include "util/libdrm.h" #endif #include "drm-uapi/drm_fourcc.h" #include "util/macros.h" From 3d23ae7ff44eb7cdf442559b461d0bffb19f1c37 Mon Sep 17 00:00:00 2001 From: Valentine Burley Date: Mon, 9 Mar 2026 14:14:01 +0100 Subject: [PATCH 3/7] egl/surfaceless: Allow zink fallback without forcing software On non-DRM systems, the surfaceless platform should be able to fall back to zink even if ForceSoftware is not set. This allows zink to run on top of Turnip/KGSL where hardware DRM nodes might be missing. Signed-off-by: Valentine Burley --- src/egl/drivers/dri2/platform_surfaceless.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/egl/drivers/dri2/platform_surfaceless.c b/src/egl/drivers/dri2/platform_surfaceless.c index 8fbb9a60ed4..ff7bb4a5600 100644 --- a/src/egl/drivers/dri2/platform_surfaceless.c +++ b/src/egl/drivers/dri2/platform_surfaceless.c @@ -385,12 +385,12 @@ dri2_initialize_surfaceless(_EGLDisplay *disp) struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); /* When ForceSoftware is false, we try the HW driver. When ForceSoftware - * is true, we try kms_swrast and swrast in order. + * or Zink is true, we try kms_swrast and swrast/zink in order. */ driver_loaded = surfaceless_probe_device(disp, disp->Options.ForceSoftware, disp->Options.Zink); - if (!driver_loaded && disp->Options.ForceSoftware) { - _eglLog(_EGL_DEBUG, "Falling back to surfaceless swrast without DRM."); + if (!driver_loaded && (disp->Options.ForceSoftware || disp->Options.Zink)) { + _eglLog(_EGL_DEBUG, "Falling back to surfaceless without DRM."); driver_loaded = surfaceless_probe_device_sw(disp); } From 15c7e40ba1790969f4698551a6e2acb461fa002c Mon Sep 17 00:00:00 2001 From: Valentine Burley Date: Mon, 9 Mar 2026 14:20:30 +0100 Subject: [PATCH 4/7] meson: Add support for buidling zink + Turnip/KGSL Rename the 'hurd' dri_platform to 'software' to represent non-DRM presentation platforms. This platform is now also enabled when building zink and Turnip with the KGSL backend, allowing zink to use Kopper. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/8634 Signed-off-by: Valentine Burley --- meson.build | 18 +++++++++--------- src/egl/meson.build | 2 +- src/gallium/auxiliary/meson.build | 2 +- src/gallium/frontends/dri/meson.build | 2 +- src/glx/meson.build | 2 +- src/x11/meson.build | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/meson.build b/meson.build index f2b32e7fbe5..95f0bbd0801 100644 --- a/meson.build +++ b/meson.build @@ -352,7 +352,7 @@ with_vdrm = [ ].contains(true) with_dri = false -if with_gallium and system_has_kms_drm +if with_gallium and (system_has_kms_drm or (freedreno_kmds.contains('kgsl') and with_gallium_zink)) _glx = get_option('glx') _egl = get_option('egl') if _glx == 'dri' or _egl.enabled() or (_glx == 'disabled' and _egl.allowed()) @@ -413,8 +413,8 @@ elif ['windows', 'cygwin'].contains(host_machine.system()) with_dri_platform = 'windows' elif system_has_kms_drm with_dri_platform = 'drm' -elif host_machine.system() == 'gnu' - with_dri_platform = 'hurd' +elif host_machine.system() == 'gnu' or (freedreno_kmds.contains('kgsl') and with_gallium_zink) + with_dri_platform = 'software' else # FIXME: haiku doesn't use dri, and xlib doesn't use dri, probably should # assert here that one of those cases has been met. @@ -538,7 +538,7 @@ with_gbm = get_option('gbm') \ .allowed() with_xlib_lease = get_option('xlib-lease') \ - .require(with_platform_x11 and (system_has_kms_drm or with_dri_platform == 'apple' or with_dri_platform == 'hurd'), error_message : 'xlib-lease requires X11 and KMS/DRM support') \ + .require(with_platform_x11 and (system_has_kms_drm or with_dri_platform == 'apple' or with_dri_platform == 'software'), error_message : 'xlib-lease requires X11 and KMS/DRM support') \ .allowed() with_egl = get_option('egl') \ @@ -657,7 +657,7 @@ if with_vulkan_icd_dir == '' with_vulkan_icd_dir = join_paths(get_option('datadir'), 'vulkan/icd.d') endif -with_dri2 = (with_dri or with_any_vk) and (with_dri_platform == 'drm' or with_dri_platform == 'apple' or with_dri_platform == 'hurd') +with_dri2 = (with_dri or with_any_vk) and (with_dri_platform == 'drm' or with_dri_platform == 'apple' or with_dri_platform == 'software') if with_dri if with_glx == 'disabled' and not with_egl and not with_gbm @@ -2203,7 +2203,7 @@ if with_platform_x11 error('libdrm required for gallium video statetrackers when using x11') endif endif - if with_dri_platform == 'drm' or with_dri_platform == 'hurd' + if with_dri_platform == 'drm' or with_dri_platform == 'software' dep_xcb_dri3 = dependency('xcb-dri3', version : dep_xcb_dri3_version) dep_xcb_present = dependency('xcb-present', version : dep_xcb_present_version) if (dep_xcb_dri3.version().version_compare('>= 1.17') and @@ -2219,7 +2219,7 @@ if with_platform_x11 dep_glproto = dependency('glproto', version : dep_glproto_version) endif if with_glx == 'dri' - if with_dri_platform == 'drm' or with_dri_platform == 'hurd' + if with_dri_platform == 'drm' or with_dri_platform == 'software' if with_glx_direct dep_xxf86vm = dependency('xxf86vm') endif @@ -2329,7 +2329,7 @@ elif with_glx == 'dri' gl_priv_reqs += [ 'x11', 'xext', 'xfixes', 'x11-xcb', 'xcb', 'xcb-glx >= 1.8.1'] - if with_dri_platform == 'drm' or with_dri_platform == 'hurd' + if with_dri_platform == 'drm' or with_dri_platform == 'software' gl_priv_reqs += 'xcb-dri2 >= 1.8' if with_glx_direct gl_priv_reqs += 'xxf86vm' @@ -2463,7 +2463,7 @@ if with_egl if with_dri egl_drivers += 'builtin:egl_dri2' endif - if with_dri_platform == 'drm' or with_dri_platform == 'hurd' + if with_dri_platform == 'drm' or with_dri_platform == 'software' egl_drivers += 'builtin:egl_dri3' endif if with_platform_windows diff --git a/src/egl/meson.build b/src/egl/meson.build index acd277fa5e9..9a27fae3429 100644 --- a/src/egl/meson.build +++ b/src/egl/meson.build @@ -108,7 +108,7 @@ if with_dri files_egl += files('drivers/dri2/platform_x11.c') incs_for_egl += inc_loader_x11 link_for_egl += libloader_x11 - if with_dri_platform == 'drm' or with_dri_platform == 'hurd' + if with_dri_platform == 'drm' or with_dri_platform == 'software' files_egl += files('drivers/dri2/platform_x11_dri3.c') endif deps_for_egl += [dep_x11_xcb, dep_xcb_xrandr, dep_xcb_xfixes, dep_xcb_shm] diff --git a/src/gallium/auxiliary/meson.build b/src/gallium/auxiliary/meson.build index c3a22c2dd1e..d1d2cfd27ae 100644 --- a/src/gallium/auxiliary/meson.build +++ b/src/gallium/auxiliary/meson.build @@ -420,7 +420,7 @@ endif if with_platform_x11 files_libgalliumvlwinsys += files('vl/vl_winsys_dri.c') links_libgalliumvlwinsys += libloader_x11 - if with_dri_platform == 'drm' or with_dri_platform == 'hurd' + if with_dri_platform == 'drm' or with_dri_platform == 'software' vlwinsys_deps += [ dep_xcb_sync, dep_xcb_present, dep_xshmfence, dep_xcb_xfixes, dep_xcb_dri3, diff --git a/src/gallium/frontends/dri/meson.build b/src/gallium/frontends/dri/meson.build index 38d8db52e30..8b939f861e0 100644 --- a/src/gallium/frontends/dri/meson.build +++ b/src/gallium/frontends/dri/meson.build @@ -21,7 +21,7 @@ files_libdri = files( if with_platform_x11 deps_for_libdri += dep_xcb - if with_dri_platform == 'drm' or with_dri_platform == 'hurd' + if with_dri_platform == 'drm' or with_dri_platform == 'software' deps_for_libdri += [dep_xcb_dri3, dep_xcb_present, dep_xcb_sync, dep_xshmfence, dep_xcb_xfixes] files_libdri += files('loader_dri3_helper.c') diff --git a/src/glx/meson.build b/src/glx/meson.build index 42c58eed40a..8ee877ea080 100644 --- a/src/glx/meson.build +++ b/src/glx/meson.build @@ -58,7 +58,7 @@ extra_libs_libglx = [] extra_deps_libgl = [] extra_ld_args_libgl = [] -if with_dri_platform == 'drm' or with_dri_platform == 'hurd' +if with_dri_platform == 'drm' or with_dri_platform == 'software' files_libglx += files('dri3_glx.c', 'dri3_priv.h') endif diff --git a/src/x11/meson.build b/src/x11/meson.build index 44a5578e772..292a167089e 100644 --- a/src/x11/meson.build +++ b/src/x11/meson.build @@ -7,7 +7,7 @@ loader_x11_files = files( 'x11_display.c', ) -if with_dri_platform == 'drm' or with_dri_platform == 'hurd' +if with_dri_platform == 'drm' or with_dri_platform == 'software' loader_x11_files += files('x11_dri3.c') endif From b18e99f2771283c4a0fbea9084a4c12fd555dce5 Mon Sep 17 00:00:00 2001 From: Valentine Burley Date: Mon, 9 Mar 2026 14:22:31 +0100 Subject: [PATCH 5/7] meson: Fix Turnip libdrm-linking check Use with_gallium_drm instead of with_gallium_kmsro for the Turnip libdrm-linking warning. This avoids incorrectly forcing a link to libdrm when zink is enabled in a KGSL-only build. Signed-off-by: Valentine Burley --- meson.build | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index 95f0bbd0801..9ed741686b4 100644 --- a/meson.build +++ b/meson.build @@ -250,7 +250,7 @@ if with_gallium_swrast endif with_gallium = gallium_drivers.length() != 0 -with_gallium_kmsro = system_has_kms_drm and [ +with_gallium_drm = system_has_kms_drm and [ with_gallium_asahi, with_gallium_etnaviv, with_gallium_freedreno, @@ -258,7 +258,6 @@ with_gallium_kmsro = system_has_kms_drm and [ with_gallium_panfrost, with_gallium_v3d, with_gallium_vc4, - with_gallium_zink, ].contains(true) _vulkan_drivers = get_option('vulkan-drivers') @@ -322,7 +321,7 @@ freedreno_kmds = get_option('freedreno-kmds') if freedreno_kmds.length() != 0 and freedreno_kmds != [ 'msm' ] and with_freedreno_vk if freedreno_kmds.contains('msm') warning('Turnip with the DRM KMD will require libdrm to always be present at runtime which may not always be the case on platforms such as Android.') - elif with_gallium_kmsro + elif with_gallium_drm warning('As a side-effect, Turnip is forced to link with libdrm when built alongside Gallium DRM drivers which platforms such as Android may not have available at runtime.') elif _vulkan_drivers != [ 'freedreno' ] warning('Turnip is forced to link with libdrm when built alongside other Vulkan drivers which platforms such as Android may not have available at runtime.') @@ -333,6 +332,9 @@ if freedreno_kmds.length() != 0 and freedreno_kmds != [ 'msm' ] and with_freedre endif endif +# This has to be below the freedreno_kmds check since that can change system_has_kms_drm +with_gallium_kmsro = with_gallium_drm or (system_has_kms_drm and with_gallium_zink) + pre_args += ['-DMESA_SYSTEM_HAS_KMS_DRM=@0@'.format(system_has_kms_drm.to_int())] if host_machine.cpu_family() == 'x86' and with_glx_read_only_text pre_args += ['-DGLX_X86_READONLY_TEXT'] From f131979413a18a6d1c28e97f2483d197adc6ca49 Mon Sep 17 00:00:00 2001 From: Valentine Burley Date: Mon, 9 Mar 2026 14:48:30 +0100 Subject: [PATCH 6/7] ci: Enable EGL and GLX in debian-no-libdrm Now that zink can be built without a hard dependency on libdrm by using the 'software' dri_platform, we can enable EGL, GLX, and the associated window system platforms (X11, Wayland) in the debian-no-libdrm build job. Signed-off-by: Valentine Burley --- .gitlab-ci/build/gitlab-ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci/build/gitlab-ci.yml b/.gitlab-ci/build/gitlab-ci.yml index 7dc4649c30b..9b0ae2378e3 100644 --- a/.gitlab-ci/build/gitlab-ci.yml +++ b/.gitlab-ci/build/gitlab-ci.yml @@ -547,10 +547,11 @@ debian-no-libdrm: BUILDTYPE: release EXTRA_OPTION: > -D freedreno-kmds=kgsl - -D glx=disabled + -D glx=dri -D gbm=disabled - -D egl=disabled + -D egl=enabled -D perfetto=true + -D platforms=x11,wayland debian-clang: extends: From e480883f765f158f8d757e38f1004c8cd73257ce Mon Sep 17 00:00:00 2001 From: Valentine Burley Date: Mon, 9 Mar 2026 14:59:28 +0100 Subject: [PATCH 7/7] meson: Update freedreno-kmds comment Turnip has supported virtio for some time, and KGSL support for the gallium driver is no longer planned, point users to zink instead. Also document the WSL backend. Signed-off-by: Valentine Burley --- meson.options | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/meson.options b/meson.options index 7311f21fc85..220d46eaba3 100644 --- a/meson.options +++ b/meson.options @@ -216,9 +216,9 @@ option( 'will be built' ) -# Note that currently turnip supports msm and kgsl, while the gallium driver -# support msm and virtio. This is a temporary situation with virtio support -# for turnip and kgsl support for gallium planned/in-progress. +# Note that the freedreno gallium driver doesn't support KGSL. +# On those systems, zink with Turnip should be used instead. +# WSL is only supported for the replay tool. option( 'freedreno-kmds', type : 'array',