Skip to content

Commit

Permalink
graphics/mesa-devel: expose OpenCL support
Browse files Browse the repository at this point in the history
Overrides lang/clover but still required for mesa.icd unless built
in standalone mode (DEFAULT_VERSIONS+=gl=mesa-devel). For example,
on Intel GPUs one can set IRIS_ENABLE_CLOVER=1 and RUSTICL_ENABLE=iris
via environ(7) to enable both Clover and Rusticl.

https://docs.mesa3d.org/envvars.html#rusticl-environment-variables
https://github.com/OCL-dev/ocl-icd/blob/master/doc/libOpenCL.7.txt.in
  • Loading branch information
jbeich committed Feb 3, 2023
1 parent 2adedbc commit d8990ef
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 3 deletions.
23 changes: 20 additions & 3 deletions graphics/mesa-devel/Makefile
@@ -1,6 +1,7 @@
PORTNAME= mesa
DISTVERSION= 23.0-branchpoint-838
DISTVERSIONSUFFIX= -g51ea81c0a11
PORTREVISION= 1
CATEGORIES= graphics
PKGNAMESUFFIX= -devel

Expand All @@ -10,7 +11,7 @@ PATCHFILES+= 50433886a3e3.patch:-p1 # https://gitlab.freedesktop.org/mesa/mesa/-
PATCHFILES+= 4c7408374e3d.patch:-p1 # https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21052

MAINTAINER= jbeich@FreeBSD.org
COMMENT= Bleeding edge Mesa drivers (OpenGL, Vulkan)
COMMENT= Bleeding edge Mesa drivers (OpenCL, OpenGL, Vulkan)
WWW= https://www.mesa3d.org/

LICENSE= MIT
Expand Down Expand Up @@ -44,8 +45,8 @@ MESON_ARGS= -Dgallium-omx=disabled \
${NULL}
PLIST_SUB= ARCH=${ARCH:S/amd/x86_/}

OPTIONS_DEFINE= LIBUNWIND LLVM LTO VAAPI VDPAU VKLAYERS WAYLAND X11 ZSTD
OPTIONS_DEFAULT= LIBUNWIND LLVM LTO VAAPI VDPAU VKLAYERS WAYLAND X11 ZSTD
OPTIONS_DEFINE= LIBUNWIND LLVM LTO OPENCL VAAPI VDPAU VKLAYERS WAYLAND X11 ZSTD
OPTIONS_DEFAULT= LIBUNWIND LLVM LTO OPENCL VAAPI VDPAU VKLAYERS WAYLAND X11 ZSTD
OPTIONS_GROUP= GALLIUM VULKAN
OPTIONS_GROUP_GALLIUM= crocus iris panfrost r600 radeonsi
OPTIONS_GROUP_VULKAN= anv hasvk radv
Expand Down Expand Up @@ -102,6 +103,20 @@ ${i}_IMPLIES+= LLVM

LTO_MESON_TRUE= b_lto

OPENCL_DESC= Heterogeneous computing via OpenCL (implies LLVM)
OPENCL_BUILD_DEPENDS= bindgen:devel/rust-bindgen-cli \
libclc>0:devel/libclc \
spirv-tools>0:graphics/spirv-tools \
rustc:lang/rust
OPENCL_LIB_DEPENDS= libLLVMSPIRVLib.so.${LLVM_VERSION}:devel/spirv-llvm-translator@${LLVM_PORT:T}
OPENCL_RUN_DEPENDS= libclc>0:devel/libclc
OPENCL_CONFIGURE_ENV= PKG_CONFIG_PATH="${LLVM_PREFIX}/libdata/pkgconfig"
OPENCL_MESON_FALSE= b_lundef # environ
OPENCL_MESON_TRUE= gallium-rusticl
OPENCL_MESON_ON= -Dgallium-opencl=icd
OPENCL_VARS= LLVM_USES=llvm:15,lib # chase libclc + rust (LTO)
OPENCL_IMPLIES= LLVM ${"${PORT_OPTIONS:Miris}":?iris:radeonsi} # any from OPTIONS_GROUP_GALLIUM

