diff mbox series

[3/6] mesa: enable a rich set of drivers for native builds

Message ID 20230316094102.2628727-3-alex@linutronix.de
State Accepted, archived
Commit 98d5c382e55910870d7e86dc83e3b7c742ea54cd
Headers show
Series [1/6] runqemu: direct mesa to use its own drivers, rather than ones provided by host distro | expand

Commit Message

Alexander Kanavin March 16, 2023, 9:40 a.m. UTC
Without this, the only available driver would be swrast
(without llvmpipe) which is far too slow to be practical,
and so qemu wouldn't be able to perform accelerated graphics.

The one major dependency pulled in by this change is llvm-native
which takes just under three minutes on my machine. If this is
undesitable, opengl can be removed from DISTRO_FEATURES_NATIVE.

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
 meta/recipes-graphics/mesa/mesa.inc | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

Comments

Ross Burton March 20, 2023, 5:10 p.m. UTC | #1
On 16 Mar 2023, at 09:40, Alexander Kanavin via lists.openembedded.org <alex.kanavin=gmail.com@lists.openembedded.org> wrote:
> 
> Without this, the only available driver would be swrast
> (without llvmpipe) which is far too slow to be practical,
> and so qemu wouldn't be able to perform accelerated graphics.
> 
> The one major dependency pulled in by this change is llvm-native
> which takes just under three minutes on my machine. If this is
> undesitable, opengl can be removed from DISTRO_FEATURES_NATIVE.

Grumble build time grumble.

Can we make this a packageconfig that is documented heavily in the local.conf sample?  My builder is headless so I disable the sdl backend in qemu-system-native already, and I’d be disabling this too as 99% of the time I just use runqemu nographic, but I don’t want to disable opengl entirely.

Ross
Alexander Kanavin March 20, 2023, 5:41 p.m. UTC | #2
On Mon, 20 Mar 2023 at 18:10, Ross Burton <Ross.Burton@arm.com> wrote:
> > The one major dependency pulled in by this change is llvm-native
> > which takes just under three minutes on my machine. If this is
> > undesitable, opengl can be removed from DISTRO_FEATURES_NATIVE.
>
> Grumble build time grumble.
>
> Can we make this a packageconfig that is documented heavily in the local.conf sample?  My builder is headless so I disable the sdl backend in qemu-system-native already, and I’d be disabling this too as 99% of the time I just use runqemu nographic, but I don’t want to disable opengl entirely.

You can disable native opengl on the native distro feature level, but
keep target opengl enabled, would that work? I'm not sure if there is
a use case for native mesa without the drivers.

Even on headless hosts you can use egl-headless, and then a vnc client
will show you the qemu display.

Alex
Peter Marko Aug. 2, 2024, 5:52 p.m. UTC | #3
> -----Original Message-----
> From: openembedded-core@lists.openembedded.org <openembedded-
> core@lists.openembedded.org> On Behalf Of Alexander Kanavin via
> lists.openembedded.org
> Sent: Thursday, March 16, 2023 10:41
> To: openembedded-core@lists.openembedded.org
> Cc: Kanavin, Alexander (EXT) (Linutronix GmbH) <alex@linutronix.de>
> Subject: [OE-core] [PATCH 3/6] mesa: enable a rich set of drivers for native
> builds
> 
> Without this, the only available driver would be swrast
> (without llvmpipe) which is far too slow to be practical,
> and so qemu wouldn't be able to perform accelerated graphics.
> 
> The one major dependency pulled in by this change is llvm-native
> which takes just under three minutes on my machine. If this is
> undesitable, opengl can be removed from DISTRO_FEATURES_NATIVE.

I was just hit by this commit when migrating our gui layers from kirkstone to scarthgap.
We include clang-native in our sdk and this creates conflict:
ERROR: product-image-sdk-1.0-r0 do_prepare_recipe_sysroot: The file /usr/bin/llvm-lto2 is installed by both llvm-native and clang-native, aborting

