gnu: emacs-consult: Fix grammar.
[jackhill/guix/guix.git] / gnu / packages / gl.scm
index 4ea6515..7b5a0b4 100644 (file)
@@ -4,15 +4,16 @@
 ;;; Copyright © 2014, 2016 David Thompson <davet@gnu.org>
 ;;; Copyright © 2014, 2015, 2016, 2017 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2016 Nikita <nikita@n0.is>
-;;; Copyright © 2016, 2017, 2018, 2020 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2016, 2017, 2018, 2020, 2021 Ricardo Wurmus <rekado@elephly.net>
 ;;; Copyright © 2016 David Thompson <davet@gnu.org>
-;;; Copyright © 2017, 2018, 2019 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2017, 2018, 2019, 2021 Efraim Flashner <efraim@flashner.co.il>
 ;;; Copyright © 2017 Arun Isaac <arunisaac@systemreboot.net>
 ;;; Copyright © 2017, 2018, 2019 Rutger Helling <rhelling@mykolab.com>
-;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
+;;; Copyright © 2018, 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2019 Pierre Neidhardt <mail@ambrevar.xyz>
 ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
 ;;; Copyright © 2020 Giacomo Leidi <goodoldpaul@autistici.org>
+;;; Copyright © 2020 Kei Kebreau <kkebreau@posteo.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -60,6 +61,7 @@
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system cmake)
   #:use-module (guix build-system meson)
+  #:use-module (guix build-system waf)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix packages)
   #:use-module (guix utils)
@@ -193,7 +195,7 @@ Polygon meshes, and Extruded polygon meshes.")
      (origin
        (method git-fetch)
        (uri (git-reference
-             (url "https://github.com/divVerent/s2tc.git")
+             (url "https://github.com/divVerent/s2tc")
              (commit (string-append "v" version))))
        (file-name (git-file-name name version))
        (sha256
@@ -233,7 +235,7 @@ also known as DXTn or DXTC) for Mesa.")
 (define-public mesa
   (package
     (name "mesa")
-    (version "20.0.7")
+    (version "20.2.4")
     (source
       (origin
         (method url-fetch)
@@ -245,9 +247,9 @@ also known as DXTn or DXTC) for Mesa.")
                                   version "/mesa-" version ".tar.xz")))
         (sha256
          (base32
-          "0y517qpdg6v6dsdgzb365p03m30511sbyh8pq0mcvhvjwy7javpy"))
+          "14m09bk7akj0k02lg8fhvvzbdsashlbdsgl2cw7wbqfj2mhdqwh5"))
         (patches
-         (search-patches "mesa-skip-disk-cache-test.patch"))))
+         (search-patches "mesa-skip-tests.patch"))))
     (build-system meson-build-system)
     (propagated-inputs
       `(;; The following are in the Requires.private field of gl.pc.
@@ -268,12 +270,11 @@ also known as DXTn or DXTC) for Mesa.")
         ("libxrandr" ,libxrandr)
         ("libxvmc" ,libxvmc)
         ,@(match (%current-system)
-            ((or "x86_64-linux" "i686-linux")
+            ((or "x86_64-linux" "i686-linux" "powerpc64le-linux")
              ;; Note: update the 'clang' input of mesa-opencl when bumping this.
-             `(("llvm" ,llvm-9)))
+             `(("llvm" ,llvm-11)))
             (_
              `()))
-        ("makedepend" ,makedepend)
         ("wayland" ,wayland)
         ("wayland-protocols" ,wayland-protocols)))
     (native-inputs
@@ -281,7 +282,7 @@ also known as DXTn or DXTC) for Mesa.")
         ("flex" ,flex)
         ("gettext" ,gettext-minimal)
         ,@(match (%current-system)
-            ((or "x86_64-linux" "i686-linux")
+            ((or "x86_64-linux" "i686-linux" "powerpc64le-linux")
              `(("glslang" ,glslang)))
             (_
              `()))
@@ -289,12 +290,15 @@ also known as DXTn or DXTC) for Mesa.")
         ("python" ,python-wrapper)
         ("python-mako" ,python-mako)
         ("which" ,(@ (gnu packages base) which))))
