git: 6bfc189110c7 - main - graphics/mesa-gallium-{va,vdpau}: Turn gallium drivers into options

From: Emmanuel Vadot <manu_at_FreeBSD.org>
Date: Fri, 31 Jan 2025 07:45:03 UTC
The branch main has been updated by manu:

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

commit 6bfc189110c7430fe236a4444b823694dc528dc8
Author:     Emmanuel Vadot <manu@FreeBSD.org>
AuthorDate: 2025-01-31 07:42:12 +0000
Commit:     Emmanuel Vadot <manu@FreeBSD.org>
CommitDate: 2025-01-31 07:43:46 +0000

    graphics/mesa-gallium-{va,vdpau}: Turn gallium drivers into options
    
    While here bring back i386 support but only for the r600 driver as amdgpu
    isn't supported on this arch.
    
    Requested by:   danfe, jbeich
    Sponsored by:   Beckhoff Automation GmbH & Co. KG
---
 graphics/mesa-gallium-va/Makefile     | 26 ++++++++++++++++++++++++--
 graphics/mesa-gallium-va/pkg-plist    |  4 ++--
 graphics/mesa-gallium-vdpau/Makefile  | 28 +++++++++++++++++++++++++---
 graphics/mesa-gallium-vdpau/pkg-plist | 16 ++++++++--------
 4 files changed, 59 insertions(+), 15 deletions(-)

diff --git a/graphics/mesa-gallium-va/Makefile b/graphics/mesa-gallium-va/Makefile
index efdfeebcd73e..84e1e1e22d9b 100644
--- a/graphics/mesa-gallium-va/Makefile
+++ b/graphics/mesa-gallium-va/Makefile
@@ -8,7 +8,7 @@ WWW=		https://www.mesa3d.org/
 LICENSE=	MIT
 LICENSE_FILE=	${WRKSRC}/docs/license.rst
 
-ONLY_FOR_ARCHS=		aarch64 amd64 powerpc64 powerpc64le
+ONLY_FOR_ARCHS=		aarch64 i386 amd64 powerpc64 powerpc64le
 ONLY_FOR_ARCHS_REASON=	used only by AMD/Radeon hardware
 
 BUILD_DEPENDS=	libva>=0:multimedia/libva
@@ -17,16 +17,30 @@ LIB_DEPENDS=	libzstd.so:archivers/zstd
 USES=		llvm:lib,noexport
 
 OPTIONS_DEFINE=		X11
+OPTIONS_GROUP=		GALLIUM
 OPTIONS_DEFAULT=	X11
+OPTIONS_SUB=		yes
+
 X11_DESC=		Enable X11 support
 X11_USES=		xorg
 X11_USE=		xorg=xorgproto,x11,xcb,xdamage,xext,xfixes,xshmfence,xxf86vm,xrandr
 
+OPTIONS_GROUP_GALLIUM=	radeonsi r600
+GALLIUM_DESC=		Gallium Video Drivers
+radeonsi_DESC=		AMD/ATI Southern Islands and newer
+r600_DESC=		AMD/ATI R600, R700, Evergreen, Northern Islands
+OPTIONS_EXCLUDE+=	${ARCH:Mi386:C/.+/radeonsi/}
+
+MESON_ARGS+=		-Dgallium-drivers=${GALLIUM_DRIVERS:ts,}
+. for _gd in ${OPTIONS_GROUP_GALLIUM}
+OPTIONS_DEFAULT+=	${_gd}
+${_gd}_VARS+=		GALLIUM_DRIVERS+=${_gd}
+. endfor
+
 .include <bsd.port.options.mk>
 .include "${.CURDIR:H:H}/graphics/mesa-dri/Makefile.common"
 
 MESON_ARGS+=	-Dvideo-codecs="vc1dec,h264dec,h264enc,h265dec,h265enc,av1dec,av1enc,vp9dec" \
-		-Dgallium-drivers="radeonsi,r600" \
 		-Dvulkan-drivers="" \
 		-Dandroid-libbacktrace=disabled \
 		-Dgallium-vdpau=disabled \
@@ -53,6 +67,14 @@ MESON_ARGS+=	-Dgallium-va=enabled
 MESON_ARGS+=	-Dintel-rt=disabled # https://gitlab.freedesktop.org/mesa/mesa/-/issues/10629
 .endif
 
+.for _gd in ${OPTIONS_GROUP_GALLIUM}
+. if defined(GALLIUM_DRIVERS) && ${GALLIUM_DRIVERS:M${_gd}}
+PLIST_SUB+=	${_gd}=""
+. else
+PLIST_SUB+=	${_gd}="@comment "
+. endif
+.endfor
+
 .if ${PORT_OPTIONS:MX11}
 MESON_ARGS+=	-Dplatforms="x11"
 .else
diff --git a/graphics/mesa-gallium-va/pkg-plist b/graphics/mesa-gallium-va/pkg-plist
index f8a847c7bff0..1d4632cf7d73 100644
--- a/graphics/mesa-gallium-va/pkg-plist
+++ b/graphics/mesa-gallium-va/pkg-plist
@@ -9,9 +9,9 @@
 @comment include/GL/internal/dri_interface.h
 @comment include/KHR/khrplatform.h
 @comment lib/dri/r600_dri.so
