gnu: Add python-pyshp.
[jackhill/guix/guix.git] / gnu / packages / vulkan.scm
index 732d554..ac91f84 100644 (file)
@@ -102,19 +102,66 @@ SPIR-V modules.  The project includes an assembler, binary module
 parser,disassembler, validator, and optimizer for SPIR-V.")
     (license license:asl2.0)))
 
+(define-public spirv-cross
+  (package
+    (name "spirv-cross")
+    (version "2020-05-19")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/KhronosGroup/SPIRV-Cross")
+             (commit version)))
+       (sha256
+        (base32 "0zyijp9zx9wbd4i5lwjap7n793iz6yjkf27la60dsffxl75yy9pd"))
+       (file-name (git-file-name name version))))
+    (build-system cmake-build-system)
+    (arguments
+     `(#:configure-flags
+       (list "-DSPIRV_CROSS_SHARED=YES")
+       ;; FIXME: The following tests fail:
+       ;;   15 - spirv-cross-test-opt
+       ;;   16 - spirv-cross-test-metal-opt
+       ;;   17 - spirv-cross-test-hlsl-opt
+       #:tests? #f
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'fix-tests-to-find-deps
+           (lambda* (#:key inputs #:allow-other-keys)
+             (substitute* "CMakeLists.txt"
+               (("\\$\\{CMAKE_(.*)_DIR\\}/external/glslang(.*)/bin")
+                (string-append (assoc-ref inputs "glslang") "/bin")))
+             (substitute* "CMakeLists.txt"
+               (("\\$\\{CMAKE_(.*)_DIR\\}/external/spirv-tools(.*)/bin")
+                (string-append (assoc-ref inputs "spirv-tools") "/bin")))
+             #t)))))
+    (inputs
+     `(("glslang" ,glslang)
+       ("spirv-headers" ,spirv-headers)
+       ("spirv-tools" ,spirv-tools)))
+    (native-inputs `(("python" ,python)))
+    (home-page "https://github.com/KhronosGroup/SPIRV-Cross")
+    (synopsis "Parser for and converter of SPIR-V to other shader languages")
+    (description
+     "SPIRV-Cross tries hard to emit readable and clean output from the
+SPIR-V, aiming to emit GLSL or MSL that looks like human-written code.")
+    (license license:asl2.0)))
+
 (define-public glslang
   (package
     (name "glslang")
-    (version "8.13.3743")
+    (version "10-11.0.0")
     (source
      (origin
        (method git-fetch)
        (uri (git-reference
              (url "https://github.com/KhronosGroup/glslang")
-             (commit version)))
+             ;; Tag "10-11.0.0" was moved to "11.0.0".
+             ;; FIXME: Use (commit version) on next update.
+             (commit "11.0.0")))
        (sha256
         (base32
-         "0d20wfpp2fmbnz1hnsjr9xc62lxpj86ik2qyviqbni0pqj212cry"))
+         "14mn2awswl022ls75mfpsnpsl0ai0jgfbqj3sxcsqawyj5f432py"))
        (file-name (string-append name "-" version "-checkout"))))
     (build-system cmake-build-system)
     (arguments
@@ -138,7 +185,7 @@ interpretation of the specifications for these languages.")
 (define-public vulkan-headers
   (package
     (name "vulkan-headers")
-    (version "1.2.141")
+    (version "1.2.164")
     (source
      (origin
        (method git-fetch)
@@ -148,7 +195,7 @@ interpretation of the specifications for these languages.")
        (file-name (git-file-name name version))
        (sha256
         (base32
-         "10nmx6y4llllfcczyfz76amd0vkqv09dj952d19zkzmmgcval7zq"))))
+         "11wzxvwim4jna1yssbmprl211dhmz8vmrd498zww3bghzlj7bljv"))))
     (build-system cmake-build-system)
     (arguments
      `(#:tests? #f))                    ; No tests.
@@ -162,7 +209,7 @@ interpretation of the specifications for these languages.")
 (define-public vulkan-loader
   (package
     (name "vulkan-loader")
-    (version "1.2.140")
+    (version "1.2.162")
     (source
      (origin
        (method git-fetch)
@@ -172,7 +219,7 @@ interpretation of the specifications for these languages.")
        (file-name (git-file-name name version))
        (sha256
         (base32
-         "0rhyz0qgp0i7pcx6wlvgwy7j33d4cs0xx39f0b6igpfk0vk70r1w"))))
+         "15gx9ab6w1sjq9hkpbas7z2f8f47j6mlln6p3w26qmydjj8gfjjv"))))
     (build-system cmake-build-system)
     (arguments
      `(#:phases (modify-phases %standard-phases
@@ -216,7 +263,7 @@ and the ICD.")
 (define-public vulkan-tools
   (package
     (name "vulkan-tools")
-    (version "1.2.140")
+    (version "1.2.162")
     (source
      (origin
        (method git-fetch)
@@ -226,7 +273,7 @@ and the ICD.")
        (file-name (git-file-name name version))
        (sha256
         (base32
-         "08dk0q77kpycn4vv19jh3ig73gbq3psan246a7fss0nfxpiddg0j"))))
+         "129wzk7xj3vn3c8b4p7fzkd0npl58118s2i1d88gsfnlix54nagq"))))
     (build-system cmake-build-system)
     (inputs
      `(("glslang" ,glslang)
@@ -253,7 +300,7 @@ API.")
 (define-public shaderc
   (package
     (name "shaderc")
-    (version "2019.0")
+    (version "2020.4")
     (source
      (origin
        (method git-fetch)
@@ -263,56 +310,46 @@ API.")
        (file-name (git-file-name name version))
        (sha256
         (base32
-         "1l5mmyxhzsbp0a6y2d86i8jmf46c6bjgjkdgkr5l8hmhflmm7gi2"))))
-    (build-system meson-build-system)
+         "07h78nd964h2bdm4drzws8i1gvyal8a3wlhbcm5qxqk6vknv8hrk"))))
+    (build-system cmake-build-system)
     (arguments
-     `(#:tests? #f ; FIXME: Tests fail.
+     `(;; FIXME: Skip most of the tests, because enabling system gtest breaks
+       ;; the build: <https://github.com/google/shaderc/issues/470>.
+       #:configure-flags
+       (list "-DSHADERC_SKIP_TESTS=ON"
+             ;; Note: despite the name, this just specifies the headers.
+             (string-append "-Dglslang_SOURCE_DIR="
+                            (assoc-ref %build-inputs "glslang") "/include/glslang"))
        #:phases
        (modify-phases %standard-phases
-         (replace 'configure
-           (lambda* (#:key outputs #:allow-other-keys)
-             (let ((out (assoc-ref outputs "out")))
-               ;; Remove various lines and touch build-version.inc or
-               ;; configuring won't work.
-               (invoke "touch" "glslc/src/build-version.inc")
-               (substitute* "CMakeLists.txt" (("..PYTHON_EXE..*") ""))
-               (substitute* "CMakeLists.txt"
-                 ((".*update_build_version.py..*") ""))
-               (substitute* "CMakeLists.txt"
-                 ((".*add_custom_target.build-version.*") ""))
-               (substitute* "CMakeLists.txt"
-                 ((".*spirv-tools_SOURCE_DIR.*glslang_SOURCE_DIR.*")
-                  ""))
-               (substitute* "CMakeLists.txt"
-                 ((".*Update build-version.inc.*") ""))
-               (substitute* "CMakeLists.txt" ((".*--check.*") ""))
-               (substitute* "glslc/src/main.cc" ((".*build-version.inc.*")
-                                                 "\"1\""))
-               (invoke "cmake" "-GNinja" "-DCMAKE_BUILD_TYPE=Release"
-                       "-DSHADERC_SKIP_TESTS=ON"
-                       "-DCMAKE_INSTALL_LIBDIR=lib"
-                       (string-append "-DCMAKE_INSTALL_PREFIX="
-                                      out)))))
-         (add-after 'unpack 'unpack-sources
-           (lambda* (#:key inputs #:allow-other-keys)
-             (let ((spirv-tools-source (assoc-ref inputs "spirv-tools-source"))
-                   (spirv-headers-source (assoc-ref inputs "spirv-headers-source"))
-                   (glslang-source (assoc-ref inputs "glslang-source")))
-               (copy-recursively spirv-tools-source "third_party/spirv-tools")
-               (copy-recursively spirv-headers-source
-                                 (string-append "third_party/spirv-tools"
-                                                "/external/spirv-headers"))
-               (copy-recursively glslang-source "third_party/glslang")
-               #t))))))
+         (add-after 'unpack 'do-not-look-for-bundled-sources
+           (lambda _
+             (substitute* "CMakeLists.txt"
+               (("add_subdirectory\\(third_party\\)")
+                ""))
+
+             (substitute* "glslc/test/CMakeLists.txt"
+               (("\\$<TARGET_FILE:spirv-dis>")
+                (which "spirv-dis")))
+
+             ;; Do not attempt to use git to encode version information.
+             (substitute* "glslc/CMakeLists.txt"
+               (("add_dependencies\\(glslc_exe build-version\\)")
+                ""))
+             (call-with-output-file "glslc/src/build-version.inc"
+               (lambda (port)
+                 (format port "\"~a\"\n\"~a\"\n\"~a\"~%"
+                         ,version
+                         ,(package-version spirv-tools)
+                         ,(package-version glslang))))
+             #t)))))
     (inputs
-     `(("googletest" ,googletest)
-       ("python" ,python)))
+     `(("glslang" ,glslang)
+       ("python" ,python)
+       ("spirv-headers" ,spirv-headers)
+       ("spirv-tools" ,spirv-tools)))
     (native-inputs
-     `(("cmake" ,cmake-minimal)
-       ("glslang-source" ,(package-source glslang))
-       ("pkg-config" ,pkg-config)
-       ("spirv-headers-source" ,(package-source spirv-headers))
-       ("spirv-tools-source" ,(package-source spirv-tools))))
+     `(("pkg-config" ,pkg-config)))
     (home-page "https://github.com/google/shaderc")
     (synopsis "Tools for shader compilation")
     (description "Shaderc is a collection of tools, libraries, and tests for
@@ -320,10 +357,10 @@ shader compilation.")
     (license license:asl2.0)))
 
 (define-public vkd3d
-  (let ((commit "ecda316ef54d70bf1b3e860755241bb75873e53f")) ; Release 1.1.
+  (let ((commit "56cd4a94d541707959ce7677af6d1a34739e5579")) ; Release 1.2.
     (package
      (name "vkd3d")
-     (version "1.1")
+     (version "1.2")
      (source
       (origin
        (method git-fetch)
@@ -332,11 +369,20 @@ shader compilation.")
              (commit commit)))
        (sha256
         (base32
-         "05a28kspy8gzng181w28zjqdb3pj2ss83b0lwnppxbcdzsz7rvrf"))
+         "1n4a622drgnprvz5hjxzyzcsg2lp5rlf1sajki2vzf5gsx6fdpk8"))
        (file-name (string-append name "-" version "-checkout"))))
      (build-system gnu-build-system)
      (arguments
-      `(#:configure-flags '("--with-spirv-tools")))
+      `(#:configure-flags '("--with-spirv-tools")
+        #:phases (modify-phases %standard-phases
+                   (add-after 'unpack 'patch-for-new-vulkan
+                     (lambda _
+                       ;; Mimic upstream commit 8e7bf8a5c3e0047 for
+                       ;; compatibility with newer vulkan-headers.
+                       (substitute* "libs/vkd3d/vkd3d_private.h"
+                         (("VK_PIPELINE_BIND_POINT_RANGE_SIZE")
+                          "2u"))
+                       #t)))))
      (native-inputs
       `(("autoconf" ,autoconf)
         ("automake" ,automake)