d5f5be68165ce11931566327bce44fb75797e0fb
[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, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
4 ;;; Copyright © 2018 Efraim Flashner <efraim@flashner.co.il>
5 ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
6 ;;;
7 ;;; This file is part of GNU Guix.
8 ;;;
9 ;;; GNU Guix is free software; you can redistribute it and/or modify it
10 ;;; under the terms of the GNU General Public License as published by
11 ;;; the Free Software Foundation; either version 3 of the License, or (at
12 ;;; your option) any later version.
13 ;;;
14 ;;; GNU Guix is distributed in the hope that it will be useful, but
15 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;;; GNU General Public License for more details.
18 ;;;
19 ;;; You should have received a copy of the GNU General Public License
20 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21
22 (define-module (gnu packages vulkan)
23 #:use-module ((guix licenses) #:prefix license:)
24 #:use-module (guix packages)
25 #:use-module (guix download)
26 #:use-module (guix git-download)
27 #:use-module (guix build-system cmake)
28 #:use-module (guix build-system gnu)
29 #:use-module (guix build-system meson)
30 #:use-module (gnu packages)
31 #:use-module (gnu packages autotools)
32 #:use-module (gnu packages bison)
33 #:use-module (gnu packages check)
34 #:use-module (gnu packages cmake)
35 #:use-module (gnu packages freedesktop)
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.5.3")
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 "069sivqajp7z4p44lmrz23lvf237xpkjxd4lzrg27836pwqcz9bj"))
56 (file-name (git-file-name name version))))
57 (build-system cmake-build-system)
58 (arguments
59 `(#:tests? #f)) ;no tests
60 (home-page "https://github.com/KhronosGroup/SPIRV-Headers")
61 (synopsis "Machine-readable files from the SPIR-V Registry")
62 (description
63 "SPIRV-Headers is a repository containing machine-readable files from
64 the SPIR-V Registry. This includes:
65 @itemize
66 @item Header files for various languages.
67 @item JSON files describing the grammar for the SPIR-V core instruction set,
68 and for the GLSL.std.450 extended instruction set.
69 @item The XML registry file.
70 @end itemize\n")
71 (license (license:x11-style
72 (string-append "https://github.com/KhronosGroup/SPIRV-Headers/blob/"
73 version "/LICENSE")))))
74
75 (define-public spirv-tools
76 (package
77 (name "spirv-tools")
78 (version "2020.2")
79 (source
80 (origin
81 (method git-fetch)
82 (uri (git-reference
83 (url "https://github.com/KhronosGroup/SPIRV-Tools")
84 (commit (string-append "v" version))))
85 (sha256
86 (base32 "00b7xgyrcb2qq63pp3cnw5q1xqx2d9rfn65lai6n6r89s1vh3vg6"))
87 (file-name (git-file-name name version))))
88 (build-system cmake-build-system)
89 (arguments
90 `(#:configure-flags (list "-DBUILD_SHARED_LIBS=ON"
91 (string-append
92 "-DSPIRV-Headers_SOURCE_DIR="
93 (assoc-ref %build-inputs "spirv-headers")))))
94 (inputs `(("spirv-headers" ,spirv-headers)))
95 (native-inputs `(("pkg-config" ,pkg-config)
96 ("python" ,python)))
97 (home-page "https://github.com/KhronosGroup/SPIRV-Tools")
98 (synopsis "API and commands for processing SPIR-V modules")
99 (description
100 "The SPIR-V Tools project provides an API and commands for processing
101 SPIR-V modules. The project includes an assembler, binary module
102 parser,disassembler, validator, and optimizer for SPIR-V.")
103 (license license:asl2.0)))
104
105 (define-public glslang
106 (package
107 (name "glslang")
108 (version "8.13.3743")
109 (source
110 (origin
111 (method git-fetch)
112 (uri (git-reference
113 (url "https://github.com/KhronosGroup/glslang")
114 (commit version)))
115 (sha256
116 (base32
117 "0d20wfpp2fmbnz1hnsjr9xc62lxpj86ik2qyviqbni0pqj212cry"))
118 (file-name (string-append name "-" version "-checkout"))))
119 (build-system cmake-build-system)
120 (arguments
121 '(#:tests? #f ;FIXME: requires bundled SPIRV-Tools
122 #:configure-flags '("-DBUILD_SHARED_LIBS=ON")))
123 (native-inputs
124 `(("pkg-config" ,pkg-config)
125 ("python" ,python)))
126 (home-page "https://github.com/KhronosGroup/glslang")
127 (synopsis "OpenGL and OpenGL ES shader front end and validator")
128 (description
129 "Glslang is the official reference compiler front end for the
130 OpenGL@tie{}ES and OpenGL shading languages. It implements a strict
131 interpretation of the specifications for these languages.")
132 ;; Modified BSD license. See "copyright" section of
133 ;; https://www.khronos.org/opengles/sdk/tools/Reference-Compiler/
134 (license (list license:bsd-3
135 ;; include/SPIRV/{bitutils,hex_float}.h are Apache 2.0.
136 license:asl2.0))))
137
138 (define-public vulkan-headers
139 (package
140 (name "vulkan-headers")
141 (version "1.2.141")
142 (source
143 (origin
144 (method git-fetch)
145 (uri (git-reference
146 (url "https://github.com/KhronosGroup/Vulkan-Headers")
147 (commit (string-append "v" version))))
148 (file-name (git-file-name name version))
149 (sha256
150 (base32
151 "10nmx6y4llllfcczyfz76amd0vkqv09dj952d19zkzmmgcval7zq"))))
152 (build-system cmake-build-system)
153 (arguments
154 `(#:tests? #f)) ; No tests.
155 (home-page
156 "https://github.com/KhronosGroup/Vulkan-Headers")
157 (synopsis "Vulkan Header files and API registry")
158 (description
159 "Vulkan-Headers contains header files and API registry for Vulkan.")
160 (license (list license:asl2.0)))) ;LICENSE.txt
161
162 (define-public vulkan-loader
163 (package
164 (name "vulkan-loader")
165 (version "1.2.140")
166 (source
167 (origin
168 (method git-fetch)
169 (uri (git-reference
170 (url "https://github.com/KhronosGroup/Vulkan-Loader")
171 (commit (string-append "v" version))))
172 (file-name (git-file-name name version))
173 (sha256
174 (base32
175 "0rhyz0qgp0i7pcx6wlvgwy7j33d4cs0xx39f0b6igpfk0vk70r1w"))))
176 (build-system cmake-build-system)
177 (arguments
178 `(#:phases (modify-phases %standard-phases
179 (add-after 'unpack 'unpack-googletest
180 (lambda* (#:key inputs #:allow-other-keys)
181 (let ((gtest (assoc-ref inputs "googletest:source")))
182 (when gtest
183 (copy-recursively gtest "external/googletest"))
184 #t)))
185 (add-after 'unpack 'disable-loader-tests
186 (lambda _
187 ;; Many tests require a Vulkan driver. Skip those.
188 (substitute* "tests/loader_validation_tests.cpp"
189 ((".*= vkCreateInstance.*" all)
190 (string-append "GTEST_SKIP();\n" all))
191 (("TEST_F.*InstanceExtensionEnumerated.*" all)
192 (string-append all "\nGTEST_SKIP();\n")))
193 #t)))))
194 (native-inputs
195 `(("googletest:source" ,(package-source googletest))
196 ("libxrandr" ,libxrandr)
197 ("pkg-config" ,pkg-config)
198 ("python" ,python)
199 ("vulkan-headers" ,vulkan-headers)
200 ("wayland" ,wayland)))
201 (home-page
202 "https://github.com/KhronosGroup/Vulkan-Loader")
203 (synopsis "Khronos official ICD loader and validation layers for Vulkan")
204 (description
205 "Vulkan allows multiple @dfn{Installable Client Drivers} (ICDs) each
206 supporting one or more devices to be used collectively. The loader is
207 responsible for discovering available Vulkan ICDs on the system and inserting
208 Vulkan layer libraries, including validation layers between the application
209 and the ICD.")
210 ;; This software is mainly Apache 2.0 licensed, but contains some components
211 ;; covered by other licenses. See COPYRIGHT.txt for details.
212 (license (list license:asl2.0 ;LICENSE.txt
213 (license:x11-style "file://COPYRIGHT.txt")
214 license:bsd-3))))
215
216 (define-public vulkan-tools
217 (package
218 (name "vulkan-tools")
219 (version "1.2.140")
220 (source
221 (origin
222 (method git-fetch)
223 (uri (git-reference
224 (url "https://github.com/KhronosGroup/Vulkan-Tools")
225 (commit (string-append "v" version))))
226 (file-name (git-file-name name version))
227 (sha256
228 (base32
229 "08dk0q77kpycn4vv19jh3ig73gbq3psan246a7fss0nfxpiddg0j"))))
230 (build-system cmake-build-system)
231 (inputs
232 `(("glslang" ,glslang)
233 ("libxrandr" ,libxrandr)
234 ("vulkan-loader" ,vulkan-loader)
235 ("wayland" ,wayland)))
236 (native-inputs
237 `(("pkg-config" ,pkg-config)
238 ("python" ,python)
239 ("vulkan-headers" ,vulkan-headers)))
240 (arguments
241 `(#:tests? #f ;no tests
242 #:configure-flags (list (string-append "-DGLSLANG_INSTALL_DIR="
243 (assoc-ref %build-inputs "glslang")))))
244 (home-page
245 "https://github.com/KhronosGroup/Vulkan-Tools")
246 (synopsis "Tools and utilities for Vulkan")
247 (description
248 "Vulkan-Tools provides tools and utilities that can assist development by
249 enabling developers to verify their applications correct use of the Vulkan
250 API.")
251 (license (list license:asl2.0)))) ;LICENSE.txt
252
253 (define-public shaderc
254 (package
255 (name "shaderc")
256 (version "2020.0")
257 (source
258 (origin
259 (method git-fetch)
260 (uri (git-reference
261 (url "https://github.com/google/shaderc")
262 (commit (string-append "v" version))))
263 (file-name (git-file-name name version))
264 (sha256
265 (base32
266 "1kqqvsvib01bsmfbdy3fbwwpvkcdlfb6k71kjvzb3crql7w0rxff"))))
267 (build-system cmake-build-system)
268 (arguments
269 `(;; FIXME: Skip most of the tests, because enabling system gtest breaks
270 ;; the build: <https://github.com/google/shaderc/issues/470>.
271 #:configure-flags '("-DSHADERC_SKIP_TESTS=ON")
272 #:phases
273 (modify-phases %standard-phases
274 (add-after 'unpack 'do-not-look-for-bundled-sources
275 (lambda _
276 (substitute* "CMakeLists.txt"
277 (("add_subdirectory\\(third_party\\)")
278 ""))
279
280 (substitute* "glslc/test/CMakeLists.txt"
281 (("\\$<TARGET_FILE:spirv-dis>")
282 (which "spirv-dis")))
283
284 ;; Do not attempt to use git to encode version information.
285 (substitute* "glslc/CMakeLists.txt"
286 (("add_dependencies\\(glslc_exe build-version\\)")
287 ""))
288 (call-with-output-file "glslc/src/build-version.inc"
289 (lambda (port)
290 (format port "\"~a\"\n\"~a\"\n\"~a\"~%"
291 ,version
292 ,(package-version spirv-tools)
293 ,(package-version glslang))))
294 #t)))))
295 (inputs
296 `(("glslang" ,glslang)
297 ("python" ,python)
298 ("spirv-headers" ,spirv-headers)
299 ("spirv-tools" ,spirv-tools)))
300 (native-inputs
301 `(("pkg-config" ,pkg-config)))
302 (home-page "https://github.com/google/shaderc")
303 (synopsis "Tools for shader compilation")
304 (description "Shaderc is a collection of tools, libraries, and tests for
305 shader compilation.")
306 (license license:asl2.0)))
307
308 (define-public vkd3d
309 (let ((commit "ecda316ef54d70bf1b3e860755241bb75873e53f")) ; Release 1.1.
310 (package
311 (name "vkd3d")
312 (version "1.1")
313 (source
314 (origin
315 (method git-fetch)
316 (uri (git-reference
317 (url "https://source.winehq.org/git/vkd3d.git")
318 (commit commit)))
319 (sha256
320 (base32
321 "05a28kspy8gzng181w28zjqdb3pj2ss83b0lwnppxbcdzsz7rvrf"))
322 (file-name (string-append name "-" version "-checkout"))))
323 (build-system gnu-build-system)
324 (arguments
325 `(#:configure-flags '("--with-spirv-tools")
326 #:phases (modify-phases %standard-phases
327 (add-after 'unpack 'patch-for-new-vulkan
328 (lambda _
329 ;; Mimic upstream commit 8e7bf8a5c3e0047 for
330 ;; compatibility with newer vulkan-headers.
331 (substitute* "libs/vkd3d/vkd3d_private.h"
332 (("VK_PIPELINE_BIND_POINT_RANGE_SIZE")
333 "2u"))
334 #t)))))
335 (native-inputs
336 `(("autoconf" ,autoconf)
337 ("automake" ,automake)
338 ("gettext" ,gettext-minimal)
339 ("libtool" ,libtool)
340 ("pkg-config" ,pkg-config)))
341 (inputs
342 `(("libx11" ,libx11)
343 ("libxcb" ,libxcb)
344 ("spirv-headers" ,spirv-headers)
345 ("spirv-tools" ,spirv-tools)
346 ("vulkan-headers" ,vulkan-headers)
347 ("vulkan-loader" ,vulkan-loader)
348 ("wine-minimal" ,wine-minimal) ; Needed for 'widl'.
349 ("xcb-util" ,xcb-util)
350 ("xcb-util-keysyms" ,xcb-util-keysyms)
351 ("xcb-util-wm" ,xcb-util-wm)))
352 (home-page "https://source.winehq.org/git/vkd3d.git/")
353 (synopsis "Direct3D 12 to Vulkan translation library")
354 (description "vkd3d is a library for translating Direct3D 12 to Vulkan.")
355 (license license:lgpl2.1))))