git: b91b541fc60d - main - graphics/mesa-{dri,libs}: Update to 25.2.8

From: Gleb Popov <arrowd_at_FreeBSD.org>
Date: Mon, 15 Jun 2026 15:56:22 UTC
The branch main has been updated by arrowd:

URL: https://cgit.FreeBSD.org/ports/commit/?id=b91b541fc60d66a8010d8c5e12442ae28ab4f7d3

commit b91b541fc60d66a8010d8c5e12442ae28ab4f7d3
Author:     Olivier Cochard <olivier@freebsd.org>
AuthorDate: 2026-05-12 18:29:29 +0000
Commit:     Gleb Popov <arrowd@FreeBSD.org>
CommitDate: 2026-06-15 15:42:59 +0000

    graphics/mesa-{dri,libs}: Update to 25.2.8
    
    PR:             294948
    Co-authored-by: Gleb Popov <arrowd@FreeBSD.org>
---
 graphics/libosmesa/Makefile                        |  2 +
 graphics/mesa-dri/Makefile                         | 18 ++++----
 graphics/mesa-dri/Makefile.common                  | 22 ++++------
 graphics/mesa-dri/distinfo                         | 14 ++----
 .../mesa-dri/files/patch-include_renderdoc__app.h  | 11 +++++
 ...-159fb9691d792594b91e0fbc4c7823e1a191620d.patch | 50 ----------------------
 graphics/mesa-dri/files/patch-meson.build          | 20 ++++-----
 graphics/mesa-dri/pkg-plist                        | 36 ++--------------
 graphics/mesa-gallium-va/Makefile                  | 18 ++++----
 graphics/mesa-gallium-vdpau/Makefile               | 18 ++++----
 graphics/mesa-gallium-xa/Makefile                  |  2 +
 graphics/mesa-libs/Makefile                        | 45 +++++++++++++------
 graphics/mesa-libs/pkg-plist                       | 12 +++---
 13 files changed, 106 insertions(+), 162 deletions(-)

diff --git a/graphics/libosmesa/Makefile b/graphics/libosmesa/Makefile
index 21a6cd84ebd3..95d775e4062f 100644
--- a/graphics/libosmesa/Makefile
+++ b/graphics/libosmesa/Makefile
@@ -8,6 +8,8 @@ WWW=		https://www.mesa3d.org/
 LICENSE=	MIT
 LICENSE_FILE=	${WRKSRC}/docs/license.rst
 
+BROKEN=		osmesa was removed upstream in mesa 25.1
+
 LIB_DEPENDS+=	libglapi.so:graphics/mesa-libs
 
 USES=		llvm:lib,noexport xorg
diff --git a/graphics/mesa-dri/Makefile b/graphics/mesa-dri/Makefile
index 368f39e9d33d..fe3e236e72a4 100644
--- a/graphics/mesa-dri/Makefile
+++ b/graphics/mesa-dri/Makefile
@@ -1,14 +1,13 @@
 PORTNAME=	mesa-dri
 PORTVERSION=	${MESAVERSION}
-PORTREVISION=	12
 CATEGORIES=	graphics
 
 COMMENT=	OpenGL hardware acceleration drivers for DRI2+
 WWW=		https://www.mesa3d.org/
 
 BUILD_DEPENDS+=	${PYTHON_PKGNAMEPREFIX}ply>0:devel/py-ply@${PY_FLAVOR}
-
-LIB_DEPENDS+=	libglapi.so:graphics/mesa-libs
+LIB_DEPENDS+=	libgallium-${MESAVERSION}.so:graphics/mesa-libs \
+		libgbm.so:graphics/mesa-libs
 
 USES+=		llvm:lib,noexport
 
@@ -27,7 +26,7 @@ WAYLAND_DESC=		Enable Wayland support for GBM/EGL and Vulkan
 WAYLAND_BUILD_DEPENDS=	wayland-protocols>=1.8:graphics/wayland-protocols
 WAYLAND_LIB_DEPENDS=	libwayland-client.so:graphics/wayland
 
