diff mbox series

[v2,1/2] mesa: add opencl DISTRO_FEATURE

Message ID 20250915232557.536762-1-dmitry.baryshkov@oss.qualcomm.com
State Accepted, archived
Commit 3061d6061e74a545b7a190fd13b52ac181994dd1
Headers show
Series [v2,1/2] mesa: add opencl DISTRO_FEATURE | expand

Commit Message

Dmitry Baryshkov Sept. 15, 2025, 11:25 p.m. UTC
OpenCL is an important part of the GPU-related world. It makes sense to
be able to provide headless environment (without OpenGL and Vulkan), but
having just OpenCL as a GPU user. Currently it is not possible since
mesa requires either of those to be enabled for the DISTRO.

Add new 'opencl' DISTRO_FEATURE, controlling enablement of OpenCL.

Note: Mesa, if built with the libclc packageconfig (which is required
for OpenCL driver) depends on the mesa-clc tool from the mesa-native
package. It is required to propagate opencl DISTRO_FEATURE to the native
set in order to be able to fulfill mesa -> mesa-native dependency as
otherwise mesa-native package will be skipped.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>

---

A patch to disable OpenCL ICD Loader (which is a part of meta-oe) will
be submitted separately.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
---
 meta/conf/bitbake.conf              | 4 ++--
 meta/recipes-graphics/mesa/mesa.bb  | 1 +
 meta/recipes-graphics/mesa/mesa.inc | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)

Comments

Quentin Schulz Sept. 18, 2025, 12:16 p.m. UTC | #1
Hi Dmitry,

On 9/16/25 1:25 AM, Dmitry Baryshkov via lists.openembedded.org wrote:
> OpenCL is an important part of the GPU-related world. It makes sense to
> be able to provide headless environment (without OpenGL and Vulkan), but
> having just OpenCL as a GPU user. Currently it is not possible since
> mesa requires either of those to be enabled for the DISTRO.
> 
> Add new 'opencl' DISTRO_FEATURE, controlling enablement of OpenCL.
> 
> Note: Mesa, if built with the libclc packageconfig (which is required
> for OpenCL driver) depends on the mesa-clc tool from the mesa-native
> package. It is required to propagate opencl DISTRO_FEATURE to the native
> set in order to be able to fulfill mesa -> mesa-native dependency as
> otherwise mesa-native package will be skipped.
> 

Ah, I think I see now.

Wouldn't that be handled by removing the dependency of mesa on 
mesa-native for libclc if we switch to depending on mesa-tools-native 
instead? Something I attempted to do here: 
https://lore.kernel.org/openembedded-core/20250822-mesa-libclc-panfrost-v6-12-393cf47e2fa2@cherry.de/

What's preventing me from doing this right now is that we have expat and 
zlib in DEPENDS in mesa.inc and mesa-tools-native is including it but as 
a native-only package. In that scenario, DEPENDS content is NOT 
automatically replaced with -native recipes, but only through 
PACKAGECONFIG dependency mechanism. Therefore, we would need to migrate 
expat and zlib to a PACKAGECONFIG option (which can be enabled by 
default!) so that mesa-tools-native can be merged and thus remove the 
need for a mesa's libclc config to require mesa-native's config to 
contain libclc. Which means we don't need to have opencl in the 
native/nativesdk filter?

What do you think?

