[PATCH] gnu: mesa: Add native-search-paths.

  • Open
  • quality assurance status badge
Details
3 participants
  • David Elsing
  • dan
  • John Kehayias
Owner
unassigned
Submitted by
dan
Severity
normal
D
(address . guix-patches@gnu.org)
20230808180851.32652-1-i@dan.games
* gnu/packages/gl.scm (mesa) [native-search-paths]: Export XDG_DATA_DIRS.

According to
Vulkan loader search for manifest files in several directories. Some of them
are in the $HOME directory, some of them are set during compile-time. We
don't raelly want vulkan-loader to depend on mesa during compile-time, since
we couldn't assume that mesa is the only package providing Vulkan drivers.
Thus, it's better for us to export XDG_DATA_DIRS in mesa, so that when both
packages are installed, Vulkan loader could find the corresponding Vulkan
drivers by environment varaible.

---
gnu/packages/gl.scm | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

Toggle diff (29 lines)
diff --git a/gnu/packages/gl.scm b/gnu/packages/gl.scm
index b53b42a9ba..583cd5a945 100644
--- a/gnu/packages/gl.scm
+++ b/gnu/packages/gl.scm
@@ -18,6 +18,7 @@
;;; Copyright © 2021, 2022, 2023 John Kehayias <john.kehayias@protonmail.com>
;;; Copyright © 2022 Petr Hodina <phodina@protonmail.com>
;;; Copyright © 2023 Kaelyn Takata <kaelyn.alexi@protonmail.com>
+;;; Copyright © 2023 dan <i@dan.games>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -518,7 +519,11 @@ (define-public mesa
;; Ensure the Mesa VDPAU drivers can be found.
(variable "VDPAU_DRIVER_PATH")
(separator #f)
- (files '("lib/vdpau")))))
+ (files '("lib/vdpau")))
+ (search-path-specification
+ ;; Ensure the Vulkan drivers can be found by Vulkan loader.
+ (variable "XDG_DATA_DIRS")
+ (files '("share")))))
(home-page "https://mesa3d.org/")
(synopsis "OpenGL and Vulkan implementations")
(description "Mesa is a free implementation of the OpenGL and Vulkan

base-commit: 4547bc6fa3142dca77f7fc912368aeff31bd6e53
--
2.41.0
J
J
John Kehayias wrote on 28 Nov 2023 06:54
(name . dan)(address . i@dan.games)(address . 65155@debbugs.gnu.org)
87msuy8lte.fsf@protonmail.com
Hi,

Sorry for the long overdue reply here.

On Wed, Aug 09, 2023 at 02:08 AM, dan wrote:

Toggle quote (13 lines)
> * gnu/packages/gl.scm (mesa) [native-search-paths]: Export XDG_DATA_DIRS.
>
> According to
> https://vulkan.lunarg.com/doc/view/1.3.231.1/linux/loader_and_layer_interface.html,
> Vulkan loader search for manifest files in several directories. Some of them
> are in the $HOME directory, some of them are set during compile-time. We
> don't raelly want vulkan-loader to depend on mesa during compile-time, since
> we couldn't assume that mesa is the only package providing Vulkan drivers.
> Thus, it's better for us to export XDG_DATA_DIRS in mesa, so that when both
> packages are installed, Vulkan loader could find the corresponding Vulkan
> drivers by environment varaible.
>

I'm not sure if this patch does what you intend. A search-path is
defined in the package that consumes the path, meaning the package that
looks there for something. The environment variable is then set whenever
there is package also in the profile that populates the specified
directory.

So perhaps this belongs in vulkan-loader? Although I admit I'm less sure
for XDG_* related paths. Is there a test case or something we can see if
this does what is intended for vulkan?

(This did not make it into the just merged mesa-updates but happy to do
it on the next round, which could also include changes to vulkan
packages if they need a branch.)

Apologies for the wait on this one, since I had looked at it a while
ago!

John

Toggle quote (31 lines)
> ---
> gnu/packages/gl.scm | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/gnu/packages/gl.scm b/gnu/packages/gl.scm
> index b53b42a9ba..583cd5a945 100644
> --- a/gnu/packages/gl.scm
> +++ b/gnu/packages/gl.scm
> @@ -18,6 +18,7 @@
> ;;; Copyright © 2021, 2022, 2023 John Kehayias <john.kehayias@protonmail.com>
> ;;; Copyright © 2022 Petr Hodina <phodina@protonmail.com>
> ;;; Copyright © 2023 Kaelyn Takata <kaelyn.alexi@protonmail.com>
> +;;; Copyright © 2023 dan <i@dan.games>
> ;;;
> ;;; This file is part of GNU Guix.
> ;;;
> @@ -518,7 +519,11 @@ (define-public mesa
> ;; Ensure the Mesa VDPAU drivers can be found.
> (variable "VDPAU_DRIVER_PATH")
> (separator #f)
> - (files '("lib/vdpau")))))
> + (files '("lib/vdpau")))
> + (search-path-specification
> + ;; Ensure the Vulkan drivers can be found by Vulkan loader.
> + (variable "XDG_DATA_DIRS")
> + (files '("share")))))
> (home-page "https://mesa3d.org/")
> (synopsis "OpenGL and Vulkan implementations")
> (description "Mesa is a free implementation of the OpenGL and Vulkan
>
> base-commit: 4547bc6fa3142dca77f7fc912368aeff31bd6e53
D
D
David Elsing wrote on 11 Feb 18:36 +0100
(name . John Kehayias)(address . john.kehayias@protonmail.com)
86jznanbrf.fsf@posteo.net
Hello,

John Kehayias <john.kehayias@protonmail.com> writes:

Toggle quote (4 lines)
> So perhaps this belongs in vulkan-loader? Although I admit I'm less sure
> for XDG_* related paths. Is there a test case or something we can see if
> this does what is intended for vulkan?

I also noticed the same problem and agree that the search path belongs
in the vulkan-loader package:

Toggle snippet (18 lines)
diff --git a/gnu/packages/vulkan.scm b/gnu/packages/vulkan.scm
index 285d6be7f5..98ce979652 100644
--- a/gnu/packages/vulkan.scm
+++ b/gnu/packages/vulkan.scm
@@ -303,6 +303,11 @@ (define-public vulkan-loader
wayland))
(inputs
(list vulkan-headers libxrandr))
+ (native-search-paths
+ (list
+ (search-path-specification
+ (variable "XDG_DATA_DIRS")
+ (files '("share")))))
(home-page
"https://github.com/KhronosGroup/Vulkan-Loader")
(synopsis "Khronos official ICD loader and validation layers for Vulkan")

I tested it with
Toggle snippet (2 lines)
guix shell -C vulkan-tools vulkan-loader mesa --no-grafts -- vulkaninfo
which works with the patch applied. As documented in [1], vulkan-loader
still needs to be part of the profile for the search path to take effect.

Cheers,
David

?