-OPTIONS_GROUP_GALLIUM=	crocus i915 iris panfrost r300 r600 radeonsi svga swrast zink
+OPTIONS_GROUP_GALLIUM=	crocus i915 iris llvmpipe panfrost r300 r600 radeonsi svga zink
 GALLIUM_DESC=		Unified OpenGL drivers
 crocus_DESC=		Intel GPU Gen4 (Broadwater) to Gen7 (Haswell)
 i915_DESC=		Intel GPU Gen3 (Grantsdale to Pineview)
@@ -39,12 +38,12 @@ iris_RUN_DEPENDS=	spirv-tools>0:graphics/spirv-tools \
 			spirv-llvm-translator-${LLVM_PORT:T}>0:devel/spirv-llvm-translator@${LLVM_PORT:T}
 iris_CONFIGURE_ENV=	PKG_CONFIG_PATH="${LLVM_PREFIX}/libdata/pkgconfig"
 iris_IMPLIES=		SPIRV
+llvmpipe_DESC=		Software Rasterizer
 panfrost_DESC=		ARM Midgard and Bifrost
 r300_DESC=		AMD/ATI R300, R400 and R500
 r600_DESC=		AMD/ATI R600, R700, Evergreen, Northern Islands
 radeonsi_DESC=		AMD/ATI Southern Islands and newer
 svga_DESC=		VMWare Virtual GPU
-swrast_DESC=		Software Rasterizer
 zink_DESC=		OpenGL on top of Khronos’ Vulkan API
 
 OPTIONS_EXCLUDE+=	${ARCH:Marmv7:C/.+/crocus i915 iris panfrost r300 r600 radeonsi svga zink/}
@@ -101,7 +100,6 @@ MESON_ARGS+=	-Dvideo-codecs="vc1dec,h264dec,h264enc,h265dec,h265enc,av1dec,av1en
 
 # Disable some options
 MESON_ARGS+=	-Dandroid-libbacktrace=disabled \
-		-Dgallium-xa=disabled \
 		-Dgallium-vdpau=disabled \
 		-Dgallium-va=disabled \
 		-Dgles1=enabled \
@@ -111,7 +109,6 @@ MESON_ARGS+=	-Dandroid-libbacktrace=disabled \
 		-Degl=enabled \
 		-Dlmsensors=disabled \
 		-Dmicrosoft-clc=disabled \
-		-Dosmesa=false \
 		-Dvalgrind=disabled
 
 .if ${ARCH} != amd64
@@ -136,7 +133,12 @@ PLIST_SUB+=	${_vd}="@comment "
 .endfor
 
 post-install:
-	@${RM} -r ${STAGEDIR}/etc/OpenCL
+# Mesa 25: libgallium-${MESAVERSION}.so and the gbm/GL/dri.pc/drirc bits
+# all belong to graphics/mesa-libs. Strip them from this port's stage tree.
+	${RM} -r ${STAGEDIR}${PREFIX}/include
+	${RM} ${STAGEDIR}${PREFIX}/lib/libgallium-${MESAVERSION}.so
+	${RM} -r ${STAGEDIR}${PREFIX}/lib/gbm
+	${RM} -r ${STAGEDIR}${PREFIX}/libdata/pkgconfig
 	${INSTALL_DATA} ${FILESDIR}/01-freebsd.conf \
 		${STAGEDIR}${PREFIX}/share/drirc.d
 
diff --git a/graphics/mesa-dri/Makefile.common b/graphics/mesa-dri/Makefile.common
index 6862ddeb24ac..6fea3639e33c 100644
--- a/graphics/mesa-dri/Makefile.common
+++ b/graphics/mesa-dri/Makefile.common
@@ -9,18 +9,12 @@
 #    - graphics/mesa-libs
 #    - lang/clover
 
-MESAVERSION=	24.1.7
+MESAVERSION=	25.2.8
 
 MASTER_SITES=	https://mesa.freedesktop.org/archive/
 
 DISTFILES=	mesa-${MESAVERSION}${EXTRACT_SUFX}
 
-PATCH_SITES=	https://gitlab.freedesktop.org/mesa/mesa/-/commit/
-PATCHFILES+=	4a253aae7ca437201d2a31d2a11a1a5434fe41f1.patch:-p1 # https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26284
-PATCHFILES+=	5a9c052ba78e5d1b0020b8f8320d211d2205a958.patch:-p1 # https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29993
-PATCHFILES+=	5d48fb19553c15bbbac498afcb7cc8710a803716.patch:-p1 # https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31931
-PATCHFILES+=	fa9cd89a85b904615ebc11da609445b5b751e68d.patch:-p1 # https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31533
-
 MAINTAINER=	x11@FreeBSD.org
 
 LICENSE=	MIT