I had to create mesa_%.bbappend which replaces llvm with clang
PACKAGECONFIG[gallium-llvm] = "-Dllvm=enabled -Dshared-llvm=enabled, -Dllvm=disabled, clang clang-native elfutils"

But bbappends are bad idea for config changes and should be only used as last resort so I'd like to solve it via distro config.
Also update-alternatives doesn't work for native recipes I think.

Any idea how to solve this in a nice way?
One idea from me would be to create global LLVM_PROVIDER and LLVM_NATIVE_PROVIDER variables which could be automatically switched in meta-clang.
Wdyt?

> 
> Signed-off-by: Alexander Kanavin <alex@linutronix.de>
> ---
>  meta/recipes-graphics/mesa/mesa.inc | 20 ++++++++++++++------
>  1 file changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/meta/recipes-graphics/mesa/mesa.inc b/meta/recipes-
> graphics/mesa/mesa.inc
> index 775aab9297..dd15046438 100644
> --- a/meta/recipes-graphics/mesa/mesa.inc
> +++ b/meta/recipes-graphics/mesa/mesa.inc
> @@ -89,6 +89,8 @@ PACKAGECONFIG = " \
>  	${@bb.utils.contains('LICENSE_FLAGS_ACCEPTED', 'commercial',
> 'video-codecs', '', d)} \
>  "
> 
> +PACKAGECONFIG:append:class-native = "gallium-llvm r600"
> +
>  # "gbm" requires "opengl"
>  PACKAGECONFIG[gbm] = "-Dgbm=enabled,-Dgbm=disabled"
> 
> @@ -102,8 +104,10 @@ PACKAGECONFIG[dri3] = "-Ddri3=enabled, -
> Ddri3=disabled, xorgproto libxshmfence"
>  # Vulkan drivers need dri3 enabled
>  # amd could be enabled as well but requires gallium-llvm with llvm >= 3.9
>  VULKAN_DRIVERS = ""
> -VULKAN_DRIVERS:append:x86:class-target = ",intel"
> -VULKAN_DRIVERS:append:x86-64:class-target = ",intel"
> +VULKAN_DRIVERS:append:x86 = ",intel"
> +VULKAN_DRIVERS:append:x86-64 = ",intel"
> +# i686 is a 32 bit override for mesa-native
> +VULKAN_DRIVERS:append:i686 = ",intel"
>  VULKAN_DRIVERS:append ="${@bb.utils.contains('PACKAGECONFIG',
> 'freedreno', ',freedreno', '', d)}"
>  VULKAN_DRIVERS:append ="${@bb.utils.contains('PACKAGECONFIG',
> 'broadcom', ',broadcom', '', d)}"
>  PACKAGECONFIG[vulkan] = "-Dvulkan-
> drivers=${@strip_comma('${VULKAN_DRIVERS}')}, -Dvulkan-
> drivers='',glslang-native vulkan-loader vulkan-headers"
> @@ -149,8 +153,10 @@ PACKAGECONFIG[zink] = ""
>  GALLIUMDRIVERS = "swrast"
>  # gallium swrast was found to crash Xorg on startup in x32 qemu
>  GALLIUMDRIVERS:x86-x32 = ""
> -GALLIUMDRIVERS:append:x86:class-target = ",i915,iris,crocus"
> -GALLIUMDRIVERS:append:x86-64:class-target = ",i915,iris,crocus"
> +GALLIUMDRIVERS:append:x86 = ",i915,iris,crocus"
> +GALLIUMDRIVERS:append:x86-64 = ",i915,iris,crocus"
> +# i686 is a 32 bit override for mesa-native
> +GALLIUMDRIVERS:append:i686 = ",i915,iris,crocus"
> 
>  GALLIUMDRIVERS:append ="${@bb.utils.contains('PACKAGECONFIG',
> 'etnaviv', ',etnaviv', '', d)}"
>  GALLIUMDRIVERS:append ="${@bb.utils.contains('PACKAGECONFIG',
> 'freedreno', ',freedreno', '', d)}"
> @@ -162,8 +168,10 @@ GALLIUMDRIVERS:append
> ="${@bb.utils.contains('PACKAGECONFIG', 'zink', ',zink', '
>  # radeonsi requires LLVM
>  GALLIUMDRIVERS_RADEONSI = "${@bb.utils.contains('PACKAGECONFIG',
> 'r600', ',radeonsi', '', d)}"
>  GALLIUMDRIVERS_LLVM = "r300,nouveau${GALLIUMDRIVERS_RADEONSI}"
> -GALLIUMDRIVERS_LLVM:append:x86:class-target = ",svga"
> -GALLIUMDRIVERS_LLVM:append:x86-64:class-target = ",svga"
> +GALLIUMDRIVERS_LLVM:append:x86 = ",svga"
> +GALLIUMDRIVERS_LLVM:append:x86-64 = ",svga"
> +# i686 is a 32 bit override for mesa-native
> +GALLIUMDRIVERS_LLVM:append:i686 = ",svga"
> 
>  PACKAGECONFIG[r600] = ""
>  PACKAGECONFIG[virgl] = ""
> --
> 2.30.2
Zoltán Böszörményi Aug. 3, 2024, 5:13 a.m. UTC | #4
2024. 08. 02. 19:52 keltezéssel, Peter Marko via lists.openembedded.org írta:
>> -----Original Message-----
>> From: openembedded-core@lists.openembedded.org <openembedded-
>> core@lists.openembedded.org> On Behalf Of Alexander Kanavin via
>> lists.openembedded.org
>> Sent: Thursday, March 16, 2023 10:41
>> To: openembedded-core@lists.openembedded.org
>> Cc: Kanavin, Alexander (EXT) (Linutronix GmbH) <alex@linutronix.de>
>> Subject: [OE-core] [PATCH 3/6] mesa: enable a rich set of drivers for native
>> builds
>>
>> Without this, the only available driver would be swrast
>> (without llvmpipe) which is far too slow to be practical,
>> and so qemu wouldn't be able to perform accelerated graphics.
>>
>> The one major dependency pulled in by this change is llvm-native
>> which takes just under three minutes on my machine. If this is
>> undesitable, opengl can be removed from DISTRO_FEATURES_NATIVE.
> I was just hit by this commit when migrating our gui layers from kirkstone to scarthgap.
> We include clang-native in our sdk and this creates conflict:
> ERROR: product-image-sdk-1.0-r0 do_prepare_recipe_sysroot: The file /usr/bin/llvm-lto2 is installed by both llvm-native and clang-native, aborting
>
> I had to create mesa_%.bbappend which replaces llvm with clang
> PACKAGECONFIG[gallium-llvm] = "-Dllvm=enabled -Dshared-llvm=enabled, -Dllvm=disabled, clang clang-native elfutils"
>
> But bbappends are bad idea for config changes and should be only used as last resort so I'd like to solve it via distro config.
> Also update-alternatives doesn't work for native recipes I think.
>
> Any idea how to solve this in a nice way?
> One idea from me would be to create global LLVM_PROVIDER and LLVM_NATIVE_PROVIDER variables which could be automatically switched in meta-clang.
> Wdyt?