+    (outputs '("out" "bin"))
     (arguments
      `(#:configure-flags
        '(,@(match (%current-system)
              ((or "armhf-linux" "aarch64-linux")
-              ;; TODO: Fix svga driver for aarch64 and armhf.
+              ;; TODO: Fix svga driver for non-Intel architectures.
               '("-Dgallium-drivers=etnaviv,freedreno,kmsro,lima,nouveau,panfrost,r300,r600,swrast,tegra,v3d,vc4,virgl"))
+             ("powerpc64le-linux"
+              '("-Dgallium-drivers=nouveau,r300,r600,radeonsi,swrast,virgl"))
              (_
               '("-Dgallium-drivers=iris,nouveau,r300,r600,radeonsi,svga,swrast,virgl")))
          ;; Enable various optional features.  TODO: opencl requires libclc,
@@ -311,16 +315,18 @@ also known as DXTn or DXTC) for Mesa.")
          "-Dgbm=true"
          "-Dshared-glapi=true"
 
-         ;; Enable Vulkan on i686-linux and x86-64-linux.
+         ;; Explicitly enable Vulkan on some architectures.
          ,@(match (%current-system)
              ((or "i686-linux" "x86_64-linux")
               '("-Dvulkan-drivers=intel,amd"))
+             ("powerpc64le-linux"
+              '("-Dvulkan-drivers=amd"))
              (_
               '("-Dvulkan-drivers=auto")))
 
-         ;; Enable the Vulkan overlay layer on i686-linux and x86-64-linux.
+         ;; Enable the Vulkan overlay layer on architectures using llvm.
          ,@(match (%current-system)
-             ((or "x86_64-linux" "i686-linux")
+             ((or "x86_64-linux" "i686-linux" "powerpc64le-linux")
               '("-Dvulkan-overlay-layer=true"))
              (_
               '()))
@@ -334,6 +340,9 @@ also known as DXTn or DXTC) for Mesa.")
              ((or "x86_64-linux" "i686-linux")
               '("-Ddri-drivers=i915,i965,nouveau,r200,r100"
                 "-Dllvm=true"))         ; default is x86/x86_64 only
+             ("powerpc64le-linux"
+              '("-Ddri-drivers=nouveau,r200,r100"
+                "-Dllvm=true"))
              (_
               '("-Ddri-drivers=nouveau,r200,r100"))))
 
@@ -347,32 +356,35 @@ also known as DXTn or DXTC) for Mesa.")
                   (guix build meson-build-system))
        #:phases
        (modify-phases %standard-phases
-         (add-after
-           'unpack 'patch-create_test_cases
-           (lambda _
-             (substitute* "src/intel/genxml/gen_pack_header.py"
-               (("/usr/bin/env python2") (which "python")))
-             #t))
+         ,@(if (string-prefix? "powerpc64le" (or (%current-target-system)
+                                                 (%current-system)))
+               ;; Disable some of the llvmpipe tests.
+               `((add-after 'unpack 'disable-failing-test
+                   (lambda _
+                     (substitute* "src/gallium/drivers/llvmpipe/lp_test_arit.c"
+                       (("0\\.5, ") ""))
+                     #t)))
+               '())
          ,@(if (string-prefix? "i686" (or (%current-target-system)
                                           (%current-system)))
                ;; Disable new test from Mesa 19 that fails on i686.  Upstream
                ;; report: <https://bugs.freedesktop.org/show_bug.cgi?id=110612>.
                `((add-after 'unpack 'disable-failing-test
                    (lambda _
-                     (substitute* "src/gallium/tests/unit/meson.build"
+                     (substitute* "src/util/tests/format/meson.build"
                        (("'u_format_test',") ""))
                      #t)))
                '())
-         (add-before
-           'configure 'fix-dlopen-libnames
+         (add-before 'configure 'fix-dlopen-libnames
            (lambda* (#:key inputs outputs #:allow-other-keys)
              (let ((out (assoc-ref outputs "out")))
                ;; Remain agnostic to .so.X.Y.Z versions while doing
                ;; the substitutions so we're future-safe.
-               (substitute* "src/glx/dri_common.c"
-                 (("dlopen\\(\"libGL\\.so")
-                  (string-append "dlopen(\"" out "/lib/libGL.so")))
-               (substitute* "src/egl/drivers/dri2/egl_dri2.c"
+               (substitute* "src/glx/meson.build"
+                 (("-DGL_LIB_NAME=\"lib@0@\\.so\\.@1@\"")
+                  (string-append "-DGL_LIB_NAME=\"" out
+                                 "/lib/lib@0@.so.@1@\"")))
+               (substitute* "src/gbm/backends/dri/gbm_dri.c"
                  (("\"libglapi\\.so")
                   (string-append "\"" out "/lib/libglapi.so")))
                (substitute* "src/gbm/main/backend.c"
@@ -382,6 +394,26 @@ also known as DXTn or DXTC) for Mesa.")
                  (("\"gbm_dri\\.so")
                   (string-append "\"" out "/lib/dri/gbm_dri.so")))
                #t)))
+         (add-after 'install 'split-outputs
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let ((out (assoc-ref outputs "out"))
+                   (bin (assoc-ref outputs "bin")))
+               ,@(match (%current-system)
+                   ((or "i686-linux" "x86_64-linux" "powerpc64le-linux")
+                    ;; Install the Vulkan overlay control script to a separate
+                    ;; output to prevent a reference on Python, saving ~70 MiB
+                    ;; on the closure size.
+                    '((copy-recursively (string-append out "/bin")
+                                        (string-append bin "/bin"))
+                      (delete-file-recursively (string-append out "/bin"))))
+                   (_
+                    ;; XXX: On architectures without the Vulkan overlay layer
+                    ;; just create an empty file because outputs can not be
+                    ;; added conditionally.
+                    '((mkdir-p (string-append bin "/bin"))
+                      (call-with-output-file (string-append bin "/bin/.empty")
+                        (const #t)))))
+               #t)))
          (add-after 'install 'symlinks-instead-of-hard-links
            (lambda* (#:key outputs #:allow-other-keys)
              ;; All the drivers and gallium targets create hard links upon
@@ -426,8 +458,7 @@ from software emulation to complete hardware acceleration for modern GPUs.")
     (license license:x11)))
 
 (define-public mesa-opencl
-  (package
-    (inherit mesa)
+  (package/inherit mesa
     (name "mesa-opencl")
     (arguments
      (substitute-keyword-arguments (package-arguments mesa)
@@ -437,12 +468,11 @@ from software emulation to complete hardware acceleration for modern GPUs.")
      `(("libclc" ,libclc)
        ,@(package-inputs mesa)))
     (native-inputs
-     `(("clang" ,clang-9)
+     `(("clang" ,clang-11)
        ,@(package-native-inputs mesa)))))
 
 (define-public mesa-opencl-icd
-  (package
-    (inherit mesa-opencl)
+  (package/inherit mesa-opencl
     (name "mesa-opencl-icd")
     (arguments
      (substitute-keyword-arguments (package-arguments mesa)
@@ -451,12 +481,12 @@ from software emulation to complete hardware acceleration for modern GPUs.")
                ,(delete "-Dgallium-opencl=standalone" flags)))))))
 
 (define-public mesa-headers
-  (package
-    (inherit mesa)
+  (package/inherit mesa
     (name "mesa-headers")
     (propagated-inputs '())
     (inputs '())
     (native-inputs '())
+    (outputs '("out"))
     (arguments
      '(#:phases
        (modify-phases %standard-phases
@@ -586,6 +616,11 @@ extension functionality is exposed in a single header file.")
                         "godir = $(moddir)\n"))))
                  (add-before 'build 'patch-dynamic-link
                    (lambda* (#:key inputs outputs #:allow-other-keys)
+                     (substitute* "gl/runtime.scm"
+                       (("\\(dynamic-link\\)")
+                        (string-append "(dynamic-link \""
+                                       (assoc-ref inputs "mesa")
+                                       "/lib/libGL.so" "\")")))
                      (define (dynamic-link-substitute file lib input)
                        (substitute* file
                          (("dynamic-link \"lib([a-zA-Z]+)\"" _ lib)
@@ -664,6 +699,53 @@ OpenGL graphics API.")
      "A library for handling OpenGL function pointer management.")
     (license license:x11)))
 
+(define-public libglvnd
+  (package
+    (name "libglvnd")
+    (version "1.3.2")
+    (home-page "https://gitlab.freedesktop.org/glvnd/libglvnd")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url home-page)
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "10x7fgb114r4gikdg6flszl3kwzcb9y5qa7sj9936mk0zxhjaylz"))))
+    (build-system meson-build-system)
+    (arguments
+     '(#:configure-flags '("-Dx11=enabled")
+       #:phases (modify-phases %standard-phases
+                  (add-after 'unpack 'disable-glx-tests
+                    (lambda _
+                      ;; This package is meant to be used alongside Mesa.
+                      ;; To avoid a circular dependency, disable tests that
+                      ;; require a running Xorg server.
+                      (substitute* "tests/meson.build"
+                        (("if with_glx")
+                         "if false"))
+                      #t)))))
+    (native-inputs
+     `(("pkg-config" ,pkg-config)))
+    (inputs
+     `(("libx11" ,libx11)
+       ("libxext" ,libxext)
+       ("xorgproto" ,xorgproto)))
+    (synopsis "Vendor-neutral OpenGL dispatch library")
+    (description
+     "libglvnd is a vendor-neutral dispatch layer for arbitrating OpenGL
+API calls between multiple vendors.  It allows multiple drivers from
+different vendors to coexist on the same file system, and determines which
+vendor to dispatch each API call to at runtime.
+
+Both GLX and EGL are supported, in any combination with OpenGL and OpenGL ES.")
+    ;; libglvnd is available under a custom X11-style license, and incorporates
+    ;; code with various other licenses.  See README.md for details.
+    (license (list (license:x11-style "file://README.md")
+                   license:x11
+                   license:expat))))
+
 (define-public soil
   (package
     (name "soil")
@@ -709,7 +791,7 @@ OpenGL.")
 (define-public glfw
   (package
     (name "glfw")
-    (version "3.2.1")
+    (version "3.3.4")
     (source (origin
               (method url-fetch)
               (uri (string-append "https://github.com/glfw/glfw"
@@ -717,7 +799,7 @@ OpenGL.")
                                   "/glfw-" version ".zip"))
               (sha256
                (base32
-                "09kk5yc1zhss9add8ryqrngrr16hdmc94rszgng135bhw09mxmdp"))))
+                "1kcrpl4d6b6h23ib5j9q670d9w3knd07whgbanbmwwhbcqnc9lmv"))))
     (build-system cmake-build-system)
     (arguments
      '(#:tests? #f ; no test target
@@ -731,6 +813,7 @@ OpenGL.")
        ;; These are in 'Requires.private' of 'glfw3.pc'.
        ("libx11" ,libx11)
        ("libxrandr" ,libxrandr)
+       ("libxi" ,libxi)
        ("libxinerama" ,libxinerama)
        ("libxcursor" ,libxcursor)
        ("libxxf86vm" ,libxxf86vm)))
@@ -752,7 +835,7 @@ and surfaces, receiving input and events.")
       (source (origin
                 (method git-fetch)
                 (uri (git-reference
-                      (url "https://github.com/extemporelang/nanovg.git")
+                      (url "https://github.com/extemporelang/nanovg")
                       (commit commit)))
                 (file-name (git-file-name name version))
                 (sha256
@@ -775,7 +858,7 @@ and visualizations.")
 (define-public gl2ps
   (package
     (name "gl2ps")
-    (version "1.4.0")
+    (version "1.4.2")
     (source
      (origin
        (method url-fetch)
@@ -783,15 +866,14 @@ and visualizations.")
              "http://geuz.org/gl2ps/src/gl2ps-"
              version ".tgz"))
        (sha256
-        (base32
-         "1qpidkz8x3bxqf69hlhyz1m0jmfi9kq24fxsp7rq6wfqzinmxjq3"))))
+        (base32 "1sgzv547h7hrskb9qd0x5yp45kmhvibjwj2mfswv95lg070h074d"))))
     (build-system cmake-build-system)
     (inputs
      `(("libpng" ,libpng)
        ("mesa" ,mesa)
        ("zlib" ,zlib)))
     (arguments
-     `(#:tests? #f))  ;; no tests
+     `(#:tests? #f))                    ; no tests
     (home-page "http://www.geuz.org/gl2ps/")
     (synopsis "OpenGL to PostScript printing library")
     (description "GL2PS is a C library providing high quality vector
@@ -813,7 +895,7 @@ mixed vector/bitmap output.")
      (origin
        (method git-fetch)
        (uri (git-reference
-             (url "https://github.com/VirtualGL/virtualgl.git")
+             (url "https://github.com/VirtualGL/virtualgl")
              (commit version)))
        (file-name (git-file-name name version))
        (sha256
@@ -955,3 +1037,62 @@ the glProgramViewportFlip before it was replaced with glProgramViewportInfo.")
 The C# wrapper was written to be used for FNA's platform support.  However, this
 is written in a way that can be used for any general C# application.")
       (license license:zlib))))
+
+(define-public glmark2
+  (package
+    (name "glmark2")
+    (version "2020.04")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/glmark2/glmark2")
+                    (commit version)))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "0ywpzp0imi3f8iyp7d1739576zx2nsr3db5hp2as4yhflfyq1as2"))
+              (modules '((guix build utils)))
+              ;; Fix Python 3 incompatibility.
+              (snippet
+               '(begin
+                  (substitute* "wscript"
+                    (("(sorted\\()FLAVORS\\.keys\\(\\)(.*)" _ beginning end)
+                     (string-append beginning "list(FLAVORS)" end)))
+                  #t))))
+    (build-system waf-build-system)
+    (arguments
+     '(#:tests? #f                      ; no check target
+       #:configure-flags
+       (list (string-append "--with-flavors="
+                            (string-join '("x11-gl" "x11-glesv2"
+                                           "drm-gl" "drm-glesv2"
+                                           "wayland-gl" "wayland-glesv2")
+                                         ",")))
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'patch-paths
+           (lambda* (#:key inputs #:allow-other-keys)
+             (let ((mesa (assoc-ref inputs "mesa")))
+               (substitute* (find-files "src" "gl-state-.*\\.cpp$")
+                 (("libGL.so") (string-append mesa "/lib/libGL.so"))
+                 (("libEGL.so") (string-append mesa "/lib/libEGL.so"))
+                 (("libGLESv2.so") (string-append mesa "/lib/libGLESv2.so")))
+               #t))))))
+    (native-inputs
+     `(("pkg-config" ,pkg-config)))
+    (inputs
+     `(("eudev" ,eudev)
+       ("libdrm" ,libdrm)
+       ("libjpeg-turbo" ,libjpeg-turbo)
+       ("libpng" ,libpng)
+       ("libx11" ,libx11)
+       ("libxcb" ,libxcb)
+       ("mesa" ,mesa)
+       ("wayland" ,wayland)
+       ("wayland-protocols" ,wayland-protocols)))
+    (home-page "https://github.com/glmark2/glmark2")
+    (synopsis "OpenGL 2.0 and OpenGL ES 2.0 benchmark")
+    (description
+     "glmark2 is an OpenGL 2.0 and OpenGL ES 2.0 benchmark based on the
+original glmark benchmark by Ben Smith.")
+    (license license:gpl3+)))