@@ -29,7 +23,8 @@ LICENSE_FILE=	${WRKSRC}/docs/license.rst
 COMPONENT=	${PORTNAME:tl:C/^lib//:C/mesa-//}
 
 BUILD_DEPENDS+=	${PYTHON_PKGNAMEPREFIX}mako>0:textproc/py-mako@${PY_FLAVOR} \
-		${PYTHON_PKGNAMEPREFIX}packaging>0:devel/py-packaging@${PY_FLAVOR}
+		${PYTHON_PKGNAMEPREFIX}packaging>0:devel/py-packaging@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}pyyaml>0:devel/py-pyyaml@${PY_FLAVOR}
 .if ${COMPONENT} != clover
 .if ${PORT_OPTIONS:MX11}
 USES+=	xorg
@@ -64,13 +59,11 @@ BINARY_ALIAS+=	python3=${PYTHON_VERSION}
 
 CONFIGURE_ENV+=	LLVM_CONFIG=${LLVM_CONFIG}
 
-# Deal with unclean env if the user have elfutils installed
-# and build the port directly without poudriere
+# mesa 25.x removed the -Dlibelf option; libelf is now auto-detected.
+# If the user has elfutils installed in LOCALBASE, propagate it as a
+# proper LIB_DEPENDS so the dependency is recorded.
 .if exists(${LOCALBASE}/include/libelf.h)
 LIB_DEPENDS+=	libelf.so:devel/elfutils
-MESON_ARGS+=	-Dlibelf=enabled
-.else
-MESON_ARGS+=	-Dlibelf=disabled
 .endif
 
 # Some symbols in mesa's linker version scripts are not always defined,
@@ -80,4 +73,5 @@ LDFLAGS+=	-Wl,--undefined-version
 
 LDFLAGS+=	-Wl,-rpath=${LOCALBASE}/llvm${LLVM_VERSION}/lib
 MESON_ARGS+=	-Dllvm=enabled \