This is already documented in meta-clang.
Though it's not automatic, you have to add it manually to
your custom distro's configuration or local.conf.

https://github.com/kraj/meta-clang?tab=readme-ov-file#providing-llvm
diff mbox series

Patch

diff --git a/meta/recipes-graphics/mesa/mesa.inc b/meta/recipes-graphics/mesa/mesa.inc
index 775aab9297..dd15046438 100644
--- a/meta/recipes-graphics/mesa/mesa.inc
+++ b/meta/recipes-graphics/mesa/mesa.inc
@@ -89,6 +89,8 @@  PACKAGECONFIG = " \
 	${@bb.utils.contains('LICENSE_FLAGS_ACCEPTED', 'commercial', 'video-codecs', '', d)} \
 "
 
+PACKAGECONFIG:append:class-native = "gallium-llvm r600"
+
 # "gbm" requires "opengl"
 PACKAGECONFIG[gbm] = "-Dgbm=enabled,-Dgbm=disabled"
 
@@ -102,8 +104,10 @@  PACKAGECONFIG[dri3] = "-Ddri3=enabled, -Ddri3=disabled, xorgproto libxshmfence"
 # Vulkan drivers need dri3 enabled
 # amd could be enabled as well but requires gallium-llvm with llvm >= 3.9
 VULKAN_DRIVERS = ""
