vulkan.scm 16 KB

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