-		-Dlibunwind=disabled
+		-Dlibunwind=disabled \
+		-Dgallium-mediafoundation=disabled
diff --git a/graphics/mesa-dri/distinfo b/graphics/mesa-dri/distinfo
index 61f1b44e1d26..39a69f4d89b2 100644
--- a/graphics/mesa-dri/distinfo
+++ b/graphics/mesa-dri/distinfo
@@ -1,11 +1,3 @@
-TIMESTAMP = 1745569914
-SHA256 (mesa-24.1.7.tar.xz) = ecd2e7b1c73998f4103542f39c6b8c968d251637ccc8caa42641aecb86cd2566
-SIZE (mesa-24.1.7.tar.xz) = 29206724
-SHA256 (4a253aae7ca437201d2a31d2a11a1a5434fe41f1.patch) = 84f18f14788bd8f387e2fc754b945bf30f84b517dd917785ed5d8ef1d594e24a
-SIZE (4a253aae7ca437201d2a31d2a11a1a5434fe41f1.patch) = 1626
-SHA256 (5a9c052ba78e5d1b0020b8f8320d211d2205a958.patch) = 4b4b7e205ea333db66c809d442f17e1f865aa623c54e7e4d918c45a1f2c9704f
-SIZE (5a9c052ba78e5d1b0020b8f8320d211d2205a958.patch) = 2162
-SHA256 (5d48fb19553c15bbbac498afcb7cc8710a803716.patch) = 316360bdb0e0eb46075a8e537e1147283d1e88f2ee48d9eac13bb8c24f7d7b46
-SIZE (5d48fb19553c15bbbac498afcb7cc8710a803716.patch) = 1090
-SHA256 (fa9cd89a85b904615ebc11da609445b5b751e68d.patch) = ec8acde15e1408a871f977db4743300f654efa888d032d680aed19938024ea24
-SIZE (fa9cd89a85b904615ebc11da609445b5b751e68d.patch) = 1346
+TIMESTAMP = 1777655135
+SHA256 (mesa-25.2.8.tar.xz) = 097842f3e49d996868b38688db87b006f7d4541e93ce86d2f341d8b3e7be7c93
+SIZE (mesa-25.2.8.tar.xz) = 43813260
diff --git a/graphics/mesa-dri/files/patch-include_renderdoc__app.h b/graphics/mesa-dri/files/patch-include_renderdoc__app.h
new file mode 100644
index 000000000000..7334da88f9f2
--- /dev/null
+++ b/graphics/mesa-dri/files/patch-include_renderdoc__app.h
@@ -0,0 +1,11 @@
+--- include/renderdoc_app.h.orig	2026-05-01 23:38:47 UTC
++++ include/renderdoc_app.h
+@@ -35,7 +35,7 @@
+ 
+ #if defined(WIN32)
+ #define RENDERDOC_CC __cdecl
+-#elif defined(__linux__)
++#elif defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__)
+ #define RENDERDOC_CC
+ #elif defined(__APPLE__)
+ #define RENDERDOC_CC
diff --git a/graphics/mesa-dri/files/patch-llvmpipe-159fb9691d792594b91e0fbc4c7823e1a191620d.patch b/graphics/mesa-dri/files/patch-llvmpipe-159fb9691d792594b91e0fbc4c7823e1a191620d.patch
deleted file mode 100644
index c3c250a8b8df..000000000000
--- a/graphics/mesa-dri/files/patch-llvmpipe-159fb9691d792594b91e0fbc4c7823e1a191620d.patch
+++ /dev/null
@@ -1,50 +0,0 @@
-From 159fb9691d792594b91e0fbc4c7823e1a191620d Mon Sep 17 00:00:00 2001
-From: Lucas Fryzek <lfryzek@igalia.com>
-Date: Mon, 28 Oct 2024 13:02:26 -0400
-Subject: [PATCH] lp: Only close udmabuf handle if its valid
-
-Also change ifdef's from just `HAVE_LIBDRM` to check for both LIBDRM
-and for UDMABUF HEADER. preventing unbalanced guards preventing part of
-the code from being included if you just have LIBDRM or just have the
-udmabuf headers.
-
-Fixes: 4cfaf10c ("llvmpipe: Only use udmabuf with libdrm")
-Reviewed-by: Konstantin Seurer <konstantin.seurer@gmail.com>
-Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31877>
----
- src/gallium/drivers/llvmpipe/lp_screen.c | 5 +++--
- src/gallium/drivers/llvmpipe/lp_screen.h | 2 +-
- 2 files changed, 4 insertions(+), 3 deletions(-)
-
-diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c
-index 8ede54a1fdf20..f85911b4703ac 100644
---- src/gallium/drivers/llvmpipe/lp_screen.c
-+++ src/gallium/drivers/llvmpipe/lp_screen.c
-@@ -939,8 +939,9 @@ llvmpipe_destroy_screen(struct pipe_screen *_screen)
- 
-    glsl_type_singleton_decref();
- 
--#ifdef HAVE_LIBDRM
--   close(screen->udmabuf_fd);
-+#if defined(HAVE_LIBDRM) && defined(HAVE_LINUX_UDMABUF_H)
-+   if (screen->udmabuf_fd != -1)
-+      close(screen->udmabuf_fd);
- #endif
- 
- #if DETECT_OS_LINUX
-diff --git a/src/gallium/drivers/llvmpipe/lp_screen.h b/src/gallium/drivers/llvmpipe/lp_screen.h
-index f36628340b3af..63ce25d56d1d3 100644
---- src/gallium/drivers/llvmpipe/lp_screen.h
-+++ src/gallium/drivers/llvmpipe/lp_screen.h
-@@ -75,7 +75,7 @@ struct llvmpipe_screen
- 
-    struct disk_cache *disk_shader_cache;
- 
--#ifdef HAVE_LIBDRM
-+#if defined(HAVE_LIBDRM) && defined(HAVE_LINUX_UDMABUF_H)
-    int udmabuf_fd;
- #endif
- 
--- 
-GitLab
-
diff --git a/graphics/mesa-dri/files/patch-meson.build b/graphics/mesa-dri/files/patch-meson.build
index b94c2e4dd7ba..dee5fd0ef099 100644
--- a/graphics/mesa-dri/files/patch-meson.build
+++ b/graphics/mesa-dri/files/patch-meson.build
@@ -1,11 +1,11 @@
---- meson.build.orig	2023-09-20 17:15:34 UTC
+--- meson.build.orig	2026-05-01 17:13:34 UTC
 +++ meson.build
