1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2017, 2018 Rutger Helling <rhelling@mykolab.com>
3 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
5 ;;; This file is part of GNU Guix.
7 ;;; GNU Guix is free software; you can redistribute it and/or modify it
8 ;;; under the terms of the GNU General Public License as published by
9 ;;; the Free Software Foundation; either version 3 of the License, or (at
10 ;;; your option) any later version.
12 ;;; GNU Guix is distributed in the hope that it will be useful, but
13 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;;; GNU General Public License for more details.
17 ;;; You should have received a copy of the GNU General Public License
18 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20 (define-module (gnu packages vulkan)
21 #:use-module ((guix licenses) #:prefix license:)
22 #:use-module (guix packages)
23 #:use-module (guix download)
24 #:use-module (guix git-download)
25 #:use-module (guix build-system cmake)
26 #:use-module (guix build-system meson)
27 #:use-module (gnu packages)
28 #:use-module (gnu packages bison)
29 #:use-module (gnu packages cmake)
30 #:use-module (gnu packages freedesktop)
31 #:use-module (gnu packages gl)
32 #:use-module (gnu packages pkg-config)
33 #:use-module (gnu packages python)
34 #:use-module (gnu packages xorg))
36 (define-public spirv-headers
37 ;; Keep updated in accordance with
38 ;; https://github.com/google/shaderc/blob/known-good/known_good.json
39 (let ((commit "061097878467b8e040fbf153a837d844ef9f9f96")
42 (name "spirv-headers")
43 (version (string-append "0.0-" revision "." (string-take commit 9)))
48 (url "https://github.com/KhronosGroup/SPIRV-Headers")
52 "0bf9h6xc5fkncxnadwmqvpsjh7sdgns6is8prv1gvlfzrkvpjj17"))
53 (file-name (string-append name "-" version "-checkout"))))
54 (build-system cmake-build-system)
56 `(#:tests? #f ;; No tests
57 #:phases (modify-phases %standard-phases
59 (lambda* (#:key outputs #:allow-other-keys)
60 (zero? (system* "cmake" "-E" "copy_directory"
61 "../source/include/spirv"
62 (string-append (assoc-ref outputs "out")
63 "/include/spirv"))))))))
64 (home-page "https://github.com/KhronosGroup/SPIRV-Headers")
65 (synopsis "Machine-readable files from the SPIR-V Registry")
67 "SPIRV-Headers is a repository containing machine-readable files from
68 the SPIR-V Registry. This includes:
70 @item Header files for various languages.
71 @item JSON files describing the grammar for the SPIR-V core instruction set,
72 and for the GLSL.std.450 extended instruction set.
73 @item The XML registry file.
75 (license (license:x11-style
76 (string-append "https://github.com/KhronosGroup/SPIRV-Headers/blob/"
77 commit "/LICENSE"))))))
79 (define-public spirv-tools
80 ;; Keep updated in accordance with
81 ;; https://github.com/google/shaderc/blob/known-good/known_good.json
82 (let ((commit "90862fe4b1c6763b32ce683d2d32c2f281f577cf")
86 (version (string-append "0.0-" revision "." (string-take commit 9)))
91 (url "https://github.com/KhronosGroup/SPIRV-Tools")
95 "1yq8ab6f52wcxm2azzmx70nqz8l35izd45830aikjkk1jfzmzabb"))
96 (file-name (string-append name "-" version "-checkout"))))
97 (build-system cmake-build-system)
99 `(#:configure-flags (list (string-append "-DCMAKE_INSTALL_LIBDIR="
100 (assoc-ref %outputs "out")
102 (string-append "-DSPIRV-Headers_SOURCE_DIR="
103 (assoc-ref %build-inputs
105 (inputs `(("spirv-headers" ,spirv-headers)))
106 (native-inputs `(("pkg-config" ,pkg-config)
108 (home-page "https://github.com/KhronosGroup/SPIRV-Tools")
109 (synopsis "API and commands for processing SPIR-V modules")
111 "The SPIR-V Tools project provides an API and commands for processing
112 SPIR-V modules. The project includes an assembler, binary module parser,
113 disassembler, validator, and optimizer for SPIR-V.")
114 (license license:asl2.0))))
116 (define-public glslang
117 ;; Keep updated in accordance with
118 ;; https://github.com/google/shaderc/blob/known-good/known_good.json
119 (let ((commit "b5b08462442239e6537315ea1405b6afcd53043e")
123 (version (string-append "3.0-" revision "." (string-take commit 9)))
128 (url "https://github.com/KhronosGroup/glslang")
132 "08imby3hciisshzacrkx8s56lx4fxm7dad06xxaxxcapinmqrvwk"))
133 (file-name (string-append name "-" version "-checkout"))))
134 (build-system cmake-build-system)
136 `(#:tests? #f ;; No tests
137 ;; glslang tries to set CMAKE_INSTALL_PREFIX manually. Remove the
139 #:phases (modify-phases %standard-phases
140 (add-after 'patch-source-shebangs 'fix-cmakelists
142 (substitute* "CMakeLists.txt"
143 (("set.*CMAKE_INSTALL_PREFIX.*") ""))
145 (native-inputs `(("bison" ,bison)
146 ("pkg-config" ,pkg-config)))
147 (home-page "https://github.com/KhronosGroup/glslang")
148 (synopsis "OpenGL and OpenGL ES shader front end and validator")
150 "Glslang is the official reference compiler front end for the
151 OpenGL@tie{}ES and OpenGL shading languages. It implements a strict
152 interpretation of the specifications for these languages.")
153 ;; Modified BSD license. See "copyright" section of
154 ;; https://www.khronos.org/opengles/sdk/tools/Reference-Compiler/
155 (license (list license:bsd-3
156 ;; include/SPIRV/{bitutils,hex_float}.h are Apache 2.0.
159 (define-public vulkan-icd-loader
161 (name "vulkan-icd-loader")
167 "https://github.com/KhronosGroup/Vulkan-LoaderAndValidationLayers/"
168 "archive/sdk-" version ".tar.gz"))
171 "15qkh77596v3xivnbb3l0q9zbmmsdglnaza2m1g7f8q7bbigyc5x"))))
172 (build-system cmake-build-system)
174 `(#:tests? #f ;FIXME: 23/39 tests fail. Try "tests/run_all_tests.sh".
176 (modify-phases %standard-phases
177 (add-after 'unpack 'remove-spirv-tools-commit-id
178 (lambda* (#:key inputs #:allow-other-keys)
179 ;; Remove lines trying to build in a git commit id.
180 (substitute* "CMakeLists.txt" ((".*spirv_tools_commit_id.h.*") ""))
182 #:configure-flags (list
183 "-DBUILD_LAYERS=OFF" ; FIXME: Fails to build.
184 (string-append "-DCMAKE_INSTALL_LIBDIR="
185 (assoc-ref %outputs "out") "/lib"))))
186 (inputs `(("glslang" ,glslang)
189 ("libxrandr" ,libxrandr)
191 ("spirv-tools" ,spirv-tools)
192 ("wayland" ,wayland)))
193 (native-inputs `(("pkg-config" ,pkg-config)
196 "https://github.com/KhronosGroup/Vulkan-LoaderAndValidationLayers")
197 (synopsis "Khronos official ICD loader and validation layers for Vulkan")
199 "Vulkan allows multiple @dfn{Installable Client Drivers} (ICDs) each
200 supporting one or more devices to be used collectively. The loader is
201 responsible for discovering available Vulkan ICDs on the system and inserting
202 Vulkan layer libraries, including validation layers between the application
204 ;; This software is mainly Apache 2.0 licensed, but contains some components
205 ;; covered by other licenses. See COPYRIGHT.txt for details.
206 (license (list license:asl2.0 ;LICENSE.txt
207 (license:x11-style "file://COPYRIGHT.txt")
210 (define-public shaderc
211 (let ((commit "773ec22d49f40b7161820f29d953be4a7e40190d")
215 (version (git-version "0.0.0-" revision commit))
220 (url "https://github.com/google/shaderc")
222 (file-name (string-append name "-" version ".tar.gz"))
225 "0b41inb1czxv3mciip0lfdxv19ccx2ys31fivfywjn2q8va1gd1f"))))
226 (build-system meson-build-system)
228 `(#:build-type "Release"
231 "-DSHADERC_SKIP_TESTS=ON"
232 "-DCMAKE_INSTALL_LIBDIR=lib"
233 (string-append "-DCMAKE_INSTALL_PREFIX="
234 (assoc-ref %outputs "out")))
235 #:tests? #f ; tests don't work yet.
237 (modify-phases %standard-phases
239 (lambda* (#:key build-type configure-flags #:allow-other-keys)
240 (let ((out (assoc-ref outputs "out")))
241 ;; Remove various lines and touch build-version.inc or
242 ;; configuring won't work.
243 (invoke "touch" "glslc/src/build-version.inc")
244 (substitute* "CMakeLists.txt" (("..PYTHON_EXE..*") ""))
245 (substitute* "CMakeLists.txt"
246 ((".*update_build_version.py..*") ""))
247 (substitute* "CMakeLists.txt"
248 ((".*add_custom_target.build-version.*") ""))
249 (substitute* "CMakeLists.txt"
250 ((".*spirv-tools_SOURCE_DIR.*glslang_SOURCE_DIR.*")
252 (substitute* "CMakeLists.txt"
253 ((".*Update build-version.inc.*") ""))
254 (substitute* "CMakeLists.txt" ((".*--check.*") ""))
255 (substitute* "glslc/src/main.cc" ((".*build-version.inc.*")
257 (invoke "cmake" (cons build-type configure-flags))
259 (add-after 'unpack 'unpack-sources
260 (lambda* (#:key inputs #:allow-other-keys)
261 (let ((spirv-tools-source (assoc-ref %build-inputs
262 "spirv-tools-source"))
263 (spirv-headers-source (assoc-ref %build-inputs
264 "spirv-headers-source"))
265 (glslang-source (assoc-ref %build-inputs
267 (mkdir-p "third-party/spirv-tools")
268 (copy-recursively spirv-tools-source
269 "third_party/spirv-tools")
270 (mkdir-p "third-party/spirv-tools/external/spirv-headers")
271 (copy-recursively spirv-headers-source
272 (string-append "third_party/spirv-tools"
273 "/external/spirv-headers"))
274 (mkdir-p "third-party/glslang")
275 (copy-recursively glslang-source
276 "third_party/glslang")
279 `(("python" ,python)))
282 ("glslang-source" ,(package-source glslang))
283 ("pkg-config" ,pkg-config)
284 ("spirv-headers-source" ,(package-source spirv-headers))
285 ("spirv-tools-source" ,(package-source spirv-tools))))
286 (home-page "https://github.com/google/shaderc")
287 (synopsis "Tools for shader compilation")
288 (description "Shaderc is a collection of tools, libraries, and tests for
289 shader compilation.")
290 (license license:asl2.0))))