VAAPI_DESC= Hardware encoding/decoding (only r600, radeonsi)
VAAPI_BUILD_DEPENDS= libva>0:multimedia/libva
VAAPI_MESON_ENABLED= gallium-va
Expand Down Expand Up @@ -143,6 +158,8 @@ post-patch:
${WRKSRC}/bin/git_sha1_gen.py

post-patch-COINST-on:
@${MV} ${WRKSRC}/src/gallium/targets/opencl/MesaOpenCL.def.in \
${WRKSRC}/src/gallium/targets/opencl/MesaOpenCL${PKGNAMESUFFIX}.def.in
@${MV} ${WRKSRC}/src/util/00-${PORTNAME}-defaults.conf \
${WRKSRC}/src/util/00-${PKGBASE}-defaults.conf
@${MV} ${WRKSRC}/src/util/00-radv-defaults.conf \
Expand Down
2 changes: 2 additions & 0 deletions graphics/mesa-devel/files/libmap.conf.in
Expand Up @@ -8,6 +8,8 @@ libEGL_mesa.so.0 libEGL_mesa%%SUFFIX%%.so.0
# GBM clients like kmscube and wlroots fail otherwise
libgbm.so.1 libgbm%%SUFFIX%%.so.1

%%OPENCL%%libMesaOpenCL.so.1 libMesaOpenCL%%SUFFIX%%.so.1