-@@ -709,7 +709,7 @@ if _power8.allowed()
-         int main() {
-           vector unsigned char r;
-           vector unsigned int v = vec_splat_u32 (1);
--          r = __builtin_vec_vgbbd ((vector unsigned char) v);
-+          r = __builtin_altivec_vgbbd ((vector unsigned char) v);
-           return 0;
-         }''',
-         args : '-mpower8-vector',
+@@ -734,7 +734,7 @@ if host_machine.cpu_family() == 'ppc64' and host_machi
+       int main() {
+         vector unsigned char r;
+         vector unsigned int v = vec_splat_u32 (1);
+-        r = __builtin_vec_vgbbd ((vector unsigned char) v);
++        r = __builtin_altivec_vgbbd ((vector unsigned char) v);
+         return 0;
+       }''',
+       name : 'POWER8 intrinsics')
diff --git a/graphics/mesa-dri/pkg-plist b/graphics/mesa-dri/pkg-plist
index 5c06f06c0b75..6288ae10fb87 100644
--- a/graphics/mesa-dri/pkg-plist
+++ b/graphics/mesa-dri/pkg-plist
@@ -1,26 +1,4 @@
-@comment include/EGL/egl.h
-@comment include/EGL/eglext_angle.h
-@comment include/EGL/eglext.h
-@comment include/EGL/eglmesaext.h
-@comment include/EGL/eglplatform.h
-include/GL/internal/dri_interface.h
-@comment include/GL/gl.h
-@comment include/GL/glcorearb.h
-@comment include/GL/glext.h
-@comment include/GLES/egl.h
-@comment include/GLES/gl.h
-@comment include/GLES/glext.h
-@comment include/GLES/glplatform.h
-@comment include/GLES2/gl2.h
-@comment include/GLES2/gl2ext.h
-@comment include/GLES2/gl2platform.h
-@comment include/GLES3/gl3.h
-@comment include/GLES3/gl31.h
-@comment include/GLES3/gl32.h
-@comment include/GLES3/gl3ext.h
-@comment include/GLES3/gl3platform.h
-@comment include/KHR/khrplatform.h
-@comment include/gbm.h
+lib/dri/libdril_dri.so
 %%crocus%%lib/dri/crocus_dri.so
 %%i915%%lib/dri/i915_dri.so
 %%iris%%lib/dri/iris_dri.so
@@ -30,8 +8,8 @@ include/GL/internal/dri_interface.h
 %%r600%%lib/dri/r600_dri.so
 %%radeonsi%%lib/dri/radeonsi_dri.so
 %%svga%%lib/dri/vmwgfx_dri.so
-%%swrast%%lib/dri/kms_swrast_dri.so
-%%swrast%%lib/dri/swrast_dri.so
+%%llvmpipe%%lib/dri/kms_swrast_dri.so
+%%llvmpipe%%lib/dri/swrast_dri.so
 %%zink%%lib/dri/zink_dri.so
 @comment lib/libEGL.so
 @comment lib/libEGL.so.1
@@ -39,9 +17,6 @@ include/GL/internal/dri_interface.h
 @comment lib/libgbm.so
 @comment lib/libgbm.so.1
 @comment lib/libgbm.so.1.0.0
-@comment lib/libglapi.so
-@comment lib/libglapi.so.0
-@comment lib/libglapi.so.0.0.0
 @comment lib/libGLESv1_CM.so
 @comment lib/libGLESv1_CM.so.1
 @comment lib/libGLESv1_CM.so.1.1.0
@@ -51,11 +26,6 @@ include/GL/internal/dri_interface.h
 %%anv%%lib/libvulkan_intel.so
 %%radv%%lib/libvulkan_radeon.so
 %%swrast_vk%%lib/libvulkan_lvp.so