-lib/dri/r600_drv_video.so
+%%r600%%lib/dri/r600_drv_video.so
 @comment lib/dri/radeonsi_dri.so
-lib/dri/radeonsi_drv_video.so
+%%radeonsi%%lib/dri/radeonsi_drv_video.so
 @comment lib/libEGL.so
 @comment lib/libEGL.so.1
 @comment lib/libEGL.so.1.0.0
diff --git a/graphics/mesa-gallium-vdpau/Makefile b/graphics/mesa-gallium-vdpau/Makefile
index 23dce3055494..a4d2f06c89db 100644
--- a/graphics/mesa-gallium-vdpau/Makefile
+++ b/graphics/mesa-gallium-vdpau/Makefile
@@ -8,7 +8,7 @@ WWW=		https://www.mesa3d.org/
 LICENSE=	MIT
 LICENSE_FILE=	${WRKSRC}/docs/license.rst
 
-ONLY_FOR_ARCHS=		aarch64 amd64 powerpc64 powerpc64le
+ONLY_FOR_ARCHS=		aarch64 i386 amd64 powerpc64 powerpc64le
 ONLY_FOR_ARCHS_REASON=	used only by AMD/Radeon hardware
 
 BUILD_DEPENDS=	libvdpau>=0:multimedia/libvdpau
@@ -18,11 +18,25 @@ USES=		llvm:lib,noexport xorg
 
 USE_XORG=	xorgproto x11 xcb xdamage xext xfixes xshmfence xxf86vm xrandr
 
+OPTIONS_GROUP=		GALLIUM
+OPTIONS_SUB=		yes
+
+OPTIONS_GROUP_GALLIUM=	radeonsi r600
+GALLIUM_DESC=		Gallium Video Drivers
+radeonsi_DESC=		AMD/ATI Southern Islands and newer
+r600_DESC=		AMD/ATI R600, R700, Evergreen, Northern Islands
+OPTIONS_EXCLUDE+=	${ARCH:Mi386:C/.+/radeonsi/}
+
+MESON_ARGS+=		-Dgallium-drivers=${GALLIUM_DRIVERS:ts,}
+. for _gd in ${OPTIONS_GROUP_GALLIUM}
+OPTIONS_DEFAULT+=	${_gd}
+${_gd}_VARS+=		GALLIUM_DRIVERS+=${_gd}
+. endfor
+
 .include <bsd.port.options.mk>
 .include "${.CURDIR:H:H}/graphics/mesa-dri/Makefile.common"
 
-MESON_ARGS+=	-Dgallium-drivers="r600,radeonsi" \
-		-Dvulkan-drivers="" \
+MESON_ARGS+=	-Dvulkan-drivers="" \
 		-Dandroid-libbacktrace=disabled \
 		-Dgallium-va=disabled \
 		-Dgallium-omx=disabled \
@@ -49,4 +63,12 @@ MESON_ARGS+=	-Dplatforms="x11" \
 MESON_ARGS+=	-Dintel-rt=disabled # https://gitlab.freedesktop.org/mesa/mesa/-/issues/10629
 .endif
 
+.for _gd in ${OPTIONS_GROUP_GALLIUM}
+. if defined(GALLIUM_DRIVERS) && ${GALLIUM_DRIVERS:M${_gd}}
+PLIST_SUB+=	${_gd}=""
+. else
+PLIST_SUB+=	${_gd}="@comment "
+. endif
+.endfor
+
 .include <bsd.port.post.mk>
diff --git a/graphics/mesa-gallium-vdpau/pkg-plist b/graphics/mesa-gallium-vdpau/pkg-plist
index 4d88ba1194b7..8d03b4978739 100644
--- a/graphics/mesa-gallium-vdpau/pkg-plist
+++ b/graphics/mesa-gallium-vdpau/pkg-plist
@@ -19,14 +19,14 @@
 @comment lib/libglapi.so
 @comment lib/libglapi.so.0
 @comment lib/libglapi.so.0.0.0
-lib/vdpau/libvdpau_r600.so
-lib/vdpau/libvdpau_r600.so.1
-lib/vdpau/libvdpau_r600.so.1.0
-lib/vdpau/libvdpau_r600.so.1.0.0
-lib/vdpau/libvdpau_radeonsi.so
-lib/vdpau/libvdpau_radeonsi.so.1
-lib/vdpau/libvdpau_radeonsi.so.1.0
-lib/vdpau/libvdpau_radeonsi.so.1.0.0
+%%r600%%lib/vdpau/libvdpau_r600.so
+%%r600%%lib/vdpau/libvdpau_r600.so.1
+%%r600%%lib/vdpau/libvdpau_r600.so.1.0
+%%r600%%lib/vdpau/libvdpau_r600.so.1.0.0
+%%radeonsi%%lib/vdpau/libvdpau_radeonsi.so
+%%radeonsi%%lib/vdpau/libvdpau_radeonsi.so.1
+%%radeonsi%%lib/vdpau/libvdpau_radeonsi.so.1.0
+%%radeonsi%%lib/vdpau/libvdpau_radeonsi.so.1.0.0
 @comment libdata/pkgconfig/dri.pc
 @comment libdata/pkgconfig/egl.pc
 @comment share/drirc.d/00-mesa-defaults.conf