Cheers,
Quentin
Dmitry Baryshkov Sept. 18, 2025, 5:14 p.m. UTC | #2
On Thu, Sep 18, 2025 at 02:16:07PM +0200, Quentin Schulz wrote:
> Hi Dmitry,
> 
> On 9/16/25 1:25 AM, Dmitry Baryshkov via lists.openembedded.org wrote:
> > OpenCL is an important part of the GPU-related world. It makes sense to
> > be able to provide headless environment (without OpenGL and Vulkan), but
> > having just OpenCL as a GPU user. Currently it is not possible since
> > mesa requires either of those to be enabled for the DISTRO.
> > 
> > Add new 'opencl' DISTRO_FEATURE, controlling enablement of OpenCL.
> > 
> > Note: Mesa, if built with the libclc packageconfig (which is required
> > for OpenCL driver) depends on the mesa-clc tool from the mesa-native
> > package. It is required to propagate opencl DISTRO_FEATURE to the native
> > set in order to be able to fulfill mesa -> mesa-native dependency as
> > otherwise mesa-native package will be skipped.
> > 
> 
> Ah, I think I see now.
> 
> Wouldn't that be handled by removing the dependency of mesa on mesa-native
> for libclc if we switch to depending on mesa-tools-native instead? Something
> I attempted to do here: https://lore.kernel.org/openembedded-core/20250822-mesa-libclc-panfrost-v6-12-393cf47e2fa2@cherry.de/
> 
> What's preventing me from doing this right now is that we have expat and
> zlib in DEPENDS in mesa.inc and mesa-tools-native is including it but as a
> native-only package. In that scenario, DEPENDS content is NOT automatically
> replaced with -native recipes, but only through PACKAGECONFIG dependency
> mechanism. Therefore, we would need to migrate expat and zlib to a
> PACKAGECONFIG option (which can be enabled by default!) so that
> mesa-tools-native can be merged and thus remove the need for a mesa's libclc
> config to require mesa-native's config to contain libclc. Which means we
> don't need to have opencl in the native/nativesdk filter?

Yes, we can drop it as soon as that patch lands. If you don't mind, I
will take a look if I can fix the dependencies in your patch in a nicer
way.

> 
> What do you think?
> 
> Cheers,
> Quentin
>
diff mbox series

Patch

diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
index 8e90c7bbc85c..eebefc484062 100644
--- a/meta/conf/bitbake.conf
+++ b/meta/conf/bitbake.conf
@@ -915,8 +915,8 @@  DISTRO_FEATURES_NATIVESDK:mingw32 = "x11 ipv6"
 
 # Normally target distro features will not be applied to native builds:
 # Native distro features on this list will use the target feature value
-DISTRO_FEATURES_FILTER_NATIVE ?= "api-documentation debuginfod opengl wayland"
-DISTRO_FEATURES_FILTER_NATIVESDK ?= "api-documentation debuginfod opengl wayland"
+DISTRO_FEATURES_FILTER_NATIVE ?= "api-documentation debuginfod opencl opengl wayland"
+DISTRO_FEATURES_FILTER_NATIVESDK ?= "api-documentation debuginfod opencl opengl wayland"
 
 DISTRO_FEATURES_BACKFILL = "pulseaudio sysvinit gobject-introspection-data ldconfig"
 MACHINE_FEATURES_BACKFILL = "rtc qemu-usermode"
diff --git a/meta/recipes-graphics/mesa/mesa.bb b/meta/recipes-graphics/mesa/mesa.bb
index 49e077b20cd2..cfa5d0f40f0a 100644
--- a/meta/recipes-graphics/mesa/mesa.bb
+++ b/meta/recipes-graphics/mesa/mesa.bb
@@ -5,6 +5,7 @@  PACKAGECONFIG = " \
 	video-codecs \
 	${@bb.utils.filter('DISTRO_FEATURES', 'x11 vulkan wayland glvnd', d)} \
 	${@bb.utils.contains('DISTRO_FEATURES', 'opengl', 'opengl egl gles gbm virgl', '', d)} \
+	${@bb.utils.contains('DISTRO_FEATURES', 'opencl', 'opencl libclc gallium-llvm', '', d)} \
 	${@bb.utils.contains('DISTRO_FEATURES', 'vulkan', 'zink', '', d)} \
 	xmlconfig \
 "
diff --git a/meta/recipes-graphics/mesa/mesa.inc b/meta/recipes-graphics/mesa/mesa.inc
index 3f09cfd4df21..a58de5ebc3da 100644
--- a/meta/recipes-graphics/mesa/mesa.inc
+++ b/meta/recipes-graphics/mesa/mesa.inc
@@ -46,7 +46,7 @@  EXTRANATIVEPATH += "chrpath-native"
 
 inherit meson pkgconfig python3native gettext features_check rust
 
-ANY_OF_DISTRO_FEATURES = "opengl vulkan"
+ANY_OF_DISTRO_FEATURES = "opencl opengl vulkan"
 
 PLATFORMS ??= "${@bb.utils.filter('PACKAGECONFIG', 'x11 wayland', d)}"