-libdata/pkgconfig/dri.pc
-@comment libdata/pkgconfig/egl.pc
-@comment libdata/pkgconfig/gbm.pc
-@comment libdata/pkgconfig/glesv1_cm.pc
-@comment libdata/pkgconfig/glesv2.pc
 share/drirc.d/00-mesa-defaults.conf
 %%radv%%share/drirc.d/00-radv-defaults.conf
 share/drirc.d/01-freebsd.conf
diff --git a/graphics/mesa-gallium-va/Makefile b/graphics/mesa-gallium-va/Makefile
index 84e1e1e22d9b..c9f47f2d85de 100644
--- a/graphics/mesa-gallium-va/Makefile
+++ b/graphics/mesa-gallium-va/Makefile
@@ -12,7 +12,8 @@ ONLY_FOR_ARCHS=		aarch64 i386 amd64 powerpc64 powerpc64le
 ONLY_FOR_ARCHS_REASON=	used only by AMD/Radeon hardware
 
 BUILD_DEPENDS=	libva>=0:multimedia/libva
-LIB_DEPENDS=	libzstd.so:archivers/zstd
+LIB_DEPENDS=	libzstd.so:archivers/zstd \
+		libgallium-${MESAVERSION}.so:graphics/mesa-libs
 
 USES=		llvm:lib,noexport
 
@@ -44,20 +45,14 @@ MESON_ARGS+=	-Dvideo-codecs="vc1dec,h264dec,h264enc,h265dec,h265enc,av1dec,av1en
 		-Dvulkan-drivers="" \
 		-Dandroid-libbacktrace=disabled \
 		-Dgallium-vdpau=disabled \
-		-Dgallium-omx=disabled \
-		-Dgallium-xa=disabled \
-		-Dgallium-opencl=disabled \
-		-Dgallium-nine=false \
 		-Dgbm=disabled \
 		-Dgles1=disabled \
 		-Dgles2=disabled \
 		-Dglvnd=disabled \
 		-Dlmsensors=disabled \
 		-Dmicrosoft-clc=disabled \
-		-Dosmesa=false \
 		-Dvalgrind=disabled \
-		-Dglx=disabled \
-		-Ddri3=enabled
+		-Dglx=disabled
 
 LDFLAGS_i386=	-Wl,-znotext
 
@@ -86,4 +81,11 @@ MESON_ARGS+=	-Dglx=disabled \
 		-Dplatforms=""
 .endif
 
+post-install:
+# Mesa 25: libgallium-${MESAVERSION}.so is owned by graphics/mesa-libs.
+	${RM} -f ${STAGEDIR}${PREFIX}/lib/libgallium-${MESAVERSION}.so
+	${RM} -f ${STAGEDIR}${PREFIX}/lib/dri/r300_dri.so
+	${RM} -f ${STAGEDIR}${PREFIX}/lib/dri/r600_dri.so
+	${RM} -f ${STAGEDIR}${PREFIX}/lib/dri/radeonsi_dri.so
+
 .include <bsd.port.post.mk>
diff --git a/graphics/mesa-gallium-vdpau/Makefile b/graphics/mesa-gallium-vdpau/Makefile
index a4d2f06c89db..33ddf93dc2d7 100644
--- a/graphics/mesa-gallium-vdpau/Makefile
+++ b/graphics/mesa-gallium-vdpau/Makefile
@@ -12,7 +12,8 @@ ONLY_FOR_ARCHS=		aarch64 i386 amd64 powerpc64 powerpc64le
 ONLY_FOR_ARCHS_REASON=	used only by AMD/Radeon hardware
 
 BUILD_DEPENDS=	libvdpau>=0:multimedia/libvdpau
-LIB_DEPENDS=	libzstd.so:archivers/zstd
+LIB_DEPENDS=	libzstd.so:archivers/zstd \
+		libgallium-${MESAVERSION}.so:graphics/mesa-libs
 
 USES=		llvm:lib,noexport xorg
 
@@ -39,20 +40,14 @@ ${_gd}_VARS+=		GALLIUM_DRIVERS+=${_gd}
 MESON_ARGS+=	-Dvulkan-drivers="" \
 		-Dandroid-libbacktrace=disabled \
 		-Dgallium-va=disabled \
