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>
4 ;;; Copyright © 2018 Efraim Flashner <efraim@flashner.co.il>
6 ;;; This file is part of GNU Guix.
8 ;;; GNU Guix is free software; you can redistribute it and/or modify it
9 ;;; under the terms of the GNU General Public License as published by
10 ;;; the Free Software Foundation; either version 3 of the License, or (at
11 ;;; your option) any later version.
13 ;;; GNU Guix is distributed in the hope that it will be useful, but
14 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;;; GNU General Public License for more details.
18 ;;; You should have received a copy of the GNU General Public License
19 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21 (define-module (gnu packages vulkan)
22 #:use-module ((guix licenses) #:prefix license:)
23 #:use-module (guix packages)
24 #:use-module (guix download)
25 #:use-module (guix git-download)
26 #:use-module (guix build-system cmake)
27 #:use-module (guix build-system meson)
28 #:use-module (gnu packages)
29 #:use-module (gnu packages bison)
30 #:use-module (gnu packages cmake)
31 #:use-module (gnu packages freedesktop)
32 #:use-module (gnu packages gl)
33 #:use-module (gnu packages pkg-config)
34 #:use-module (gnu packages python)
35 #:use-module (gnu packages xorg))
37 (define-public spirv-headers
38 ;; Keep updated in accordance with
39 ;; https://github.com/google/shaderc/blob/known-good/known_good.json
40 (let ((commit "061097878467b8e040fbf153a837d844ef9f9f96")
43 (name "spirv-headers")
44 (version (string-append "0.0-" revision "." (string-take commit 9)))
49 (url "https://github.com/KhronosGroup/SPIRV-Headers")
53 "0bf9h6xc5fkncxnadwmqvpsjh7sdgns6is8prv1gvlfzrkvpjj17"))
54 (file-name (string-append name "-" version "-checkout"))))
55 (build-system cmake-build-system)
57 `(#:tests? #f ;; No tests
58 #:phases (modify-phases %standard-phases
60 (lambda* (#:key outputs #:allow-other-keys)
61 (zero? (system* "cmake" "-E" "copy_directory"
62 "../source/include/spirv"
63 (string-append (assoc-ref outputs "out")
64 "/include/spirv"))))))))
65 (home-page "https://github.com/KhronosGroup/SPIRV-Headers")
66 (synopsis "Machine-readable files from the SPIR-V Registry")
68 "SPIRV-Headers is a repository containing machine-readable files from
69 the SPIR-V Registry. This includes:
71 @item Header files for various languages.
72 @item JSON files describing the grammar for the SPIR-V core instruction set,
73 and for the GLSL.std.450 extended instruction set.
74 @item The XML registry file.
76 (license (license:x11-style
77 (string-append "https://github.com/KhronosGroup/SPIRV-Headers/blob/"
78 commit "/LICENSE"))))))
80 (define-public spirv-tools
81 ;; Keep updated in accordance with
82 ;; https://github.com/google/shaderc/blob/known-good/known_good.json
83 (let ((commit "90862fe4b1c6763b32ce683d2d32c2f281f577cf")
87 (version (string-append "0.0-" revision "." (string-take commit 9)))
92 (url "https://github.com/KhronosGroup/SPIRV-Tools")
96 "1yq8ab6f52wcxm2azzmx70nqz8l35izd45830aikjkk1jfzmzabb"))
97 (file-name (string-append name "-" version "-checkout"))))
98 (build-system cmake-build-system)
100 `(#:configure-flags (list (string-append "-DCMAKE_INSTALL_LIBDIR="
101 (assoc-ref %outputs "out")
103 (string-append "-DSPIRV-Headers_SOURCE_DIR="
104 (assoc-ref %build-inputs
106 (inputs `(("spirv-headers" ,spirv-headers)))
107 (native-inputs `(("pkg-config" ,pkg-config)
109 (home-page "https://github.com/KhronosGroup/SPIRV-Tools")
110 (synopsis "API and commands for processing SPIR-V modules")
112 "The SPIR-V Tools project provides an API and commands for processing
113 SPIR-V modules. The project includes an assembler, binary module parser,
114 disassembler, validator, and optimizer for SPIR-V.")
115 (license license:asl2.0))))
117 (define-public glslang
118 ;; Keep updated in accordance with
119 ;; https://github.com/google/shaderc/blob/known-good/known_good.json
120 (let ((commit "b5b08462442239e6537315ea1405b6afcd53043e")
124 (version (string-append "3.0-" revision "." (string-take commit 9)))
129 (url "https://github.com/KhronosGroup/glslang")
133 "08imby3hciisshzacrkx8s56lx4fxm7dad06xxaxxcapinmqrvwk"))
134 (file-name (string-append name "-" version "-checkout"))))
135 (build-system cmake-build-system)
137 `(#:tests? #f ;; No tests
138 ;; glslang tries to set CMAKE_INSTALL_PREFIX manually. Remove the
140 #:phases (modify-phases %standard-phases
141 (add-after 'patch-source-shebangs 'fix-cmakelists
143 (substitute* "CMakeLists.txt"
144 (("set.*CMAKE_INSTALL_PREFIX.*") ""))
146 (native-inputs `(("bison" ,bison)
147 ("pkg-config" ,pkg-config)))
148 (home-page "https://github.com/KhronosGroup/glslang")
149 (synopsis "OpenGL and OpenGL ES shader front end and validator")
151 "Glslang is the official reference compiler front end for the
152 OpenGL@tie{}ES and OpenGL shading languages. It implements a strict
153 interpretation of the specifications for these languages.")
154 ;; Modified BSD license. See "copyright" section of
155 ;; https://www.khronos.org/opengles/sdk/tools/Reference-Compiler/
156 (license (list license:bsd-3
157 ;; include/SPIRV/{bitutils,hex_float}.h are Apache 2.0.
160 (define-public vulkan-icd-loader
162 (name "vulkan-icd-loader")
168 "https://github.com/KhronosGroup/Vulkan-LoaderAndValidationLayers/"
169 "archive/sdk-" version ".tar.gz"))
172 "1qb34j2zrc04fgs96m3k76vi4nx3sygbdcyg7pbwasr45cbdhsxb"))))
173 (build-system cmake-build-system)
175 `(#:tests? #f ;FIXME: 23/39 tests fail. Try "tests/run_all_tests.sh".
177 (modify-phases %standard-phases
178 (add-after 'unpack 'remove-spirv-tools-commit-id
179 (lambda* (#:key inputs #:allow-other-keys)
180 ;; Remove lines trying to build in a git commit id.
181 (substitute* "CMakeLists.txt" ((".*spirv_tools_commit_id.h.*") ""))
183 #:configure-flags (list
184 "-DBUILD_LAYERS=OFF" ; FIXME: Fails to build.
185 "-DBUILD_TESTS=OFF" ; FIXME: Needs 'googletest' submodule.
186 (string-append "-DCMAKE_INSTALL_LIBDIR="
187 (assoc-ref %outputs "out") "/lib"))))
188 (inputs `(("glslang" ,glslang)
191 ("libxrandr" ,libxrandr)
193 ("spirv-tools" ,spirv-tools)
194 ("wayland" ,wayland)))
195 (native-inputs `(("pkg-config" ,pkg-config)
198 "https://github.com/KhronosGroup/Vulkan-LoaderAndValidationLayers")
199 (synopsis "Khronos official ICD loader and validation layers for Vulkan")
201 "Vulkan allows multiple @dfn{Installable Client Drivers} (ICDs) each
202 supporting one or more devices to be used collectively. The loader is
203 responsible for discovering available Vulkan ICDs on the system and inserting
204 Vulkan layer libraries, including validation layers between the application
206 ;; This software is mainly Apache 2.0 licensed, but contains some components
207 ;; covered by other licenses. See COPYRIGHT.txt for details.
208 (license (list license:asl2.0 ;LICENSE.txt
209 (license:x11-style "file://COPYRIGHT.txt")
212 (define-public shaderc
213 (let ((commit "773ec22d49f40b7161820f29d953be4a7e40190d")
217 (version (git-version "0.0.0" revision commit))
222 (url "https://github.com/google/shaderc")
224 (file-name (string-append name "-" version ".tar.gz"))
227 "0b41inb1czxv3mciip0lfdxv19ccx2ys31fivfywjn2q8va1gd1f"))))
228 (build-system meson-build-system)
230 `(#:tests? #f ; tests don't work yet.
232 (modify-phases %standard-phases
234 (lambda* (#:key outputs #:allow-other-keys)
235 (let ((out (assoc-ref outputs "out")))
236 ;; Remove various lines and touch build-version.inc or
237 ;; configuring won't work.
238 (invoke "touch" "glslc/src/build-version.inc")
239 (substitute* "CMakeLists.txt" (("..PYTHON_EXE..*") ""))
240 (substitute* "CMakeLists.txt"
241 ((".*update_build_version.py..*") ""))
242 (substitute* "CMakeLists.txt"
243 ((".*add_custom_target.build-version.*") ""))
244 (substitute* "CMakeLists.txt"
245 ((".*spirv-tools_SOURCE_DIR.*glslang_SOURCE_DIR.*")
247 (substitute* "CMakeLists.txt"
248 ((".*Update build-version.inc.*") ""))
249 (substitute* "CMakeLists.txt" ((".*--check.*") ""))
250 (substitute* "glslc/src/main.cc" ((".*build-version.inc.*")
252 (invoke "cmake" "-GNinja" "-DCMAKE_BUILD_TYPE=Release"
253 "-DSHADERC_SKIP_TESTS=ON"
254 "-DCMAKE_INSTALL_LIBDIR=lib"
255 (string-append "-DCMAKE_INSTALL_PREFIX="
257 (add-after 'unpack 'unpack-sources
258 (lambda* (#:key inputs #:allow-other-keys)
259 (let ((spirv-tools-source (assoc-ref inputs "spirv-tools-source"))
260 (spirv-headers-source (assoc-ref inputs "spirv-headers-source"))
261 (glslang-source (assoc-ref inputs "glslang-source")))
262 (copy-recursively spirv-tools-source "third_party/spirv-tools")
263 (copy-recursively spirv-headers-source
264 (string-append "third_party/spirv-tools"
265 "/external/spirv-headers"))
266 (copy-recursively glslang-source "third_party/glslang")
269 `(("python" ,python)))
272 ("glslang-source" ,(package-source glslang))
273 ("pkg-config" ,pkg-config)
274 ("spirv-headers-source" ,(package-source spirv-headers))
275 ("spirv-tools-source" ,(package-source spirv-tools))))
276 (home-page "https://github.com/google/shaderc")
277 (synopsis "Tools for shader compilation")
278 (description "Shaderc is a collection of tools, libraries, and tests for
279 shader compilation.")
280 (license license:asl2.0))))