Merge branch 'zink-nodrm' into 'main'

meson: Support building zink/Kopper without libdrm for KGSL, fix debian-no-libdrm CI job

Closes #8634

See merge request mesa/mesa!40302
This commit is contained in:
Valentine Burley 2026-03-11 04:54:53 +00:00
commit eaf7aeec59
14 changed files with 44 additions and 29 deletions

View file

@ -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:

View file

@ -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']
@ -352,7 +354,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 +415,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 +540,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 +659,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 +2205,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 +2221,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 +2331,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 +2465,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

View file

@ -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',

View file

@ -33,7 +33,7 @@
#include <fcntl.h>
#include <stdbool.h>
#include <stdio.h>
#include <xf86drm.h>
#include "util/libdrm.h"
#include <cutils/properties.h>
#include <drm-uapi/drm_fourcc.h>
#include <sync/sync.h>

View file

@ -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);
}

View file

@ -35,7 +35,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <xf86drm.h>
#include "util/libdrm.h"
#include "drm-uapi/drm_fourcc.h"
#include <sys/mman.h>
#include <vulkan/vulkan_core.h>

View file

@ -42,7 +42,7 @@
#include <vulkan/vulkan_xcb.h>
/* clang-format on */
#ifdef HAVE_LIBDRM
#include <xf86drm.h>
#include "util/libdrm.h"
#include "platform_x11_dri3.h"
#endif
#include "util/bitscan.h"

View file

@ -31,7 +31,7 @@
#include <xcb/xcb.h>
#if defined(HAVE_WAYLAND_PLATFORM)
#include <xf86drm.h>
#include "util/libdrm.h"
#endif
#include "drm-uapi/drm_fourcc.h"
#include "util/macros.h"

View file

@ -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]

View file

@ -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,

View file

@ -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')

View file

@ -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

View file

@ -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 */

View file

@ -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