-		-Dgallium-omx=disabled \
-		-Dgallium-xa=disabled \
-		-Dgallium-opencl=disabled \
-		-Dgallium-nine=false \
 		-Dgbm=disabled \
 		-Dgles1=disabled \
 		-Dgles2=disabled \
 		-Dglvnd=disabled \
 		-Dlmsensors=disabled \
 		-Dmicrosoft-clc=disabled \
-		-Dosmesa=false \
 		-Dvalgrind=disabled \
-		-Dglx=disabled \
-		-Ddri3=enabled
+		-Dglx=disabled
 
 LDFLAGS_i386=	-Wl,-znotext
 
@@ -71,4 +66,11 @@ PLIST_SUB+=	${_gd}="@comment "
 . endif
 .endfor
 
+post-install:
+# Mesa 25: libgallium-${MESAVERSION}.so is owned by graphics/mesa-libs.
+	${RM} -f ${STAGEDIR}${PREFIX}/lib/libgallium-${MESAVERSION}.so
+	${RM} -f ${STAGEDIR}${PREFIX}/lib/dri/r300_dri.so
+	${RM} -f ${STAGEDIR}${PREFIX}/lib/dri/r600_dri.so
+	${RM} -f ${STAGEDIR}${PREFIX}/lib/dri/radeonsi_dri.so
+
 .include <bsd.port.post.mk>
diff --git a/graphics/mesa-gallium-xa/Makefile b/graphics/mesa-gallium-xa/Makefile
index 3d09f7ab433a..eb8d0b1d8a46 100644
--- a/graphics/mesa-gallium-xa/Makefile
+++ b/graphics/mesa-gallium-xa/Makefile
@@ -8,6 +8,8 @@ WWW=		https://www.mesa3d.org/
 LICENSE=	MIT
 LICENSE_FILE=	${WRKSRC}/docs/license.rst
 
+BROKEN=		gallium-xa was removed upstream in mesa 25.1
+
 ONLY_FOR_ARCHS=		amd64 i386
 ONLY_FOR_ARCHS_REASON=	used only by VMware supported architectures
 
diff --git a/graphics/mesa-libs/Makefile b/graphics/mesa-libs/Makefile
index 7ffe5201b2a5..d653b3b01348 100644
--- a/graphics/mesa-libs/Makefile
+++ b/graphics/mesa-libs/Makefile
@@ -1,6 +1,5 @@
 PORTNAME=	mesa-libs
 PORTVERSION=	${MESAVERSION}
-PORTREVISION=	1
 CATEGORIES=	graphics
 
 COMMENT=	OpenGL libraries that support GLX and EGL clients
@@ -11,7 +10,15 @@ LICENSE_FILE=	${WRKSRC}/docs/license.rst
 
 USES=		llvm:noexport
 
-BUILD_DEPENDS=	libglvnd>=0:graphics/libglvnd
+BUILD_DEPENDS=	libglvnd>=0:graphics/libglvnd \
+		${PYTHON_PKGNAMEPREFIX}ply>0:devel/py-ply@${PY_FLAVOR} \
+		libclc-${LLVM_PORT:T}>0:devel/libclc@${LLVM_PORT:T} \
+		spirv-tools>0:graphics/spirv-tools \
+		spirv-llvm-translator-${LLVM_PORT:T}>0:devel/spirv-llvm-translator@${LLVM_PORT:T}
+RUN_DEPENDS=	spirv-tools>0:graphics/spirv-tools \
+		spirv-llvm-translator-${LLVM_PORT:T}>0:devel/spirv-llvm-translator@${LLVM_PORT:T}
+
+CONFIGURE_ENV+=	PKG_CONFIG_PATH="${LLVM_PREFIX}/libdata/pkgconfig"
 
 OPTIONS_GROUP=		PLATFORM
 OPTIONS_GROUP_PLATFORM=	X11 WAYLAND
@@ -33,23 +40,31 @@ USE_LDCONFIG=		yes
 .include <bsd.port.options.mk>
 .include "${.CURDIR:H:H}/graphics/mesa-dri/Makefile.common"
 
