gnu: nnn: Don't use NAME in source URI.
[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 ;;; Copyright © 2018 Efraim Flashner <efraim@flashner.co.il>
5 ;;;
6 ;;; This file is part of GNU Guix.
7 ;;;
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.
12 ;;;
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.
17 ;;;
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/>.
20
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 gnu)
28 #:use-module (guix build-system meson)
29 #:use-module (gnu packages)
30 #:use-module (gnu packages autotools)
31 #:use-module (gnu packages bison)
32 #:use-module (gnu packages check)
33 #:use-module (gnu packages cmake)
34 #:use-module (gnu packages freedesktop)
35 #:use-module (gnu packages gettext)
36 #:use-module (gnu packages gl)
37 #:use-module (gnu packages pkg-config)
38 #:use-module (gnu packages python)
39 #:use-module (gnu packages wine)
40 #:use-module (gnu packages xorg))
41
42 (define-public spirv-headers
43 ;; Keep updated in accordance with
44 ;; https://github.com/google/shaderc/blob/known-good/known_good.json
45 (let ((commit "3ce3e49d73b8abbf2ffe33f829f941fb2a40f552")
46 (revision "3"))
47 (package
48 (name "spirv-headers")
49 (version (string-append "0.0-" revision "." (string-take commit 9)))
50 (source
51 (origin
52 (method git-fetch)
53 (uri (git-reference
54 (url "https://github.com/KhronosGroup/SPIRV-Headers")
55 (commit commit)))
56 (sha256
57 (base32
58 "0yk4bzqifdqpmdxkhvrxbdqhf5ngkga0ig1yyz7khr7rklqfz7wp"))
59 (file-name (string-append name "-" version "-checkout"))))
60 (build-system cmake-build-system)
61 (arguments
62 `(#:tests? #f ;; No tests
63 #:phases (modify-phases %standard-phases
64 (replace 'install
65 (lambda* (#:key outputs #:allow-other-keys)
66 (invoke "cmake" "-E" "copy_directory"
67 "../source/include/spirv"
68 (string-append (assoc-ref outputs "out")
69 "/include/spirv")))))))
70 (home-page "https://github.com/KhronosGroup/SPIRV-Headers")
71 (synopsis "Machine-readable files from the SPIR-V Registry")
72 (description
73 "SPIRV-Headers is a repository containing machine-readable files from
74 the SPIR-V Registry. This includes:
75 @itemize
76 @item Header files for various languages.
77 @item JSON files describing the grammar for the SPIR-V core instruction set,
78 and for the GLSL.std.450 extended instruction set.
79 @item The XML registry file.
80 @end itemize\n")
81 (license (license:x11-style
82 (string-append "https://github.com/KhronosGroup/SPIRV-Headers/blob/"
83 commit "/LICENSE"))))))
84
85 (define-public spirv-tools
86 ;; Keep updated in accordance with
87 ;; https://github.com/google/shaderc/blob/known-good/known_good.json
88 (let ((commit "fe2fbee294a8ad4434f828a8b4d99eafe9aac88c")
89 (revision "2"))
90 (package
91 (name "spirv-tools")
92 (version (string-append "0.0-" revision "." (string-take commit 9)))
93 (source
94 (origin
95 (method git-fetch)
96 (uri (git-reference
97 (url "https://github.com/KhronosGroup/SPIRV-Tools")
98 (commit commit)))
99 (sha256
100 (base32
101 "03rq4ypwqnz34n8ip85n95a3b9rxb34j26azzm3b3invaqchv19x"))
102 (file-name (string-append name "-" version "-checkout"))))
103 (build-system cmake-build-system)
104 (arguments
105 `(#:tests? #f ; FIXME: Tests fail.
106 #:configure-flags (list (string-append "-DSPIRV-Headers_SOURCE_DIR="
107 (assoc-ref %build-inputs
108 "spirv-headers")))))
109 (inputs `(("spirv-headers" ,spirv-headers)))
110 (native-inputs `(("pkg-config" ,pkg-config)
111 ("python" ,python)))
112 (home-page "https://github.com/KhronosGroup/SPIRV-Tools")
113 (synopsis "API and commands for processing SPIR-V modules")
114 (description
115 "The SPIR-V Tools project provides an API and commands for processing
116 SPIR-V modules. The project includes an assembler, binary module parser,
117 disassembler, validator, and optimizer for SPIR-V.")
118 (license license:asl2.0))))
119
120 (define-public glslang
121 ;; Keep updated in accordance with
122 ;; https://github.com/google/shaderc/blob/known-good/known_good.json
123 (let ((commit "32d3ec319909fcad0b2b308fe1635198773e8316")
124 (revision "3"))
125 (package
126 (name "glslang")
127 (version (string-append "3.0-" revision "." (string-take commit 9)))
128 (source
129 (origin
130 (method git-fetch)
131 (uri (git-reference
132 (url "https://github.com/KhronosGroup/glslang")
133 (commit commit)))
134 (sha256
135 (base32
136 "1kmgjv5kbrjy6azpgwnjcn3cj8vg5i8hnyk3m969sc0gq2j1rbjj"))
137 (file-name (string-append name "-" version "-checkout"))))
138 (build-system cmake-build-system)
139 (arguments
140 `(#:tests? #f ;; No tests
141 ;; glslang tries to set CMAKE_INSTALL_PREFIX manually. Remove the
142 ;; offending line.
143 #:phases (modify-phases %standard-phases
144 (add-after 'patch-source-shebangs 'fix-cmakelists
145 (lambda _
146 (substitute* "CMakeLists.txt"
147 (("set.*CMAKE_INSTALL_PREFIX.*") ""))
148 #t)))))
149 (native-inputs `(("bison" ,bison)
150 ("pkg-config" ,pkg-config)))
151 (home-page "https://github.com/KhronosGroup/glslang")
152 (synopsis "OpenGL and OpenGL ES shader front end and validator")
153 (description
154 "Glslang is the official reference compiler front end for the
155 OpenGL@tie{}ES and OpenGL shading languages. It implements a strict
156 interpretation of the specifications for these languages.")
157 ;; Modified BSD license. See "copyright" section of
158 ;; https://www.khronos.org/opengles/sdk/tools/Reference-Compiler/
159 (license (list license:bsd-3
160 ;; include/SPIRV/{bitutils,hex_float}.h are Apache 2.0.
161 license:asl2.0)))))
162
163 (define-public vulkan-headers
164 (package
165 (name "vulkan-headers")
166 (version "1.1.85.0")
167 (source
168 (origin
169 (method url-fetch)
170 (uri (string-append
171 "https://github.com/KhronosGroup/Vulkan-Headers/"
172 "archive/sdk-" version ".tar.gz"))
173 (sha256
174 (base32
175 "166hqqb97kjg6h9vp8yxb1cq02i1kqaxvl693482gf8v21fl7ink"))))
176 (build-system cmake-build-system)
177 (arguments
178 `(#:tests? #f)) ; No tests.
179 (home-page
180 "https://github.com/KhronosGroup/Vulkan-Headers")
181 (synopsis "Vulkan Header files and API registry")
182 (description
183 "Vulkan-Headers contains header files and API registry for Vulkan.")
184 (license (list license:asl2.0)))) ;LICENSE.txt
185
186 (define-public vulkan-loader
187 (package
188 (name "vulkan-loader")
189 (version (package-version vulkan-headers))
190 (source
191 (origin
192 (method url-fetch)
193 (uri (string-append
194 "https://github.com/KhronosGroup/Vulkan-Loader/"
195 "archive/sdk-" version ".tar.gz"))
196 (sha256
197 (base32
198 "04d53ynlc0ww8r67hv4sxwg5sirjhpr1laaa9hc6j4niliw0166n"))))
199 (build-system cmake-build-system)
200 (arguments
201 `(#:tests? #f ;FIXME: 23/39 tests fail. Try "tests/run_all_tests.sh".
202 #:phases
203 (modify-phases %standard-phases
204 (add-after 'unpack 'remove-spirv-tools-commit-id
205 (lambda* (#:key inputs #:allow-other-keys)
206 ;; Remove lines trying to build in a git commit id.
207 (substitute* "CMakeLists.txt" ((".*spirv_tools_commit_id.h.*") ""))
208 #t)))
209 #:configure-flags (list
210 "-DBUILD_LAYERS=OFF" ; FIXME: Fails to build.
211 "-DBUILD_TESTS=OFF" ; FIXME: Needs 'googletest' submodule.
212 (string-append "-DCMAKE_INSTALL_LIBDIR="
213 (assoc-ref %outputs "out") "/lib"))))
214 (inputs `(("glslang" ,glslang)
215 ("libxcb" ,libxcb)
216 ("libx11" ,libx11)
217 ("libxrandr" ,libxrandr)
218 ("mesa" ,mesa)
219 ("spirv-tools" ,spirv-tools)
220 ("vulkan-headers" ,vulkan-headers)
221 ("wayland" ,wayland)))
222 (native-inputs `(("pkg-config" ,pkg-config)
223 ("python" ,python)))
224 (home-page
225 "https://github.com/KhronosGroup/Vulkan-Loader")
226 (synopsis "Khronos official ICD loader and validation layers for Vulkan")
227 (description
228 "Vulkan allows multiple @dfn{Installable Client Drivers} (ICDs) each
229 supporting one or more devices to be used collectively. The loader is
230 responsible for discovering available Vulkan ICDs on the system and inserting
231 Vulkan layer libraries, including validation layers between the application
232 and the ICD.")
233 ;; This software is mainly Apache 2.0 licensed, but contains some components
234 ;; covered by other licenses. See COPYRIGHT.txt for details.
235 (license (list license:asl2.0 ;LICENSE.txt
236 (license:x11-style "file://COPYRIGHT.txt")
237 license:bsd-3))))
238
239 (define-public vulkan-icd-loader
240 (deprecated-package "vulkan-icd-loader" vulkan-loader))
241
242 (define-public vulkan-tools
243 (package
244 (name "vulkan-tools")
245 (version (package-version vulkan-headers))
246 (source
247 (origin
248 (method url-fetch)
249 (uri (string-append
250 "https://github.com/KhronosGroup/Vulkan-Tools/"
251 "archive/sdk-" version ".tar.gz"))
252 (sha256
253 (base32
254 "0r26px9rh09giddajlmafv21rx1la1y3bbnjgnpai8aw98wvq9mm"))))
255 (build-system cmake-build-system)
256 (inputs
257 `(("glslang" ,glslang)
258 ("libxrandr" ,libxrandr)
259 ("mesa" ,mesa)
260 ("vulkan-headers" ,vulkan-headers)
261 ("vulkan-loader" ,vulkan-loader)
262 ("wayland" ,wayland)))
263 (native-inputs
264 `(("pkg-config" ,pkg-config)
265 ("python" ,python)))
266 (arguments
267 `(#:tests? #f)) ; No tests.
268 (home-page
269 "https://github.com/KhronosGroup/Vulkan-Tools")
270 (synopsis "Tools and utilities for Vulkan")
271 (description
272 "Vulkan-Tools provides tools and utilities that can assist development by
273 enabling developers to verify their applications correct use of the Vulkan
274 API.")
275 (license (list license:asl2.0)))) ;LICENSE.txt
276
277 (define-public shaderc
278 (let ((commit "be8e0879750303a1de09385465d6b20ecb8b380d")
279 (revision "2"))
280 (package
281 (name "shaderc")
282 (version (git-version "0.0.0" revision commit))
283 (source
284 (origin
285 (method git-fetch)
286 (uri (git-reference
287 (url "https://github.com/google/shaderc")
288 (commit commit)))
289 (file-name (string-append name "-" version ".tar.gz"))
290 (sha256
291 (base32
292 "16p25ry2i4zrj00zihfpf210f8xd7g398ffbw25igvi9mbn4nbfd"))))
293 (build-system meson-build-system)
294 (arguments
295 `(#:tests? #f ; FIXME: Tests fail.
296 #:phases
297 (modify-phases %standard-phases
298 (replace 'configure
299 (lambda* (#:key outputs #:allow-other-keys)
300 (let ((out (assoc-ref outputs "out")))
301 ;; Remove various lines and touch build-version.inc or
302 ;; configuring won't work.
303 (invoke "touch" "glslc/src/build-version.inc")
304 (substitute* "CMakeLists.txt" (("..PYTHON_EXE..*") ""))
305 (substitute* "CMakeLists.txt"
306 ((".*update_build_version.py..*") ""))
307 (substitute* "CMakeLists.txt"
308 ((".*add_custom_target.build-version.*") ""))
309 (substitute* "CMakeLists.txt"
310 ((".*spirv-tools_SOURCE_DIR.*glslang_SOURCE_DIR.*")
311 ""))
312 (substitute* "CMakeLists.txt"
313 ((".*Update build-version.inc.*") ""))
314 (substitute* "CMakeLists.txt" ((".*--check.*") ""))
315 (substitute* "glslc/src/main.cc" ((".*build-version.inc.*")
316 "\"1\""))
317 (invoke "cmake" "-GNinja" "-DCMAKE_BUILD_TYPE=Release"
318 "-DSHADERC_SKIP_TESTS=ON"
319 "-DCMAKE_INSTALL_LIBDIR=lib"
320 (string-append "-DCMAKE_INSTALL_PREFIX="
321 out)))))
322 (add-after 'unpack 'unpack-sources
323 (lambda* (#:key inputs #:allow-other-keys)
324 (let ((spirv-tools-source (assoc-ref inputs "spirv-tools-source"))
325 (spirv-headers-source (assoc-ref inputs "spirv-headers-source"))
326 (glslang-source (assoc-ref inputs "glslang-source")))
327 (copy-recursively spirv-tools-source "third_party/spirv-tools")
328 (copy-recursively spirv-headers-source
329 (string-append "third_party/spirv-tools"
330 "/external/spirv-headers"))
331 (copy-recursively glslang-source "third_party/glslang")
332 #t))))))
333 (inputs
334 `(("googletest" ,googletest)
335 ("python" ,python)))
336 (native-inputs
337 `(("cmake" ,cmake)
338 ("glslang-source" ,(package-source glslang))
339 ("pkg-config" ,pkg-config)
340 ("spirv-headers-source" ,(package-source spirv-headers))
341 ("spirv-tools-source" ,(package-source spirv-tools))))
342 (home-page "https://github.com/google/shaderc")
343 (synopsis "Tools for shader compilation")
344 (description "Shaderc is a collection of tools, libraries, and tests for
345 shader compilation.")
346 (license license:asl2.0))))
347
348 (define-public vkd3d
349 (let ((commit "ecda316ef54d70bf1b3e860755241bb75873e53f")) ; Release 1.1.
350 (package
351 (name "vkd3d")
352 (version "1.1")
353 (source
354 (origin
355 (method git-fetch)
356 (uri (git-reference
357 (url "https://source.winehq.org/git/vkd3d.git")
358 (commit commit)))
359 (sha256
360 (base32
361 "05a28kspy8gzng181w28zjqdb3pj2ss83b0lwnppxbcdzsz7rvrf"))
362 (file-name (string-append name "-" version "-checkout"))))
363 (build-system gnu-build-system)
364 (arguments
365 `(#:configure-flags '("--with-spirv-tools")))
366 (native-inputs
367 `(("autoconf" ,autoconf)
368 ("automake" ,automake)
369 ("gettext" ,gnu-gettext)
370 ("libtool" ,libtool)
371 ("pkg-config" ,pkg-config)))
372 (inputs
373 `(("libx11" ,libx11)
374 ("libxcb" ,libxcb)
375 ("spirv-headers" ,spirv-headers)
376 ("spirv-tools" ,spirv-tools)
377 ("vulkan-headers" ,vulkan-headers)
378 ("vulkan-loader" ,vulkan-loader)
379 ("wine-minimal" ,wine-minimal) ; Needed for 'widl'.
380 ("xcb-util" ,xcb-util)
381 ("xcb-util-keysyms" ,xcb-util-keysyms)
382 ("xcb-util-wm" ,xcb-util-wm)))
383 (home-page "https://source.winehq.org/git/vkd3d.git/")
384 (synopsis "Direct3D 12 to Vulkan translation library")
385 (description "vkd3d is a library for translating Direct3D 12 to Vulkan.")
386 (license license:lgpl2.1))))