Merge branch 'master' into staging
[jackhill/guix/guix.git] / gnu / packages / vulkan.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2017, 2018, 2019 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 gcc)
36 #:use-module (gnu packages gettext)
37 #:use-module (gnu packages gl)
38 #:use-module (gnu packages pkg-config)
39 #:use-module (gnu packages python)
40 #:use-module (gnu packages wine)
41 #:use-module (gnu packages xorg))
42
43 (define-public spirv-headers
44 (package
45 (name "spirv-headers")
46 (version "1.3.7")
47 (source
48 (origin
49 (method git-fetch)
50 (uri (git-reference
51 (url "https://github.com/KhronosGroup/SPIRV-Headers")
52 (commit version)))
53 (sha256
54 (base32
55 "0m56smanfcczjfif4yfcqhjj4d4sc088kwg6dgia8fwdsjavdm4d"))
56 (file-name (string-append name "-" version "-checkout"))))
57 (build-system cmake-build-system)
58 (arguments
59 `(#:tests? #f ;; No tests
60 #:phases (modify-phases %standard-phases
61 (replace 'install
62 (lambda* (#:key outputs #:allow-other-keys)
63 (invoke "cmake" "-E" "copy_directory"
64 "../source/include/spirv"
65 (string-append (assoc-ref outputs "out")
66 "/include/spirv")))))))
67 (home-page "https://github.com/KhronosGroup/SPIRV-Headers")
68 (synopsis "Machine-readable files from the SPIR-V Registry")
69 (description
70 "SPIRV-Headers is a repository containing machine-readable files from
71 the SPIR-V Registry. This includes:
72 @itemize
73 @item Header files for various languages.
74 @item JSON files describing the grammar for the SPIR-V core instruction set,
75 and for the GLSL.std.450 extended instruction set.
76 @item The XML registry file.
77 @end itemize\n")
78 (license (license:x11-style
79 (string-append "https://github.com/KhronosGroup/SPIRV-Headers/blob/"
80 version "/LICENSE")))))
81
82 (define-public spirv-tools
83 (package
84 (name "spirv-tools")
85 (version "2019.1")
86 (source
87 (origin
88 (method git-fetch)
89 (uri (git-reference
90 (url "https://github.com/KhronosGroup/SPIRV-Tools")
91 (commit (string-append "v" version))))
92 (sha256
93 (base32
94 "0vddjzhkrhrm3l3i57nxmq2smv3r1s0ka5ff2kziaahr4hqb479r"))
95 (file-name (string-append name "-" version "-checkout"))))
96 (build-system cmake-build-system)
97 (arguments
98 `(#:tests? #f ; FIXME: Tests fail.
99 #:phases
100 (modify-phases %standard-phases
101 (add-before 'configure 'fixgcc7
102 (lambda _
103 (unsetenv "C_INCLUDE_PATH")
104 (unsetenv "CPLUS_INCLUDE_PATH")
105 #t)))
106 #:configure-flags (list (string-append "-DSPIRV-Headers_SOURCE_DIR="
107 (assoc-ref %build-inputs "spirv-headers")))))
108 (inputs `(("spirv-headers" ,spirv-headers)))
109 (native-inputs `(("gcc" ,gcc-7)
110 ("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
117 parser,disassembler, validator, and optimizer for SPIR-V.")
118 (license license:asl2.0)))
119
120 (define-public glslang
121 (package
122 (name "glslang")
123 (version "7.11.3214")
124 (source
125 (origin
126 (method git-fetch)
127 (uri (git-reference
128 (url "https://github.com/KhronosGroup/glslang")
129 (commit version)))
130 (sha256
131 (base32
132 "0dqjga0lcza006fhac26zp2plbq4gx8a6nsmrwkqlzji6lw1jins"))
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-headers
160 (package
161 (name "vulkan-headers")
162 (version "1.1.114")
163 (source
164 (origin
165 (method git-fetch)
166 (uri (git-reference
167 (url "https://github.com/KhronosGroup/Vulkan-Headers")
168 (commit (string-append "v" version))))
169 (file-name (git-file-name name version))
170 (sha256
171 (base32
172 "0fdvh26nxibylh32lj8b62d9nf9j25xa0il9zg362wmr2zgm8gka"))))
173 (build-system cmake-build-system)
174 (arguments
175 `(#:tests? #f)) ; No tests.
176 (home-page
177 "https://github.com/KhronosGroup/Vulkan-Headers")
178 (synopsis "Vulkan Header files and API registry")
179 (description
180 "Vulkan-Headers contains header files and API registry for Vulkan.")
181 (license (list license:asl2.0)))) ;LICENSE.txt
182
183 (define-public vulkan-loader
184 (package
185 (name "vulkan-loader")
186 (version (package-version vulkan-headers))
187 (source
188 (origin
189 (method git-fetch)
190 (uri (git-reference
191 (url "https://github.com/KhronosGroup/Vulkan-Loader")
192 (commit (string-append "v" version))))
193 (file-name (git-file-name name version))
194 (sha256
195 (base32
196 "1rkm6dzdzxva62shscipz3kpp66x4kgmwvp1ski2fvf4jzzcbv7h"))))
197 (build-system cmake-build-system)
198 (arguments
199 `(#:tests? #f ;FIXME: 23/39 tests fail. Try "tests/run_all_tests.sh".
200 #:phases
201 (modify-phases %standard-phases
202 (add-after 'unpack 'remove-spirv-tools-commit-id
203 (lambda* (#:key inputs #:allow-other-keys)
204 ;; Remove lines trying to build in a git commit id.
205 (substitute* "CMakeLists.txt" ((".*spirv_tools_commit_id.h.*") ""))
206 #t))
207 ;; Make sure that the files needed for Mesa's Vulkan overlay are availabe.
208 (add-after 'unpack 'copy-headers1
209 (lambda* (#:key outputs #:allow-other-keys)
210 (install-file "tests/layers/vk_layer_data.h"
211 (string-append (assoc-ref %outputs "out")
212 "/include/vulkan"))
213 (install-file "tests/layers/vk_layer_extension_utils.h"
214 (string-append (assoc-ref %outputs "out")
215 "/include/vulkan"))
216 (install-file "loader/vk_loader_platform.h"
217 (string-append (assoc-ref %outputs "out")
218 "/include/vulkan"))
219 #t))
220 (add-after 'build 'copy-headers2
221 (lambda* (#:key outputs #:allow-other-keys)
222 (install-file "vk_layer_dispatch_table.h"
223 (string-append (assoc-ref %outputs "out")
224 "/include/vulkan"))
225 (install-file "vk_dispatch_table_helper.h"
226 (string-append (assoc-ref %outputs "out")
227 "/include/vulkan"))
228 #t)))
229 #:configure-flags (list
230 "-DBUILD_TESTS=OFF" ; FIXME: Needs 'googletest' submodule.
231 (string-append "-DCMAKE_INSTALL_LIBDIR="
232 (assoc-ref %outputs "out") "/lib"))))
233 (native-inputs `(("libxrandr" ,libxrandr)
234 ("pkg-config" ,pkg-config)
235 ("python" ,python)
236 ("vulkan-headers" ,vulkan-headers)
237 ("wayland" ,wayland)))
238 (home-page
239 "https://github.com/KhronosGroup/Vulkan-Loader")
240 (synopsis "Khronos official ICD loader and validation layers for Vulkan")
241 (description
242 "Vulkan allows multiple @dfn{Installable Client Drivers} (ICDs) each
243 supporting one or more devices to be used collectively. The loader is
244 responsible for discovering available Vulkan ICDs on the system and inserting
245 Vulkan layer libraries, including validation layers between the application
246 and the ICD.")
247 ;; This software is mainly Apache 2.0 licensed, but contains some components
248 ;; covered by other licenses. See COPYRIGHT.txt for details.
249 (license (list license:asl2.0 ;LICENSE.txt
250 (license:x11-style "file://COPYRIGHT.txt")
251 license:bsd-3))))
252
253 (define-public vulkan-icd-loader
254 (deprecated-package "vulkan-icd-loader" vulkan-loader))
255
256 (define-public vulkan-tools
257 (package
258 (name "vulkan-tools")
259 (version (package-version vulkan-headers))
260 (source
261 (origin
262 (method git-fetch)
263 (uri (git-reference
264 (url "https://github.com/KhronosGroup/Vulkan-Tools")
265 (commit (string-append "v" version))))
266 (file-name (git-file-name name version))
267 (sha256
268 (base32
269 "1lz06mpni8ghf1xcxi4g6ck306lfaqwfi6f1w64kp9hczmvapfhf"))))
270 (build-system cmake-build-system)
271 (inputs
272 `(("glslang" ,glslang)
273 ("libxrandr" ,libxrandr)
274 ("vulkan-loader" ,vulkan-loader)
275 ("wayland" ,wayland)))
276 (native-inputs
277 `(("pkg-config" ,pkg-config)
278 ("python" ,python)
279 ("vulkan-headers" ,vulkan-headers)))
280 (arguments
281 `(#:tests? #f ; No tests.
282 #:configure-flags (list (string-append "-DGLSLANG_INSTALL_DIR="
283 (assoc-ref %build-inputs "glslang")))))
284 (home-page
285 "https://github.com/KhronosGroup/Vulkan-Tools")
286 (synopsis "Tools and utilities for Vulkan")
287 (description
288 "Vulkan-Tools provides tools and utilities that can assist development by
289 enabling developers to verify their applications correct use of the Vulkan
290 API.")
291 (license (list license:asl2.0)))) ;LICENSE.txt
292
293 (define-public shaderc
294 (package
295 (name "shaderc")
296 (version "2019.0")
297 (source
298 (origin
299 (method git-fetch)
300 (uri (git-reference
301 (url "https://github.com/google/shaderc")
302 (commit (string-append "v" version))))
303 (file-name (git-file-name name version))
304 (sha256
305 (base32
306 "1l5mmyxhzsbp0a6y2d86i8jmf46c6bjgjkdgkr5l8hmhflmm7gi2"))))
307 (build-system meson-build-system)
308 (arguments
309 `(#:tests? #f ; FIXME: Tests fail.
310 #:phases
311 (modify-phases %standard-phases
312 (replace 'configure
313 (lambda* (#:key outputs #:allow-other-keys)
314 (let ((out (assoc-ref outputs "out")))
315 ;; Remove various lines and touch build-version.inc or
316 ;; configuring won't work.
317 (invoke "touch" "glslc/src/build-version.inc")
318 (substitute* "CMakeLists.txt" (("..PYTHON_EXE..*") ""))
319 (substitute* "CMakeLists.txt"
320 ((".*update_build_version.py..*") ""))
321 (substitute* "CMakeLists.txt"
322 ((".*add_custom_target.build-version.*") ""))
323 (substitute* "CMakeLists.txt"
324 ((".*spirv-tools_SOURCE_DIR.*glslang_SOURCE_DIR.*")
325 ""))
326 (substitute* "CMakeLists.txt"
327 ((".*Update build-version.inc.*") ""))
328 (substitute* "CMakeLists.txt" ((".*--check.*") ""))
329 (substitute* "glslc/src/main.cc" ((".*build-version.inc.*")
330 "\"1\""))
331 (invoke "cmake" "-GNinja" "-DCMAKE_BUILD_TYPE=Release"
332 "-DSHADERC_SKIP_TESTS=ON"
333 "-DCMAKE_INSTALL_LIBDIR=lib"
334 (string-append "-DCMAKE_INSTALL_PREFIX="
335 out)))))
336 (add-after 'unpack 'unpack-sources
337 (lambda* (#:key inputs #:allow-other-keys)
338 (let ((spirv-tools-source (assoc-ref inputs "spirv-tools-source"))
339 (spirv-headers-source (assoc-ref inputs "spirv-headers-source"))
340 (glslang-source (assoc-ref inputs "glslang-source")))
341 (copy-recursively spirv-tools-source "third_party/spirv-tools")
342 (copy-recursively spirv-headers-source
343 (string-append "third_party/spirv-tools"
344 "/external/spirv-headers"))
345 (copy-recursively glslang-source "third_party/glslang")
346 #t))))))
347 (inputs
348 `(("googletest" ,googletest)
349 ("python" ,python)))
350 (native-inputs
351 `(("cmake" ,cmake)
352 ("glslang-source" ,(package-source glslang))
353 ("pkg-config" ,pkg-config)
354 ("spirv-headers-source" ,(package-source spirv-headers))
355 ("spirv-tools-source" ,(package-source spirv-tools))))
356 (home-page "https://github.com/google/shaderc")
357 (synopsis "Tools for shader compilation")
358 (description "Shaderc is a collection of tools, libraries, and tests for
359 shader compilation.")
360 (license license:asl2.0)))
361
362 (define-public vkd3d
363 (let ((commit "ecda316ef54d70bf1b3e860755241bb75873e53f")) ; Release 1.1.
364 (package
365 (name "vkd3d")
366 (version "1.1")
367 (source
368 (origin
369 (method git-fetch)
370 (uri (git-reference
371 (url "https://source.winehq.org/git/vkd3d.git")
372 (commit commit)))
373 (sha256
374 (base32
375 "05a28kspy8gzng181w28zjqdb3pj2ss83b0lwnppxbcdzsz7rvrf"))
376 (file-name (string-append name "-" version "-checkout"))))
377 (build-system gnu-build-system)
378 (arguments
379 `(#:configure-flags '("--with-spirv-tools")))
380 (native-inputs
381 `(("autoconf" ,autoconf)
382 ("automake" ,automake)
383 ("gettext" ,gnu-gettext)
384 ("libtool" ,libtool)
385 ("pkg-config" ,pkg-config)))
386 (inputs
387 `(("libx11" ,libx11)
388 ("libxcb" ,libxcb)
389 ("spirv-headers" ,spirv-headers)
390 ("spirv-tools" ,spirv-tools)
391 ("vulkan-headers" ,vulkan-headers)
392 ("vulkan-loader" ,vulkan-loader)
393 ("wine-minimal" ,wine-minimal) ; Needed for 'widl'.
394 ("xcb-util" ,xcb-util)
395 ("xcb-util-keysyms" ,xcb-util-keysyms)
396 ("xcb-util-wm" ,xcb-util-wm)))
397 (home-page "https://source.winehq.org/git/vkd3d.git/")
398 (synopsis "Direct3D 12 to Vulkan translation library")
399 (description "vkd3d is a library for translating Direct3D 12 to Vulkan.")
400 (license license:lgpl2.1))))