+LDFLAGS_i386=	-Wl,-znotext
+
+# mesa-libs is the home of libgallium-${MESAVERSION}.so (the unified gallium
+# runtime introduced in mesa 25's "megalib" refactor). It must be built with
+# a real gallium driver set so install_megadrivers actually ships the lib;
+# the per-driver lib/dri/*_dri.so shims that fall out of this build are
+# stripped in post-install (they belong to graphics/mesa-dri).
+GALLIUM_DRIVERS=	crocus i915 iris llvmpipe panfrost r300 r600 radeonsi svga zink
+.if ${ARCH} != amd64 && ${ARCH} != i386 && ${ARCH} != x86_64
+GALLIUM_DRIVERS:=	${GALLIUM_DRIVERS:Ncrocus:Ni915:Niris:Nsvga}
+.endif
+.if ${ARCH} == armv7
+GALLIUM_DRIVERS=	llvmpipe
+.endif
+
+MESON_ARGS+=	-Dgallium-drivers=${GALLIUM_DRIVERS:ts,}
+MESON_ARGS+=	-Dvulkan-drivers=""
+
 MESON_ARGS+=	-Dandroid-libbacktrace=disabled \
 		-Dgallium-vdpau=disabled \
-		-Dgallium-omx=disabled \
 		-Dgallium-va=disabled \
-		-Dgallium-xa=disabled \
-		-Dgallium-nine=false \
 		-Dlmsensors=disabled \
 		-Dmicrosoft-clc=disabled \
-		-Dosmesa=false \
 		-Dtools="" \
-		-Dvalgrind=disabled \
-		-Degl=enabled \
-		-Dgbm=enabled \
-		-Dvulkan-drivers="" \
-		-Dglvnd=enabled
-# Building EGL and GBM requires a driver so add r300
-MESON_ARGS+=	-Dgallium-drivers="r300"
+		-Dvalgrind=disabled
 
 .if ${PORT_OPTIONS:MX11}
 MESA_PLATFORMS+=	x11
@@ -76,9 +91,13 @@ MESON_ARGS+=	-Dintel-rt=disabled # https://gitlab.freedesktop.org/mesa/mesa/-/is
 LDFLAGS+=-Wl,-z,notext
 .endif
 
+PLIST_SUB+=	MESAVERSION=${MESAVERSION}
+
 post-install:
 # Fallback if GLX_EXT_libglvnd is missing or vendor library doesn't exist
 	@${ECHO_CMD} "libGLX_indirect.so.0 libGLX_mesa.so.0" \
 		>${STAGEDIR}${PREFIX}/etc/libmap.d/mesa.conf
+# Strip the per-hardware DRI shims; they are owned by graphics/mesa-dri.
+	${RM} -rf ${STAGEDIR}${PREFIX}/lib/dri
 
 .include <bsd.port.post.mk>
diff --git a/graphics/mesa-libs/pkg-plist b/graphics/mesa-libs/pkg-plist
index 9d92766c8f37..de7084ae45a6 100644
--- a/graphics/mesa-libs/pkg-plist
+++ b/graphics/mesa-libs/pkg-plist
@@ -1,23 +1,21 @@
 etc/libmap.d/mesa.conf
 include/EGL/eglext_angle.h
 include/EGL/eglmesaext.h
-@comment include/GL/internal/dri_interface.h
+include/GL/internal/dri_interface.h
 include/gbm.h
-@comment lib/dri/radeon_dri.so
-@comment lib/dri/r300_dri.so
+include/gbm_backend_abi.h
+lib/gbm/dri_gbm.so
 lib/libEGL_mesa.so
 lib/libEGL_mesa.so.0
 lib/libEGL_mesa.so.0.0.0
 %%GLX%%lib/libGLX_mesa.so
 %%GLX%%lib/libGLX_mesa.so.0
 %%GLX%%lib/libGLX_mesa.so.0.0.0
+lib/libgallium-%%MESAVERSION%%.so
 lib/libgbm.so
 lib/libgbm.so.1
 lib/libgbm.so.1.0.0
-lib/libglapi.so
-lib/libglapi.so.0
-lib/libglapi.so.0.0.0
-@comment libdata/pkgconfig/dri.pc
+libdata/pkgconfig/dri.pc
 libdata/pkgconfig/gbm.pc
 @comment share/drirc.d/00-mesa-defaults.conf
 share/glvnd/egl_vendor.d/50_mesa.json