%%anv%%%%PREFIX%%/lib/libvulkan_intel.so libvulkan_intel%%SUFFIX%%.so
%%hasvk%%%%PREFIX%%/lib/libvulkan_intel_hasvk.so libvulkan_intel_hasvk%%SUFFIX%%.so
%%radv%%%%PREFIX%%/lib/libvulkan_radeon.so libvulkan_radeon%%SUFFIX%%.so
Expand Down
42 changes: 42 additions & 0 deletions graphics/mesa-devel/files/patch-suffix
Expand Up @@ -62,6 +62,48 @@ Library selection is handled by libglvnd and/or libmap.conf.
egl_lib_version = '0.0.0'
deps_for_egl += dep_glvnd
files_egl += [g_egldispatchstubs_h, g_egldispatchstubs_c]
--- src/gallium/auxiliary/pipe-loader/meson.build.orig 2023-02-01 23:53:26 UTC
+++ src/gallium/auxiliary/pipe-loader/meson.build
@@ -58,7 +58,7 @@ libpipe_loader_dynamic = static_library(
c_args : [
libpipe_loader_defines,
'-DPIPE_SEARCH_DIR="@0@"'.format(
- join_paths(get_option('prefix'), get_option('libdir'), 'gallium-pipe')
+ join_paths(get_option('prefix'), get_option('libdir'), 'gallium-pipe' + get_option('egl-lib-suffix'))
)
],
gnu_symbol_visibility : 'hidden',
--- src/gallium/targets/opencl/meson.build.orig 2023-02-01 23:53:26 UTC
+++ src/gallium/targets/opencl/meson.build
@@ -30,7 +30,7 @@ llvm_libdir = dep_llvm.get_variable(cmake : 'LLVM_LIBR
endif

llvm_libdir = dep_llvm.get_variable(cmake : 'LLVM_LIBRARY_DIR', configtool: 'libdir')
-opencl_libname = with_opencl_icd ? 'MesaOpenCL' : 'OpenCL'
+opencl_libname = with_opencl_icd ? 'MesaOpenCL' + get_option('egl-lib-suffix') : 'OpenCL'

polly_dep = null_dep
polly_isl_dep = null_dep
@@ -117,7 +117,7 @@ if with_opencl_icd

if with_opencl_icd
_config = configuration_data()
- _config.set('OPENCL_LIBNAME', 'MesaOpenCL')
+ _config.set('OPENCL_LIBNAME', 'MesaOpenCL' + get_option('egl-lib-suffix'))
_config.set('OPENCL_VERSION', opencl_version)
configure_file(
configuration : _config,
--- src/gallium/targets/pipe-loader/meson.build.orig 2023-02-01 23:53:26 UTC
+++ src/gallium/targets/pipe-loader/meson.build
@@ -44,7 +44,7 @@ endif
pipe_loader_link_deps += files('pipe.sym')
endif

-pipe_loader_install_dir = join_paths(get_option('libdir'), 'gallium-pipe')
+pipe_loader_install_dir = join_paths(get_option('libdir'), 'gallium-pipe' + get_option('egl-lib-suffix'))

_kmsro_targets = [
driver_kmsro, driver_v3d, driver_vc4, driver_freedreno, driver_etnaviv,
--- src/gbm/backends/dri/gbm_dri.c.orig 2020-05-30 21:28:01 UTC
+++ src/gbm/backends/dri/gbm_dri.c
@@ -307,14 +307,6 @@ dri_bind_extensions(struct gbm_dri_device *dri,
Expand Down
12 changes: 12 additions & 0 deletions graphics/mesa-devel/pkg-plist
@@ -1,4 +1,6 @@
%%VKLAYERS%%bin/mesa-overlay-control.py
%%NO_COINST%%%%OPENCL%%etc/OpenCL/vendors/mesa.icd
%%OPENCL%%etc/OpenCL/vendors/rusticl.icd
%%COINST%%@sample etc/libmap.d/mesa%%SUFFIX%%.conf.sample
%%NO_COINST%%include/EGL/eglext_angle.h
%%NO_COINST%%include/EGL/eglmesaext.h
Expand All @@ -12,12 +14,22 @@
%%panfrost%%lib/dri%%SUFFIX%%/rockchip_dri.so
%%VAAPI%%%%r600%%lib/dri%%SUFFIX%%/r600_drv_video.so
%%VAAPI%%%%radeonsi%%lib/dri%%SUFFIX%%/radeonsi_drv_video.so
%%OPENCL%%%%crocus%%lib/gallium-pipe%%SUFFIX%%/pipe_crocus.so
%%OPENCL%%%%iris%%lib/gallium-pipe%%SUFFIX%%/pipe_iris.so
%%OPENCL%%%%r600%%lib/gallium-pipe%%SUFFIX%%/pipe_r600.so
%%OPENCL%%%%radeonsi%%lib/gallium-pipe%%SUFFIX%%/pipe_radeonsi.so
%%NO_COINST%%lib/libEGL_mesa%%SUFFIX%%.so
lib/libEGL_mesa%%SUFFIX%%.so.0
lib/libEGL_mesa%%SUFFIX%%.so.0.0.0
%%X11%%%%NO_COINST%%lib/libGLX_mesa%%SUFFIX%%.so
%%X11%%lib/libGLX_mesa%%SUFFIX%%.so.0
%%X11%%lib/libGLX_mesa%%SUFFIX%%.so.0.0.0
%%OPENCL%%lib/libMesaOpenCL%%SUFFIX%%.so
%%OPENCL%%lib/libMesaOpenCL%%SUFFIX%%.so.1
%%OPENCL%%lib/libMesaOpenCL%%SUFFIX%%.so.1.0.0
%%OPENCL%%lib/libRusticlOpenCL.so
%%OPENCL%%lib/libRusticlOpenCL.so.1
%%OPENCL%%lib/libRusticlOpenCL.so.1.0.0
%%VKLAYERS%%lib/libVkLayer_MESA_device_select.so
%%VKLAYERS%%lib/libVkLayer_MESA_overlay.so
%%NO_COINST%%lib/libgbm%%SUFFIX%%.so
Expand Down

0 comments on commit d8990ef

Please sign in to comment.