gnu: Fix common unquote typos.
[jackhill/guix/guix.git] / gnu / packages / vulkan.scm
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 ;;;
5 ;;; This file is part of GNU Guix.
6 ;;;
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.
11 ;;;
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.
16 ;;;
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/>.
19
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))
35
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")
40 (revision "2"))
41 (package
42 (name "spirv-headers")
43 (version (string-append "0.0-" revision "." (string-take commit 9)))
44 (source
45 (origin
46 (method git-fetch)
47 (uri (git-reference
48 (url "https://github.com/KhronosGroup/SPIRV-Headers")
49 (commit commit)))
50 (sha256
51 (base32
52 "0bf9h6xc5fkncxnadwmqvpsjh7sdgns6is8prv1gvlfzrkvpjj17"))
53 (file-name (string-append name "-" version "-checkout"))))
54 (build-system cmake-build-system)
55 (arguments
56 `(#:tests? #f ;; No tests
57 #:phases (modify-phases %standard-phases
58 (replace 'install
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")
66 (description
67 "SPIRV-Headers is a repository containing machine-readable files from
68 the SPIR-V Registry. This includes:
69 @itemize
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.
74 @end itemize\n")
75 (license (license:x11-style
76 (string-append "https://github.com/KhronosGroup/SPIRV-Headers/blob/"
77 commit "/LICENSE"))))))
78
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")
83 (revision "1"))
84 (package
85 (name "spirv-tools")
86 (version (string-append "0.0-" revision "." (string-take commit 9)))
87 (source
88 (origin
89 (method git-fetch)
90 (uri (git-reference
91 (url "https://github.com/KhronosGroup/SPIRV-Tools")
92 (commit commit)))
93 (sha256
94 (base32
95 "1yq8ab6f52wcxm2azzmx70nqz8l35izd45830aikjkk1jfzmzabb"))
96 (file-name (string-append name "-" version "-checkout"))))
97 (build-system cmake-build-system)
98 (arguments
99 `(#:configure-flags (list (string-append "-DCMAKE_INSTALL_LIBDIR="
100 (assoc-ref %outputs "out")
101 "/lib")
102 (string-append "-DSPIRV-Headers_SOURCE_DIR="
103 (assoc-ref %build-inputs
104 "spirv-headers")))))
105 (inputs `(("spirv-headers" ,spirv-headers)))
106 (native-inputs `(("pkg-config" ,pkg-config)
107 ("python" ,python)))
108 (home-page "https://github.com/KhronosGroup/SPIRV-Tools")
109 (synopsis "API and commands for processing SPIR-V modules")
110 (description
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))))
115
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")
120 (revision "2"))
121 (package
122 (name "glslang")
123 (version (string-append "3.0-" revision "." (string-take commit 9)))
124 (source
125 (origin
126 (method git-fetch)
127 (uri (git-reference
128 (url "https://github.com/KhronosGroup/glslang")
129 (commit commit)))
130 (sha256
131 (base32
132 "08imby3hciisshzacrkx8s56lx4fxm7dad06xxaxxcapinmqrvwk"))
133 (file-name (string-append name "-" version "-checkout"))))
134 (build-system cmake-build-system)
135 (arguments
136 `(#:tests? #f ;; No tests
137 ;; glslang tries to set CMAKE_INSTALL_PREFIX manually. Remove the
138 ;; offending line.
139 #:phases (modify-phases %standard-phases
140 (add-after 'patch-source-shebangs 'fix-cmakelists
141 (lambda _
142 (substitute* "CMakeLists.txt"
143 (("set.*CMAKE_INSTALL_PREFIX.*") ""))
144 #t)))))
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")
149 (description
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.
157 license:asl2.0)))))
158
159 (define-public vulkan-icd-loader
160 (package
161 (name "vulkan-icd-loader")
162 (version "1.1.70.0")
163 (source
164 (origin
165 (method url-fetch)
166 (uri (string-append
167 "https://github.com/KhronosGroup/Vulkan-LoaderAndValidationLayers/"
168 "archive/sdk-" version ".tar.gz"))
169 (sha256
170 (base32
171 "15qkh77596v3xivnbb3l0q9zbmmsdglnaza2m1g7f8q7bbigyc5x"))))
172 (build-system cmake-build-system)
173 (arguments
174 `(#:tests? #f ;FIXME: 23/39 tests fail. Try "tests/run_all_tests.sh".
175 #:phases
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.*") ""))
181 #t)))
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)
187 ("libxcb" ,libxcb)
188 ("libx11" ,libx11)
189 ("libxrandr" ,libxrandr)
190 ("mesa" ,mesa)
191 ("spirv-tools" ,spirv-tools)
192 ("wayland" ,wayland)))
193 (native-inputs `(("pkg-config" ,pkg-config)
194 ("python" ,python)))
195 (home-page
196 "https://github.com/KhronosGroup/Vulkan-LoaderAndValidationLayers")
197 (synopsis "Khronos official ICD loader and validation layers for Vulkan")
198 (description
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
203 and the ICD.")
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")
208 license:bsd-3))))
209
210 (define-public shaderc
211 (let ((commit "773ec22d49f40b7161820f29d953be4a7e40190d")
212 (revision "1"))
213 (package
214 (name "shaderc")
215 (version (git-version "0.0.0-" revision commit))
216 (source
217 (origin
218 (method git-fetch)
219 (uri (git-reference
220 (url "https://github.com/google/shaderc")
221 (commit commit)))
222 (file-name (string-append name "-" version ".tar.gz"))
223 (sha256
224 (base32
225 "0b41inb1czxv3mciip0lfdxv19ccx2ys31fivfywjn2q8va1gd1f"))))
226 (build-system meson-build-system)
227 (arguments
228 `(#:build-type "Release"
229 #:configure-flags
230 (list "-GNinja"
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.
236 #:phases
237 (modify-phases %standard-phases
238 (replace 'configure
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.*")
251 ""))
252 (substitute* "CMakeLists.txt"
253 ((".*Update build-version.inc.*") ""))
254 (substitute* "CMakeLists.txt" ((".*--check.*") ""))
255 (substitute* "glslc/src/main.cc" ((".*build-version.inc.*")
256 "\"1\""))
257 (invoke "cmake" (cons build-type configure-flags))
258 #t)))
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
266 "glslang-source")))
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")
277 #t))))))
278 (inputs
279 `(("python" ,python)))
280 (native-inputs
281 `(("cmake" ,cmake)
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))))