-VULKAN_DRIVERS:append:x86:class-target = ",intel"
-VULKAN_DRIVERS:append:x86-64:class-target = ",intel"
+VULKAN_DRIVERS:append:x86 = ",intel"
+VULKAN_DRIVERS:append:x86-64 = ",intel"
+# i686 is a 32 bit override for mesa-native
+VULKAN_DRIVERS:append:i686 = ",intel"
 VULKAN_DRIVERS:append ="${@bb.utils.contains('PACKAGECONFIG', 'freedreno', ',freedreno', '', d)}"
 VULKAN_DRIVERS:append ="${@bb.utils.contains('PACKAGECONFIG', 'broadcom', ',broadcom', '', d)}"
 PACKAGECONFIG[vulkan] = "-Dvulkan-drivers=${@strip_comma('${VULKAN_DRIVERS}')}, -Dvulkan-drivers='',glslang-native vulkan-loader vulkan-headers"
@@ -149,8 +153,10 @@  PACKAGECONFIG[zink] = ""
 GALLIUMDRIVERS = "swrast"
 # gallium swrast was found to crash Xorg on startup in x32 qemu
 GALLIUMDRIVERS:x86-x32 = ""
-GALLIUMDRIVERS:append:x86:class-target = ",i915,iris,crocus"
-GALLIUMDRIVERS:append:x86-64:class-target = ",i915,iris,crocus"
+GALLIUMDRIVERS:append:x86 = ",i915,iris,crocus"
+GALLIUMDRIVERS:append:x86-64 = ",i915,iris,crocus"
+# i686 is a 32 bit override for mesa-native
+GALLIUMDRIVERS:append:i686 = ",i915,iris,crocus"
 
 GALLIUMDRIVERS:append ="${@bb.utils.contains('PACKAGECONFIG', 'etnaviv', ',etnaviv', '', d)}"
 GALLIUMDRIVERS:append ="${@bb.utils.contains('PACKAGECONFIG', 'freedreno', ',freedreno', '', d)}"
@@ -162,8 +168,10 @@  GALLIUMDRIVERS:append ="${@bb.utils.contains('PACKAGECONFIG', 'zink', ',zink', '
 # radeonsi requires LLVM
 GALLIUMDRIVERS_RADEONSI = "${@bb.utils.contains('PACKAGECONFIG', 'r600', ',radeonsi', '', d)}"
 GALLIUMDRIVERS_LLVM = "r300,nouveau${GALLIUMDRIVERS_RADEONSI}"
-GALLIUMDRIVERS_LLVM:append:x86:class-target = ",svga"
-GALLIUMDRIVERS_LLVM:append:x86-64:class-target = ",svga"
+GALLIUMDRIVERS_LLVM:append:x86 = ",svga"
+GALLIUMDRIVERS_LLVM:append:x86-64 = ",svga"
+# i686 is a 32 bit override for mesa-native
+GALLIUMDRIVERS_LLVM:append:i686 = ",svga"
 
 PACKAGECONFIG[r600] = ""
 PACKAGECONFIG[virgl] = ""