projects/guix·blob ruby-team · refs

1454 lines · 61.5 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2013, 2015, 2024 Andreas Enge <[email protected]>
3;;; Copyright © 2013 Joshua Grant <[email protected]>
4;;; Copyright © 2014, 2016 David Thompson <[email protected]>
5;;; Copyright © 2014, 2015, 2016, 2017 Mark H Weaver <[email protected]>
6;;; Copyright © 2016 Nikita <[email protected]>
7;;; Copyright © 2016, 2017, 2018, 2020, 2021 Ricardo Wurmus <[email protected]>
8;;; Copyright © 2017-2019, 2021, 2023-2026 Efraim Flashner <[email protected]>
9;;; Copyright © 2017 Arun Isaac <[email protected]>
10;;; Copyright © 2017, 2018, 2019 Rutger Helling <[email protected]>
11;;; Copyright © 2018–2021 Tobias Geerinckx-Rice <[email protected]>
12;;; Copyright © 2019 Pierre Neidhardt <[email protected]>
13;;; Copyright © 2020 Marius Bakke <[email protected]>
14;;; Copyright © 2020 Giacomo Leidi <[email protected]>
15;;; Copyright © 2020, 2021, 2022, 2023, 2025 Maxim Cournoyer <[email protected]>
16;;; Copyright © 2020 Kei Kebreau <[email protected]>
17;;; Copyright © 2021 Ivan Gankevich <[email protected]>
18;;; Copyright © 2021-2025 John Kehayias <[email protected]>
19;;; Copyright © 2022 Petr Hodina <[email protected]>
20;;; Copyright © 2023 Kaelyn Takata <[email protected]>
21;;; Copyright © 2023, 2024 Zheng Junjie <[email protected]>
22;;; Copyright © 2024 Liliana Marie Prikler <[email protected]>
23;;; Copyright © 2024 Artyom V. Poptsov <[email protected]>
24;;; Copyright © 2024 Arnaud Lechevallier <[email protected]>
25;;; Copyright © 2024-2025 Alvin Hsu <[email protected]>
26;;; Copyright © 2025 Sughosha <[email protected]>
27;;;
28;;; This file is part of GNU Guix.
29;;;
30;;; GNU Guix is free software; you can redistribute it and/or modify it
31;;; under the terms of the GNU General Public License as published by
32;;; the Free Software Foundation; either version 3 of the License, or (at
33;;; your option) any later version.
34;;;
35;;; GNU Guix is distributed in the hope that it will be useful, but
36;;; WITHOUT ANY WARRANTY; without even the implied warranty of
37;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
38;;; GNU General Public License for more details.
39;;;
40;;; You should have received a copy of the GNU General Public License
41;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
42
43(define-module (gnu packages gl)
44 #:use-module (gnu packages)
45 #:use-module (gnu packages autotools)
46 #:use-module (gnu packages backup)
47 #:use-module (gnu packages bison)
48 #:use-module (gnu packages build-tools)
49 #:use-module (gnu packages check)
50 #:use-module (gnu packages compression)
51 #:use-module (gnu packages documentation)
52 #:use-module (gnu packages elf)
53 #:use-module (gnu packages compiler-tools)
54 #:use-module (gnu packages fontutils)
55 #:use-module (gnu packages freedesktop)
56 #:use-module (gnu packages gettext)
57 #:use-module (gnu packages guile)
58 #:use-module (gnu packages image)
59 #:use-module (gnu packages linux)
60 #:use-module (gnu packages llvm)
61 #:use-module (gnu packages lua)
62 #:use-module (gnu packages pkg-config)
63 #:use-module (gnu packages python)
64 #:use-module (gnu packages python-build)
65 #:use-module (gnu packages python-xyz)
66 #:use-module (gnu packages rust)
67 #:use-module (gnu packages rust-apps)
68 #:use-module (gnu packages tls)
69 #:use-module (gnu packages video)
70 #:use-module (gnu packages vulkan)
71 #:use-module (gnu packages xdisorg)
72 #:use-module (gnu packages xml)
73 #:use-module (gnu packages xorg)
74 #:use-module (guix download)
75 #:use-module (guix git-download)
76 #:use-module (guix hg-download)
77 #:use-module (gnu packages cmake)
78 #:use-module (guix build-system gnu)
79 #:use-module (guix build-system cargo)
80 #:use-module (guix build-system cmake)
81 #:use-module (guix build-system meson)
82 #:use-module (guix build-system pyproject)
83 #:use-module ((guix licenses) #:prefix license:)
84 #:use-module (guix packages)
85 #:use-module (guix gexp)
86 #:use-module (guix utils)
87 #:use-module (ice-9 match)
88 #:use-module ((srfi srfi-1) #:hide (zip))
89 #:use-module (srfi srfi-26))
90
91(define-public glu
92 (package
93 (name "glu")
94 (version "9.0.2")
95 (source (origin
96 (method git-fetch)
97 (uri (git-reference
98 (url "https://gitlab.freedesktop.org/mesa/glu")
99 (commit (string-append "glu-" version))))
100 (file-name (git-file-name name version))
101 (sha256
102 (base32
103 "1khxfidyglpx4yd8f3xvrj05ah823cz1ygcszhcaa4w7h9kd1lbr"))))
104 (build-system gnu-build-system)
105 (native-inputs
106 (list pkg-config
107 autoconf
108 automake
109 libtool))
110 (propagated-inputs
111 (list mesa)) ; according to glu.pc
112 (home-page "http://www.opengl.org/archives/resources/faq/technical/glu.htm")
113 (synopsis "Mesa OpenGL Utility library")
114 (description
115 "GLU, or OpenGL Utility Library provides some higher-level functionality
116not provided by just OpenGL itself. Some of GLU's Features
117include: Scaling of 2D images and creation of mipmap pyramids,
118Transformation of object coordinates into device coordinates and
119vice versa, Support for NURBS surfaces, Support for tessellation
120of concave or bow tie polygonal primitives, Specialty transformation
121matrices for creating perspective and orthographic projections,
122positioning a camera, and selection/picking, Rendering of disk,
123cylinder, and sphere primitives, Interpreting OpenGL error values
124as ASCII text.")
125 (license (license:x11-style "http://directory.fsf.org/wiki/License:SGIFreeBv2"))))
126
127(define-public freeglut
128 (package
129 (name "freeglut")
130 (version "3.4.0")
131 (source (origin
132 (method url-fetch)
133 (uri (string-append
134 "https://github.com/FreeGLUTProject/freeglut/releases"
135 "/download/v" version "/freeglut-" version ".tar.gz"))
136 (sha256
137 (base32
138 "1v7ayg3a03mv8b6lsr1qm21lbr8xg8dh3gdfxnbhl64vbn8wn2rw"))))
139 (build-system cmake-build-system)
140 (arguments
141 '(#:tests? #f ;no test target
142 #:configure-flags '("-DFREEGLUT_BUILD_STATIC_LIBS=OFF")))
143 (inputs (list libx11 libxi libxrandr libxxf86vm))
144 (propagated-inputs
145 ;; Headers from Mesa and GLU are needed.
146 (list glu mesa))
147 (home-page "https://freeglut.sourceforge.net/")
148 (synopsis "Alternative to the OpenGL Utility Toolkit (GLUT)")
149 (description
150 "Freeglut is a completely Free/OpenSourced alternative to
151the OpenGL Utility Toolkit (GLUT) library. GLUT was originally
152written by Mark Kilgard to support the sample programs in the
153second edition OpenGL @code{RedBook}. Since then, GLUT has been used
154in a wide variety of practical applications because it is simple,
155widely available and highly portable.
156
157GLUT (and hence freeglut) allows the user to create and manage windows
158containing OpenGL contexts on a wide range of platforms and also read
159the mouse, keyboard and joystick functions. Freeglut is released under
160the X-Consortium license.")
161 (license license:x11)))
162
163(define-public ftgl
164 (package
165 (name "ftgl")
166 (version "2.4.0")
167 (home-page "https://github.com/frankheckenbach/ftgl")
168 (source (origin
169 (method git-fetch)
170 (uri (git-reference (url home-page)
171 (commit (string-append "v" version))))
172 (file-name (git-file-name name version))
173 (sha256
174 (base32
175 "0zjs1h9w30gajq9lndzvjsa26rsmr1081lb1fbpbj10yhcdcsc79"))
176 (patches (search-patches "ftgl-ftcontour-type.patch"))))
177 (build-system gnu-build-system)
178 (arguments
179 `(#:configure-flags
180 '("--disable-static"
181 ;; XXX: FTVectoriser.cpp: conversion from ‘unsigned char*’ to ‘char*’
182 "CXXFLAGS=-fpermissive")))
183 ;; The pkg-config file lists "freetype2" as Requires.private.
184 (propagated-inputs (list freetype))
185 (inputs (list libx11 mesa glu))
186 (native-inputs
187 (list pkg-config autoconf automake libtool))
188 (synopsis "Font rendering library for OpenGL applications")
189 (description
190 "FTGL is a font rendering library for OpenGL applications. Supported
191rendering modes are: Bitmaps, Anti-aliased pixmaps, Texture maps, Outlines,
192Polygon meshes, and Extruded polygon meshes.")
193 (license license:x11)))
194
195(define-public glad-0.1
196 (package
197 (name "glad")
198 (version "0.1.36")
199 (source
200 (origin
201 (method git-fetch)
202 (uri (git-reference
203 (url "https://github.com/Dav1dde/glad")
204 (commit (string-append "v" version))))
205 (file-name (git-file-name name version))
206 (sha256
207 (base32 "0m55ya1zrmg6n2cljkajy80ilmi5sblln8742fm0k1sw9k7hzn8n"))))
208 (build-system pyproject-build-system)
209 (arguments
210 (list
211 ;; XXX: testing seems complex, see utility/compiletest.sh
212 #:tests? #f
213 #:phases
214 #~(modify-phases %standard-phases
215 (add-after 'install 'install-cmakelists.txt
216 (lambda _
217 (let ((share (string-append #$output "/share/"
218 #$(package-name this-package))))
219 (install-file "CMakeLists.txt" share)))))))
220 (native-inputs (list python-setuptools))
221 (home-page "https://github.com/Dav1dde/glad")
222 (synopsis "Multi-language GL/GLES/EGL/GLX/WGL loader generator")
223 (description "Glad uses the official Khronos XML specifications to
224generate a GL/GLES/EGL/GLX/WGL loader tailored for specific requirements.")
225 (license license:expat)))
226
227(define-public glad
228 (package
229 (name "glad")
230 (version "2.0.8")
231 (source (origin
232 (method git-fetch)
233 (uri (git-reference
234 (url "https://github.com/Dav1dde/glad")
235 (commit (string-append "v" version))))
236 (file-name (git-file-name name version))
237 (sha256
238 (base32
239 "0c9cygiq35aiq6bpdvbwqs0wxc2dvxsh4jnx50466savscxalsk9"))))
240 (build-system pyproject-build-system)
241 (arguments
242 (list
243 #:phases
244 #~(modify-phases %standard-phases
245 (add-after 'install 'install-cmakelists.txt
246 (lambda _
247 (let ((share (string-append #$output "/share/"
248 #$(package-name this-package))))
249 (install-file "cmake/CMakeLists.txt" share)
250 (install-file "cmake/GladConfig.cmake" share))))
251 (replace 'check
252 (lambda* (#:key tests? #:allow-other-keys)
253 (when tests?
254 (invoke "xvfb-run" "utility/test.sh")))))))
255 (native-inputs (list python-setuptools xvfb-run-for-tests))
256 (propagated-inputs (list python-jinja2))
257 (home-page "https://github.com/Dav1dde/glad")
258 (synopsis "Multi-language GL/GLES/EGL/GLX/WGL loader generator")
259 (description "Glad uses the official Khronos XML specifications to
260generate a GL/GLES/EGL/GLX/WGL loader tailored for specific requirements.")
261 (license license:expat)))
262
263(define-public s2tc
264 (package
265 (name "s2tc")
266 (version "1.0")
267 (source
268 (origin
269 (method git-fetch)
270 (uri (git-reference
271 (url "https://github.com/divVerent/s2tc")
272 (commit (string-append "v" version))))
273 (file-name (git-file-name name version))
274 (sha256
275 (base32 "1fg323fk7wlv2xh6lw66wswgcv6qi8aaadk7c28h2f2lj1s7njnf"))))
276 (build-system gnu-build-system)
277 (native-inputs
278 (list autoconf automake libtool))
279 (inputs
280 (list mesa-headers))
281 (home-page "https://github.com/divVerent/s2tc")
282 (synopsis "S3 Texture Compression implementation")
283 (description
284 "S2TC is a patent-free implementation of S3 Texture Compression (S3TC,
285also known as DXTn or DXTC) for Mesa.")
286 (license license:expat)))
287
288;;; Mesa needs LibVA headers to build its Gallium-based VA API implementation;
289;;; LibVA itself depends on Mesa. We use the following to solve the circular
290;;; dependency.
291(define libva-without-mesa
292 ;; Delay to work around circular import problem.
293 (delay
294 (package
295 (inherit libva)
296 (name "libva-without-mesa")
297 (inputs (fold alist-delete (package-inputs libva)
298 '("mesa" "wayland")))
299 (arguments
300 (strip-keyword-arguments
301 '(#:make-flags)
302 (substitute-keyword-arguments arguments
303 ((#:configure-flags flags)
304 '(list "--disable-glx"))))))))
305
306(define-public mesa
307 (package
308 (name "mesa")
309 (version "26.0.2")
310 (source
311 (origin
312 (method url-fetch)
313 (uri (list (string-append "https://archive.mesa3d.org/"
314 "mesa-" version ".tar.xz")
315 (string-append "ftp://ftp.freedesktop.org/pub/mesa/"
316 "mesa-" version ".tar.xz")))
317 (sha256
318 (base32 "0ikk7hb60q581i2wb1pasphv7sgqkv74qaw4cdiiq8dy45956gwp"))))
319 (build-system meson-build-system)
320 (propagated-inputs
321 ;; The following are in the Requires.private field of gl.pc.
322 (list libdrm
323 libvdpau
324 libx11
325 libxdamage
326 libxfixes
327 libxshmfence
328 libxxf86vm
329 xorgproto))
330 (inputs
331 (append
332 (list elfutils ;libelf required for r600 when using llvm
333 expat
334 (force libva-without-mesa)
335 libxml2
336 libxrandr
337 libxvmc
338 llvm-for-mesa
339 vulkan-loader
340 wayland
341 wayland-protocols
342 `(,zstd "lib"))
343 ;; The freedreno driver wants libarchive and lua.
344 (if (target-arm?)
345 (list libarchive
346 lua-5.4)
347 '())
348 ;; Rust isn't needed for all architectures.
349 (if (and (target-x86-64?) (target-linux?))
350 ;; NVK dependencies
351 (cargo-inputs 'mesa)
352 '())))
353 (native-inputs
354 (append
355 (list bison
356 clang-18 ;ensure rust-bindgen-cli uses the same
357 flex
358 gettext-minimal
359 glslang
360 libclc
361 pkg-config
362 python-mako
363 python-packaging
364 python-ply
365 python-pyyaml
366 python-wrapper
367 (@ (gnu packages base) which))
368 (if (target-arm?)
369 ;; Needed for etnaviv.
370 (list python-pycparser)
371 '())
372 (if (%current-target-system)
373 (list cmake-minimal-cross
374 pkg-config-for-build
375 wayland
376 wayland-protocols)
377 '())
378 ;; Rust isn't needed for all architectures.
379 (if (and (target-x86-64?) (target-linux?))
380 ;; NVK dependencies
381 (list rust
382 rust-bindgen-cli
383 rust-cbindgen)
384 '())))
385 (outputs '("out" "bin"))
386 (arguments
387 (list
388 #:configure-flags
389 #~(list
390 #$@(cond
391 ((target-aarch64?)
392 ;; This includes more drivers than "auto": r300, r600
393 '("-Dgallium-drivers=asahi,etnaviv,freedreno,iris,lima,nouveau,\
394panfrost,r300,r600,svga,softpipe,lima,llvmpipe,tegra,v3d,vc4,virgl,zink"))
395 ((target-arm32?)
396 ;; This includes more drivers than "auto": r300, r600
397 '("-Dgallium-drivers=etnaviv,freedreno,iris,lima,nouveau,\
398panfrost,r300,r600,svga,softpipe,lima,llvmpipe,tegra,v3d,vc4,virgl,zink"))
399 ((or (target-ppc64le?) (target-ppc32?) (target-riscv64?))
400 ;; This includes more drivers than "auto": svga
401 '("-Dgallium-drivers=nouveau,r300,r600,radeonsi,svga,softpipe,llvmpipe,virgl,zink"))
402 (else
403 '("-Dgallium-drivers=auto")))
404 ;; Enable various optional features. TODO: opencl requires libclc,
405 ;; omx requires libomxil-bellagio
406 "-Dplatforms=x11,wayland"
407 "-Dglx=dri" ;Thread Local Storage, improves performance
408 ;; "-Dopencl=true"
409 ;; "-Domx=true"
410
411 ;; features required by wayland
412 "-Dgles2=enabled"
413 "-Dgbm=enabled"
414 "--wrap-mode=nodownload" ; XXX: disable
415
416 #$@(cond
417 ;; Increase the number of vulkan drivers on each architecture:
418 ((target-x86-32?)
419 ;; TODO: Reenable nouveau/NVK when rust support lands.
420 '("-Dvulkan-drivers=amd,intel,intel_hasvk,swrast,virtio"))
421 ((target-x86-64?)
422 '("-Dvulkan-drivers=amd,intel,intel_hasvk,nouveau,swrast,virtio"))
423 ((target-arm32?)
424 '("-Dvulkan-drivers=swrast,intel,panfrost,freedreno,virtio"))
425 ((target-aarch64?)
426 ;; This includes more drivers than "auto": amd, broadcom
427 '("-Dvulkan-drivers=swrast,intel,panfrost,freedreno,asahi,amd,broadcom,virtio"))
428 ;; The default fallback seems to be amd and swrast.
429 ((target-linux?)
430 '("-Dvulkan-drivers=amd,swrast,virtio"))
431 (else
432 '("-Dvulkan-drivers=auto")))
433
434 ;; Enable the Vulkan overlay layer on all architectures.
435 "-Dvulkan-layers=device-select,overlay"
436
437 ;; Enable all the codecs that were built by default as part of the
438 ;; 21.3.x releases to avoid functionality regressions.
439 "-Dvideo-codecs=all"
440
441 ;; Enable ZSTD compression for shader cache.
442 "-Dzstd=enabled"
443
444 ;; Also enable the tests.
445 "-Dbuild-tests=true"
446
447 "-Dllvm=enabled") ; default is x86/x86_64 only
448
449 ;; XXX: 'debugoptimized' causes LTO link failures on some drivers. The
450 ;; documentation recommends using 'release' for performance anyway.
451 #:build-type "release"
452
453 #:modules '((ice-9 match)
454 (ice-9 ftw)
455 (srfi srfi-1)
456 (guix build utils)
457 ((guix build cargo-build-system) #:prefix cargo:)
458 (guix build meson-build-system))
459 #:imported-modules (append %cargo-build-system-modules
460 %meson-build-system-modules)
461 #:phases
462 #~(modify-phases %standard-phases
463 #$@(if (%current-target-system)
464 #~((add-after 'unpack 'fix-cross-compiling
465 (lambda* (#:key native-inputs #:allow-other-keys)
466 ;; When cross compiling, we use cmake to find llvm, not
467 ;; llvm-config, because llvm-config cannot be executed
468 ;; see https://github.com/llvm/llvm-project/issues/58984
469 (substitute* "meson.build"
470 (("method : host_machine\\.system.*")
471 "method : 'cmake',\n"))
472 (setenv "CMAKE"
473 (search-input-file
474 native-inputs "/bin/cmake")))))
475 #~())
476 #$@(if (this-package-native-input "rust")
477 #~((add-after 'unpack 'prepare-rust-crates
478 (lambda args
479 (apply (assoc-ref cargo:%standard-phases
480 'prepare-rust-crates)
481 args)
482 ;; Use /tmp/rust-crates as the source.
483 (substitute* (find-files "subprojects" "-rs\\.wrap$")
484 (("source_url = (.*)" _ url)
485 (let ((split-url (string-split url #\/)))
486 (string-append
487 "source_url = file:///tmp/rust-crates/rust-"
488 (string-join
489 (string-split (list-ref split-url 6) #\_) "-")
490 "-" (list-ref split-url 7) ".tar.gz\n"))))
491 ;; "Download" the packages.
492 (for-each
493 (lambda (wrapper)
494 (invoke "meson" "subprojects" "download"
495 (string-drop-right wrapper 5)))
496 (scandir "subprojects"
497 (lambda (file)
498 (string-suffix? "-rs.wrap" file)))))))
499 #~())
500 (add-after 'unpack 'disable-failing-test
501 (lambda _
502 ;; Disable the intel vulkan (anv_state_pool) tests, as they may
503 ;; fail in a nondeterministic fashion (see:
504 ;; https://gitlab.freedesktop.org/mesa/mesa/-/issues/5446).
505 (substitute* "src/intel/vulkan/meson.build"
506 (("if with_tests")
507 "if false"))
508 #$@(match (%current-system)
509 ("riscv64-linux"
510 ;; Disable some of the llvmpipe tests.
511 `((substitute* "src/gallium/drivers/llvmpipe/meson.build"
512 (("if with_tests") "if false"))))
513 ("powerpc64le-linux"
514 ;; Disable some of the llvmpipe tests.
515 `((substitute* "src/gallium/drivers/llvmpipe/lp_test_arit.c"
516 (("0\\.5, ") ""))))
517 ("powerpc-linux"
518 ;; There are some tests which fail specifically on powerpc.
519 `((substitute* '(;; LLVM ERROR: Relocation type not implemented yet!
520 "src/gallium/drivers/llvmpipe/meson.build"
521 "src/gallium/targets/osmesa/meson.build")
522 (("if with_tests") "if not with_tests"))
523 ;; This is probably a big-endian test failure.
524 (substitute* "src/amd/common/meson.build"
525 (("and not with_platform_windows")
526 "and with_platform_windows"))))
527 ("i686-linux"
528 ;; This test is known to fail on i686 (see:
529 ;; https://gitlab.freedesktop.org/mesa/mesa/-/issues/4091).
530 `((substitute* "src/util/meson.build"
531 ((".*'tests/u_debug_stack_test.cpp',.*") ""))))
532 ("aarch64-linux"
533 ;; Disable some of the llvmpipe tests.
534 `((substitute* "src/gallium/drivers/llvmpipe/meson.build"
535 (("'lp_test_format', ") ""))))
536 ("armhf-linux"
537 ;; Disable some of the llvmpipe tests.
538 `((substitute* "src/gallium/drivers/llvmpipe/meson.build"
539 (("'lp_test_arit', ") ""))))
540 (_
541 '((display "No tests to disable on this architecture.\n"))))))
542 (add-after 'unpack 'set-home-directory
543 ;; Build tries to use a shader cache (non-fatal error).
544 (lambda _ (setenv "HOME" "/tmp")))
545 (add-before 'configure 'fix-dlopen-libnames
546 (lambda* (#:key inputs #:allow-other-keys)
547 (let ((out #$output))
548 ;; Remain agnostic to .so.X.Y.Z versions while doing
549 ;; the substitutions so we're future-safe.
550 (substitute* "src/glx/meson.build"
551 (("-DGL_LIB_NAME=\"lib@0@\\.so\\.@1@\"")
552 (string-append "-DGL_LIB_NAME=\"" out
553 "/lib/lib@[email protected].@1@\"")))
554 (substitute* "src/gbm/backends/dri/gbm_dri.c"
555 (("\"libglapi\\.so")
556 (string-append "\"" out "/lib/libglapi.so")))
557 (substitute* "src/gbm/main/backend.c"
558 ;; No need to patch the gbm_gallium_drm.so reference;
559 ;; it's never installed since Mesa removed its
560 ;; egl_gallium support.
561 (("\"gbm_dri\\.so")
562 (string-append "\"" out "/lib/dri/gbm_dri.so")))
563 (substitute* "src/gallium/drivers/zink/zink_screen.c"
564 (("util_dl_open\\(VK_LIBNAME\\)")
565 (format #f "util_dl_open(\"~a\")"
566 (search-input-file inputs
567 "lib/libvulkan.so.1")))))))
568 (add-after 'install 'split-outputs
569 (lambda _
570 (let ((out #$output)
571 (bin #$output:bin))
572 ;; Not all architectures have the Vulkan overlay control script.
573 (mkdir-p (string-append out "/bin"))
574 (call-with-output-file (string-append out "/bin/.empty")
575 (const #t))
576 (copy-recursively (string-append out "/bin")
577 (string-append bin "/bin"))
578 (delete-file-recursively (string-append out "/bin")))))
579 (add-after 'install 'symlinks-instead-of-hard-links
580 (lambda _
581 ;; All the drivers and gallium targets create hard links upon
582 ;; installation (search for "hardlink each megadriver instance"
583 ;; in the makefiles). This is no good for us since we'd produce
584 ;; nars that contain several copies of these files. Thus, turn
585 ;; them into symlinks, which saves ~124 MiB.
586 (let* ((out #$output)
587 (lib (string-append out "/lib"))
588 (files (find-files lib
589 (lambda (file stat)
590 (and (string-contains file ".so")
591 (eq? 'regular
592 (stat:type stat))))))
593 (inodes (map (compose stat:ino stat) files)))
594 (for-each (lambda (inode)
595 (match (filter-map (match-lambda
596 ((file ino)
597 (and (= ino inode) file)))
598 (zip files inodes))
599 ((_)
600 #f)
601 ((reference others ..1)
602 (format #t "creating ~a symlinks to '~a'~%"
603 (length others) reference)
604 (for-each delete-file others)
605 (for-each (lambda (file)
606 (if (string=? (dirname file)
607 (dirname reference))
608 (symlink (basename reference)
609 file)
610 (symlink reference file)))
611 others))))
612 (delete-duplicates inodes)))))
613 (add-after 'install 'set-layer-path-in-manifests
614 (lambda _
615 (let* ((out #$output)
616 (implicit-path (string-append
617 out
618 "/share/vulkan/implicit_layer.d/"))
619 (explicit-path (string-append
620 out
621 "/share/vulkan/explicit_layer.d/"))
622 (fix-layer-path
623 (lambda (layer-name)
624 (let* ((explicit (string-append explicit-path layer-name ".json"))
625 (implicit (string-append implicit-path layer-name ".json"))
626 (manifest (if (file-exists? explicit)
627 explicit
628 implicit)))
629 (substitute* manifest
630 (((string-append "\"lib" layer-name ".so\""))
631 (string-append "\"" out "/lib/lib" layer-name ".so\"")))))))
632 (for-each fix-layer-path '("VkLayer_MESA_device_select"
633 "VkLayer_MESA_overlay"))))))))
634 (native-search-paths
635 (list (search-path-specification
636 ;; Ensure the Mesa VDPAU drivers can be found.
637 (variable "VDPAU_DRIVER_PATH")
638 (separator #f)
639 (files '("lib/vdpau")))))
640 (home-page "https://mesa3d.org/")
641 (synopsis "OpenGL and Vulkan implementations")
642 (description "Mesa is a free implementation of the OpenGL and Vulkan
643specifications - systems for rendering interactive 3D graphics. A variety of
644device drivers allows Mesa to be used in many different environments ranging
645from software emulation to complete hardware acceleration for modern GPUs.")
646 (license license:x11)))
647
648(define-public mesa-opencl
649 (package/inherit mesa
650 (name "mesa-opencl")
651 (source (origin
652 (inherit (package-source mesa))))
653 (arguments
654 (substitute-keyword-arguments arguments
655 ((#:modules modules)
656 (cons '(ice-9 textual-ports) modules))
657 ((#:configure-flags flags)
658 #~(cons* "-Dgallium-rusticl=true"
659 ;; Enable all drivers by default.
660 (string-append "-Dgallium-rusticl-enable-drivers="
661 "asahi,freedreno,radeonsi")
662 #$flags))
663 ((#:phases phases)
664 #~(modify-phases #$phases
665 (add-after 'install 'use-absolute-file-name-in-rusticl.icd
666 (lambda _
667 ;; Use absolute path for OpenCL platform library. Otherwise
668 ;; we would have to set LD_LIBRARY_PATH=LIBRARY_PATH for
669 ;; Rusticl in our applications to find the OpenCL platform.
670 (let* ((out #$output)
671 (rusticl.icd (string-append
672 out "/etc/OpenCL/vendors/rusticl.icd"))
673 (old-path (call-with-input-file rusticl.icd
674 get-string-all))
675 (new-path (string-append out "/lib/"
676 (string-trim-both old-path))))
677 (if (file-exists? new-path)
678 (call-with-output-file rusticl.icd
679 (lambda (port) (format port "~a\n" new-path)))))))))))))
680
681(define-public mesa-headers
682 (package/inherit mesa
683 (name "mesa-headers")
684 (propagated-inputs '())
685 (inputs '())
686 (native-inputs '())
687 (outputs '("out"))
688 (arguments
689 '(#:phases
690 (modify-phases %standard-phases
691 (delete 'configure)
692 (delete 'build)
693 (delete 'check)
694 (replace 'install
695 (lambda* (#:key outputs #:allow-other-keys)
696 (copy-recursively "include" (string-append
697 (assoc-ref outputs "out")
698 "/include")))))))))
699
700;;; The mesa-demos distribution contains non-free files, many files with no
701;;; clear license information, and many demos that aren't useful for most
702;;; people, so we just use this for the mesa-utils package below, and possibly
703;;; other packages in the future. This is modeled after Debian's solution.
704(define (mesa-demos-source version)
705 (origin
706 (method url-fetch)
707 (uri (string-append "ftp://ftp.freedesktop.org/pub/mesa/demos"
708 "/mesa-demos-" version ".tar.bz2"))
709 (sha256 (base32 "0zgzbz55a14hz83gbmm0n9gpjnf5zadzi2kjjvkn6khql2a9rs81"))))
710
711(define-public mesa-utils
712 (package
713 (name "mesa-utils")
714 (version "8.4.0")
715 (source (mesa-demos-source version))
716 (build-system gnu-build-system)
717 (inputs
718 (list mesa freeglut glew))
719 (native-inputs
720 (list pkg-config))
721 (arguments
722 (list
723 #:configure-flags
724 #~(list "CFLAGS=-g -O2 -Wno-error=incompatible-pointer-types")
725 #:phases
726 #~(modify-phases %standard-phases
727 (replace 'install
728 (lambda* (#:key outputs #:allow-other-keys)
729 (let ((out #$output))
730 (mkdir-p (string-append out "/bin"))
731 (for-each (lambda (file)
732 (copy-file file
733 (string-append out "/bin/"
734 (basename file))))
735 '("src/xdemos/glxdemo" "src/xdemos/glxgears"
736 "src/egl/opengl/eglinfo"
737 "src/xdemos/glxinfo" "src/xdemos/glxheads"))))))))
738 (home-page "https://mesa3d.org/")
739 (synopsis "Utility tools for Mesa")
740 (description
741 "The mesa-utils package contains several utility tools for Mesa: eglinfo,
742glxdemo, glxgears, glxheads, and glxinfo.")
743 ;; glxdemo is public domain; others expat.
744 (license (list license:expat license:public-domain))))
745
746(define-public glew
747 (package
748 (name "glew")
749 (version "2.2.0")
750 (source (origin
751 (method url-fetch)
752 (uri (string-append "mirror://sourceforge/glew/glew/" version
753 "/glew-" version ".tgz"))
754 (sha256
755 (base32
756 "1qak8f7g1iswgswrgkzc7idk7jmqgwrs58fhg2ai007v7j4q5z6l"))
757 (modules '((guix build utils)))
758 (snippet
759 '(begin
760 (substitute* "config/Makefile.linux"
761 (("= cc") "= gcc")
762 (("/lib64") "/lib"))
763 #t))))
764 (build-system gnu-build-system)
765 (arguments
766 (list #:make-flags #~(list #$@(if (%current-target-system)
767 #~((string-append "CC=" #$(cc-for-target))
768 (string-append "LD=" #$(cc-for-target))
769 (string-append "STRIP=" #$(strip-for-target)))
770 #~())
771 (string-append "GLEW_PREFIX=" #$output)
772 (string-append "GLEW_DEST=" #$output))
773 #:phases
774 #~(modify-phases %standard-phases
775 (delete 'configure)
776 (add-after 'install 'delete-static
777 (lambda _
778 (delete-file (string-append #$output "/lib/libGLEW.a")))))
779 #:tests? #f)) ;no 'check' target
780 (inputs
781 (list libxi libxmu libx11 mesa))
782
783 ;; <GL/glew.h> includes <GL/glu.h>.
784 (propagated-inputs (list glu))
785
786 (home-page "http://glew.sourceforge.net/")
787 (synopsis "OpenGL extension loading library for C and C++")
788 (description
789 "The OpenGL Extension Wrangler Library (GLEW) is a C/C++ extension
790loading library. GLEW provides efficient run-time mechanisms for determining
791which OpenGL extensions are supported on the target platform. OpenGL core and
792extension functionality is exposed in a single header file.")
793 (license license:bsd-3)))
794
795(define-public guile-opengl
796 (package
797 (name "guile-opengl")
798 (version "0.2.0")
799 (source (origin
800 (method url-fetch)
801 (uri (string-append "mirror://gnu/guile-opengl/guile-opengl-"
802 version ".tar.gz"))
803 (sha256
804 (base32
805 "0rbc2wf9x63ilj3n85h8wyllzc2b22abmhs2p2ghjgc253n8gw5q"))))
806 (build-system gnu-build-system)
807 (native-inputs (list pkg-config))
808 (inputs (list guile-2.2 mesa glu freeglut))
809 (arguments
810 '(#:phases (modify-phases %standard-phases
811 (add-before 'build 'patch-dynamic-link
812 (lambda* (#:key inputs outputs #:allow-other-keys)
813 (substitute* "gl/runtime.scm"
814 (("\\(dynamic-link\\)")
815 (string-append "(dynamic-link \""
816 (assoc-ref inputs "mesa")
817 "/lib/libGL.so" "\")")))
818 (define (dynamic-link-substitute file lib input)
819 (substitute* file
820 (("dynamic-link \"lib([a-zA-Z]+)\"" _ lib)
821 (string-append "dynamic-link \""
822 (assoc-ref inputs input)
823 "/lib/lib" lib "\""))))
824 ;; Replace dynamic-link calls for libGL, libGLU, and
825 ;; libglut with absolute paths to the store.
826 (dynamic-link-substitute "glx/runtime.scm" "GL" "mesa")
827 (dynamic-link-substitute "glu/runtime.scm" "GLU" "glu")
828 (dynamic-link-substitute "glut/runtime.scm" "glut"
829 "freeglut"))))))
830 (home-page "https://gnu.org/s/guile-opengl")
831 (synopsis "Guile binding for the OpenGL graphics API")
832 (description
833 "Guile-OpenGL is a library for Guile that provides bindings to the
834OpenGL graphics API.")
835 (license license:lgpl3+)))
836
837(define-public guile3.0-opengl
838 (package
839 (inherit guile-opengl)
840 (name "guile3.0-opengl")
841 (inputs
842 (list guile-3.0 mesa glu freeglut))))
843
844(define-public libepoxy
845 (package
846 (name "libepoxy")
847 (version "1.5.10")
848 (home-page "https://github.com/anholt/libepoxy")
849 (source (origin
850 (method git-fetch)
851 (uri (git-reference (url home-page) (commit version)))
852 (file-name (git-file-name name version))
853 (sha256
854 (base32
855 "0jw02bzdwynyrwsn5rhcacv92h9xx928j3xp436f8gdnwlyb5641"))))
856 (arguments
857 (list
858 #:phases
859 #~(modify-phases %standard-phases
860 (add-before 'configure 'patch-paths
861 (lambda* (#:key inputs #:allow-other-keys)
862 (let ((mesa-lib
863 (lambda (file)
864 (search-input-file inputs (string-append "lib/" file)))))
865 (substitute* (find-files "." "\\.[ch]$")
866 (("libGL.so.1") (mesa-lib "libGL.so.1"))
867 (("libEGL.so.1") (mesa-lib "libEGL.so.1"))
868 (("libGLESv1_CM.so.1") (mesa-lib "libGLESv1_CM.so.1"))
869 (("libGLESv2.so.2") (mesa-lib "libGLESv2.so.2")))))))))
870 (build-system meson-build-system)
871 (native-inputs
872 (list pkg-config python))
873 (propagated-inputs
874 ;; epoxy.pc: 'Requires.private: gl egl'
875 (list mesa))
876 (synopsis "Library for handling OpenGL function pointer management")
877 (description
878 "A library for handling OpenGL function pointer management.")
879 (license license:x11)))
880
881(define-public libglvnd
882 (package
883 (name "libglvnd")
884 (version "1.7.0")
885 (home-page "https://gitlab.freedesktop.org/glvnd/libglvnd")
886 (source (origin
887 (method git-fetch)
888 (uri (git-reference
889 (url home-page)
890 (commit (string-append "v" version))))
891 (file-name (git-file-name name version))
892 (sha256
893 (base32
894 "07v3bmwzmg0d4g2zp835v1g7j22j8vz7hjfmqrdqjgxjj6v4jkyr"))))
895 (build-system meson-build-system)
896 (arguments
897 '(#:configure-flags '("-Dx11=enabled")
898 #:phases (modify-phases %standard-phases
899 (add-after 'unpack 'disable-glx-tests
900 (lambda _
901 ;; This package is meant to be used alongside Mesa.
902 ;; To avoid a circular dependency, disable tests that
903 ;; require a running Xorg server.
904 (substitute* "tests/meson.build"
905 (("if with_glx")
906 "if false")))))))
907 (native-inputs
908 (list pkg-config))
909 (inputs
910 (list libx11 libxext xorgproto))
911 (synopsis "Vendor-neutral OpenGL dispatch library")
912 (description
913 "libglvnd is a vendor-neutral dispatch layer for arbitrating OpenGL
914API calls between multiple vendors. It allows multiple drivers from
915different vendors to coexist on the same file system, and determines which
916vendor to dispatch each API call to at runtime.
917
918Both GLX and EGL are supported, in any combination with OpenGL and OpenGL ES.")
919 ;; libglvnd is available under a custom X11-style license, and incorporates
920 ;; code with various other licenses. See README.md for details.
921 (license (list (license:x11-style "file://README.md")
922 license:x11
923 license:expat))))
924
925(define-public libopenglrecorder
926 (package
927 (name "libopenglrecorder")
928 (version "0.1.0")
929 (source (origin
930 (method git-fetch)
931 (uri (git-reference
932 (url "https://github.com/Benau/libopenglrecorder")
933 (commit (string-append "v" version))))
934 (file-name (git-file-name name version))
935 (sha256
936 (base32
937 "0sfx2kdw2mca3mx4fnk1yy74pilp2i9npcpyj894qkngz5aaz2wl"))))
938 (build-system cmake-build-system)
939 (arguments
940 (list #:tests? #f)) ;no test suite
941 (native-inputs (list pkg-config))
942 (inputs (list libjpeg-turbo))
943 (home-page "https://github.com/Benau/libopenglrecorder")
944 (synopsis "Async readback OpenGL frame buffer with audio recording")
945 (description
946 "libopenglrecorder is a library allowing optional async readback OpenGL
947frame buffer with optional audio recording. It will do video and audio
948encoding together.")
949 (license license:bsd-3)))
950
951(define-public soil
952 (package
953 (name "soil")
954 (version "1.0.7")
955 (source (origin
956 (method url-fetch)
957 ;; No versioned archive available.
958 (uri "http://www.lonesock.net/files/soil.zip")
959 (sha256
960 (base32
961 "00gpwp9dldzhsdhksjvmbhsd2ialraqbv6v6dpikdmpncj6mnc52"))))
962 (build-system gnu-build-system)
963 (arguments
964 '(#:tests? #f ; no tests
965 #:phases (modify-phases %standard-phases
966 (delete 'configure)
967 (add-before 'build 'init-build
968 (lambda* (#:key outputs #:allow-other-keys)
969 (let ((out (assoc-ref outputs "out")))
970 (setenv "CFLAGS" "-fPIC") ; needed for shared library
971 ;; Use alternate Makefile
972 (copy-file "projects/makefile/alternate Makefile.txt"
973 "src/Makefile")
974 (chdir "src")
975 (substitute* '("Makefile")
976 (("INCLUDEDIR = /usr/include/SOIL")
977 (string-append "INCLUDEDIR = " out "/include/SOIL"))
978 (("LIBDIR = /usr/lib")
979 (string-append "LIBDIR = " out "/lib"))
980 ;; Remove these flags from 'install' commands.
981 (("-o root -g root") ""))))))))
982 (native-inputs
983 (list unzip))
984 (inputs
985 (list mesa))
986 (home-page "https://www.lonesock.net/soil.html")
987 (synopsis "OpenGL texture loading library")
988 (description
989 "SOIL is a tiny C library used primarily for uploading textures into
990OpenGL.")
991 (license license:public-domain)
992 (properties '((lint-hidden-cpe-vendors . ("roots"))))))
993
994(define-public glfw
995 (package
996 (name "glfw")
997 (version "3.3.10")
998 (source (origin
999 (method url-fetch)
1000 (uri (string-append "https://github.com/glfw/glfw"
1001 "/releases/download/" version
1002 "/glfw-" version ".zip"))
1003 (sha256
1004 (base32
1005 "1f5xs4cj1y5wk1jimv1mylk6n6vh7433js28mfd1kf7p2zw3whz8"))))
1006 (build-system cmake-build-system)
1007 (arguments
1008 (list
1009 #:modules '((guix build cmake-build-system)
1010 (guix build utils)
1011 (ice-9 format))
1012 #:tests? #f ;no test target
1013 #:configure-flags #~(list "-DBUILD_SHARED_LIBS=ON")
1014 #:phases
1015 #~(modify-phases %standard-phases
1016 (add-after 'unpack 'patch-sonames
1017 (lambda* (#:key inputs #:allow-other-keys)
1018 (let-syntax ((patch-sonames
1019 (syntax-rules ()
1020 ((_ (file ...) soname ...)
1021 (substitute* (list file ...)
1022 (((format #f "(~@{~a~^|~})" soname ...) lib)
1023 (search-input-file
1024 inputs (string-append
1025 "lib/" lib))))))))
1026 ;; Avoid looking in LD_LIBRARY_PATH for dlopen calls.
1027 (patch-sonames ("src/egl_context.c"
1028 "src/glx_context.c"
1029 "src/vulkan.c"
1030 "src/wl_init.c"
1031 "src/x11_init.c")
1032 "libEGL.so.1"
1033 "libGL.so"
1034 "libGL.so.1"
1035 "libGLESv1_CM.so.1"
1036 "libGLESv2.so.2"
1037 "libvulkan.so.1"
1038 "libwayland-cursor.so.0"
1039 "libwayland-egl.so.1"
1040 "libwayland-client.so.0"
1041 "libxkbcommon.so.0"
1042 "libXxf86vm.so.1"
1043 "libXi.so.6"
1044 "libXrandr.so.2"
1045 "libXcursor.so.1"
1046 "libXinerama.so.1"
1047 "libX11-xcb.so.1"
1048 "libXrender.so.1")))))))
1049 (native-inputs (list doxygen unzip))
1050 (inputs (list libxkbcommon wayland vulkan-loader))
1051 (propagated-inputs
1052 (list mesa ;included in public headers
1053 ;; These are in 'Requires.private' of 'glfw3.pc'.
1054 libx11
1055 libxrandr
1056 libxi
1057 libxinerama
1058 libxcursor
1059 libxxf86vm))
1060 (home-page "https://www.glfw.org")
1061 (synopsis "OpenGL application development library")
1062 (description
1063 "GLFW is a library for OpenGL, OpenGL ES and Vulkan development for
1064desktop computers. It provides a simple API for creating windows, contexts
1065and surfaces, receiving input and events.")
1066 (license license:zlib)))
1067
1068(define-public glfw-3.4
1069 (package
1070 (inherit glfw)
1071 (version "3.4")
1072 (source (origin
1073 (method url-fetch)
1074 (uri (string-append "https://github.com/glfw/glfw"
1075 "/releases/download/" version
1076 "/glfw-" version ".zip"))
1077 (sha256
1078 (base32
1079 "1sd396kkn53myp61kxrd18h7b1q4ix173hhxhvl0iz8j4x5h1v5m"))))
1080 (native-inputs (modify-inputs native-inputs
1081 (prepend pkg-config)))
1082 ;; When building out of source, the install phase fails with:
1083 ;; file INSTALL cannot find "/tmp/guix-build-glfw-3.4.drv-0/build/docs/html":
1084 ;; No such file or directory
1085 (arguments (substitute-keyword-arguments arguments
1086 ((#:out-of-source? _ #f) #f)))))
1087
1088(define-public nanovg
1089 ;; No tags are available.
1090 (let ((revision "0")
1091 (commit "b83cf926525e7cea8d2483da2a75852b8c7b6d28"))
1092 (package
1093 (name "nanovg")
1094 (version (git-version "0" revision commit))
1095 (source (origin
1096 (method git-fetch)
1097 (uri (git-reference
1098 (url "https://github.com/memononen/nanovg")
1099 (commit commit)))
1100 (file-name (git-file-name name version))
1101 (sha256
1102 (base32
1103 "1zp355pw6xnb5mjarz67cxkglv7j1s0qzv705fz1wf0gl0sjhy8f"))
1104 (modules '((guix build utils)))
1105 (snippet
1106 ;; Fix including freetype.
1107 '(substitute* (find-files "." "\\.(c|h)$")
1108 (("ft2build\\.h") "freetype2/ft2build.h")))))
1109 (build-system gnu-build-system)
1110 (arguments
1111 (list #:tests? #f ;no test suite
1112 #:phases
1113 #~(modify-phases %standard-phases
1114 (delete 'configure) ;no configure script
1115 ;; No Makefile exists.
1116 (replace 'build
1117 (lambda _
1118 (invoke #$(cc-for-target)
1119 "../source/src/nanovg.c" "-c" "-fPIC"
1120 "-DFONS_USE_FREETYPE=1"
1121 (string-append "-I"
1122 #$(this-package-input "freetype")
1123 "/include/freetype2"))
1124 (invoke #$(cc-for-target)
1125 "-shared" "-olibnanovg.so" "nanovg.o"
1126 "-lfreetype")))
1127 ;; No Makefile exists.
1128 (replace 'install
1129 (lambda _
1130 (let ((lib (string-append #$output "/lib"))
1131 (include (string-append #$output
1132 "/include/nanovg")))
1133 (install-file "libnanovg.so" lib)
1134 (with-directory-excursion "../source"
1135 (for-each
1136 (lambda (file)
1137 (install-file file include))
1138 (append (find-files "src" "nanovg.*\\.h$")
1139 '("example/perf.h"
1140 "example/stb_image_write.h"))))))))))
1141 (inputs
1142 (list freetype))
1143 (home-page "https://github.com/memononen/nanovg")
1144 (synopsis "2D vector drawing library on top of OpenGL")
1145 (description
1146 "NanoVG is an antialiased vector graphics rendering library for OpenGL.
1147It is aimed for building scalable user interfaces and visualizations.")
1148 (license license:zlib))))
1149
1150(define-public nanovg-for-extempore
1151 (let ((version "0.7.1")
1152 (revision "0")
1153 (commit "3c60175fcc2e5fe305b04355cdce35d499c80310"))
1154 (package
1155 (name "nanovg-for-extempore")
1156 (version (git-version version revision commit))
1157 (source (origin
1158 (method git-fetch)
1159 (uri (git-reference
1160 (url "https://github.com/extemporelang/nanovg")
1161 (commit commit)))
1162 (file-name (git-file-name name version))
1163 (sha256
1164 (base32
1165 "0ddn3d3mxqn8hj9967v3pss7lz1wn08pcdnqzc118g7yjkq7hxzy"))))
1166 (build-system cmake-build-system)
1167 (arguments `(#:tests? #f)) ; no tests included
1168 (inputs
1169 (list mesa))
1170 ;; Extempore refuses to build on architectures other than x86_64
1171 (supported-systems '("x86_64-linux"))
1172 (home-page "https://github.com/extemporelang/nanovg")
1173 (synopsis "2D vector drawing library on top of OpenGL")
1174 (description "NanoVG is small antialiased vector graphics rendering
1175library for OpenGL. It has lean API modeled after HTML5 canvas API. It is
1176aimed to be a practical and fun toolset for building scalable user interfaces
1177and visualizations.")
1178 (license license:zlib))))
1179
1180(define-public gl2ps
1181 (package
1182 (name "gl2ps")
1183 (version "1.4.2")
1184 (source
1185 (origin
1186 (method url-fetch)
1187 (uri (string-append
1188 "http://geuz.org/gl2ps/src/gl2ps-"
1189 version ".tgz"))
1190 (sha256
1191 (base32 "1sgzv547h7hrskb9qd0x5yp45kmhvibjwj2mfswv95lg070h074d"))))
1192 (build-system cmake-build-system)
1193 (inputs
1194 (list libpng mesa zlib))
1195 (arguments
1196 `(#:tests? #f)) ; no tests
1197 (home-page "https://www.geuz.org/gl2ps/")
1198 (synopsis "OpenGL to PostScript printing library")
1199 (description "GL2PS is a C library providing high quality vector
1200output for any OpenGL application. GL2PS uses sorting algorithms
1201capable of handling intersecting and stretched polygons, as well as
1202non-manifold objects. GL2PS provides many features including advanced
1203smooth shading and text rendering, culling of invisible primitives and
1204mixed vector/bitmap output.")
1205 ;; GL2PS is dual-licenced and can be used under the terms of either.
1206 (license (list license:lgpl2.0+
1207 (license:fsf-free "http://www.geuz.org/gl2ps/COPYING.GL2PS"
1208 "GPL-incompatible copyleft license")))))
1209
1210(define-public virtualgl
1211 (package
1212 (name "virtualgl")
1213 (version "2.6.2")
1214 (source
1215 (origin
1216 (method git-fetch)
1217 (uri (git-reference
1218 (url "https://github.com/VirtualGL/virtualgl")
1219 (commit version)))
1220 (file-name (git-file-name name version))
1221 (sha256
1222 (base32 "0yyc553xsb5n0rx7jp9p4wdbd7md07b3qrkf3ssyjavqqg908qg9"))))
1223 (arguments
1224 `(#:tests? #f ; no tests are available
1225 #:configure-flags (list
1226 (string-append "-DCMAKE_INSTALL_LIBDIR="
1227 (assoc-ref %outputs "out") "/lib")
1228 "-DVGL_USESSL=1"))) ; use OpenSSL
1229 (build-system cmake-build-system)
1230 (inputs (list glu libjpeg-turbo libxtst mesa openssl))
1231 (native-inputs (list pkg-config))
1232 (home-page "https://www.virtualgl.org")
1233 (synopsis "Redirects 3D commands from an OpenGL application onto a 3D
1234graphics card")
1235 (description "VirtualGL redirects the 3D rendering commands from OpenGL
1236applications to 3D accelerator hardware in a dedicated server and displays the
1237rendered output interactively to a thin client located elsewhere on the
1238network.")
1239 (license license:wxwindows3.1+)))
1240
1241(define-public mojoshader
1242 (let ((changeset "5887634ea695"))
1243 (package
1244 (name "mojoshader")
1245 (version (string-append "20190825" "-" changeset))
1246 (source
1247 (origin
1248 (method hg-fetch)
1249 (uri (hg-reference
1250 (url "https://hg.icculus.org/icculus/mojoshader/")
1251 (changeset changeset)))
1252 (file-name (git-file-name name version))
1253 (sha256
1254 (base32 "0ibl4z1696jiifv9j5drir7jm0b5px0vwkwckbi7cfd46p7p6wcy"))))
1255 (arguments
1256 ;; Tests only for COMPILER_SUPPORT=ON.
1257 `(#:tests? #f
1258 #:configure-flags '("-DBUILD_SHARED=ON"
1259 "-DFLIP_VIEWPORT=ON"
1260 "-DDEPTH_CLIPPING=ON")
1261 #:phases
1262 (modify-phases %standard-phases
1263 (replace 'install
1264 (lambda* (#:key outputs #:allow-other-keys)
1265 (let* ((out (assoc-ref outputs "out"))
1266 (lib (string-append out "/lib"))
1267 (header (string-append out "/include")))
1268 (install-file "libmojoshader.so" lib)
1269 (for-each (lambda (f)
1270 (install-file f header))
1271 (find-files "../source" "mojoshader.*\\.h$"))
1272 (let ((profiles-header (string-append header "/profiles")))
1273 (mkdir-p profiles-header)
1274 (rename-file (string-append header "/mojoshader_profile.h")
1275 (string-append profiles-header "/mojoshader_profile.h"))))
1276 #t)))))
1277 (build-system cmake-build-system)
1278 (home-page "https://www.icculus.org/mojoshader/")
1279 (synopsis "Work with Direct3D shaders on alternate 3D APIs")
1280 (description "MojoShader is a library to work with Direct3D shaders on
1281alternate 3D APIs and non-Windows platforms. The primary motivation is moving
1282shaders to OpenGL languages on the fly. The developer deals with \"profiles\"
1283that represent various target languages, such as GLSL or ARB_*_program.
1284
1285This allows a developer to manage one set of shaders, presumably written in
1286Direct3D HLSL, and use them across multiple rendering backends. This also
1287means that the developer only has to worry about one (offline) compiler to
1288manage program complexity, while MojoShader itself deals with the reduced
1289complexity of the bytecode at runtime.
1290
1291MojoShader provides both a simple API to convert bytecode to various profiles,
1292and (optionally) basic glue to rendering APIs to abstract the management of
1293the shaders at runtime.")
1294 (license license:zlib))))
1295
1296(define-public mojoshader-with-viewport-flip
1297 ;; Changeset c586d4590241 replaced glProgramViewportFlip with
1298 ;; glProgramViewportInfo.
1299 ;; https://hg.icculus.org/icculus/mojoshader/rev/c586d4590241
1300 (let ((changeset "2e37299b13d8"))
1301 (package
1302 (inherit mojoshader)
1303 (name "mojoshader-with-viewport-flip")
1304 (version (string-append "20190725" "-" changeset))
1305 (source
1306 (origin
1307 (method hg-fetch)
1308 (uri (hg-reference
1309 (url "https://hg.icculus.org/icculus/mojoshader/")
1310 (changeset changeset)))
1311 (file-name (git-file-name name version))
1312 (sha256
1313 (base32 "0ffws7cqbskxwc3hjsnnzq4r2bbf008kdr3b11pa3kr7dsi50y6i"))))
1314 (synopsis "Work with Direct3D shaders on alternate 3D APIs (with viewport flip)")
1315 (description "This is the last version of the mojoshader library with
1316the glProgramViewportFlip before it was replaced with glProgramViewportInfo.")
1317 (license license:zlib))))
1318
1319(define-public glmark2
1320 (package
1321 (name "glmark2")
1322 (version "2023.01")
1323 (source (origin
1324 (method git-fetch)
1325 (uri (git-reference
1326 (url "https://github.com/glmark2/glmark2")
1327 (commit version)))
1328 (file-name (git-file-name name version))
1329 (sha256
1330 (base32
1331 "094dr0ljg1hq6wymw2hb3369p4g91sn5c2qf554dl0dbdbjdqasq"))))
1332 (build-system meson-build-system)
1333 (arguments
1334 '(#:tests? #f ; no check target
1335 #:configure-flags
1336 (list (string-append "-Dflavors="
1337 (string-join '("x11-gl" "x11-glesv2"
1338 "drm-gl" "drm-glesv2"
1339 "wayland-gl" "wayland-glesv2")
1340 ",")))
1341 #:phases
1342 (modify-phases %standard-phases
1343 (add-after 'unpack 'patch-paths
1344 (lambda* (#:key inputs #:allow-other-keys)
1345 (let ((mesa (assoc-ref inputs "mesa")))
1346 (substitute* (find-files "src" "gl-state-.*\\.cpp$")
1347 (("libGL.so") (string-append mesa "/lib/libGL.so"))
1348 (("libEGL.so") (string-append mesa "/lib/libEGL.so"))
1349 (("libGLESv2.so") (string-append mesa "/lib/libGLESv2.so")))
1350 #t))))))
1351 (native-inputs
1352 (list pkg-config))
1353 (inputs
1354 (list eudev
1355 libdrm
1356 libjpeg-turbo
1357 libpng
1358 libx11
1359 libxcb
1360 mesa
1361 wayland
1362 wayland-protocols))
1363 (home-page "https://github.com/glmark2/glmark2")
1364 (synopsis "OpenGL 2.0 and OpenGL ES 2.0 benchmark")
1365 (description
1366 "glmark2 is an OpenGL 2.0 and OpenGL ES 2.0 benchmark based on the
1367original glmark benchmark by Ben Smith.")
1368 (license license:gpl3+)))
1369
1370(define-public waffle
1371 (package
1372 (name "waffle")
1373 (version "1.8.0")
1374 (source (origin
1375 (method git-fetch)
1376 (uri (git-reference
1377 (url "https://gitlab.freedesktop.org/mesa/waffle")
1378 (commit (string-append "v" version))))
1379 (file-name (git-file-name name version))
1380 (sha256
1381 (base32 "1mrw0arlrpm83cwaz7rnimkkjv3a134rcmi1h512y2g4yjzhnm8r"))
1382 (modules '((ice-9 ftw)
1383 (guix build utils)))
1384 (snippet #~(with-directory-excursion "third_party"
1385 (let ((keep '("." ".." "meson.build" "threads")))
1386 (for-each (lambda (f)
1387 (unless (member f keep)
1388 (delete-file-recursively f)))
1389 (scandir ".")))))))
1390 (build-system meson-build-system)
1391 (propagated-inputs (list mesa wayland))
1392 (native-inputs (list cmocka pkg-config))
1393 (home-page "https://waffle.freedesktop.org/")
1394 (synopsis "Choose OpenGL API at runtime")
1395 (description "Waffle is a library that allows one to defer selection of an
1396 OpenGL API and a window system until runtime.")
1397 (license license:bsd-2)))
1398
1399(define-public piglit
1400 (let ((revision "2")
1401 (commit "040ed91f234abb6a502d3a6910f1b0e54bd239a7"))
1402 (package
1403 (name "piglit")
1404 (version (git-version "0.0.0" revision commit))
1405 (source (origin
1406 (method git-fetch)
1407 (uri (git-reference
1408 (url "https://gitlab.freedesktop.org/mesa/piglit")
1409 (commit commit)))
1410 (file-name (git-file-name name version))
1411 (sha256
1412 (base32 "1j5dmkym1mmz410xgwygimnjk2aswsqmcpjwz4s98pgmymh1yjvf"))))
1413 (build-system cmake-build-system)
1414 (arguments
1415 (list #:configure-flags #~(list "-DPIGLIT_SSE2=OFF")
1416 ;; Tests are not invoked through cmake. Instead, there are
1417 ;; pytest/tox-based tests for the framework, but they require
1418 ;; unpackaged plugins.
1419 #:tests? #f
1420 #:phases
1421 #~(modify-phases %standard-phases
1422 (add-after 'unpack 'patch-source
1423 (lambda* (#:key inputs #:allow-other-keys)
1424 (substitute* (find-files "framework/" "\\.py$")
1425 (("'wflinfo'")
1426 (string-append "'"
1427 (search-input-file inputs "/bin/wflinfo")
1428 "'")))))
1429 (add-after 'install 'wrap
1430 (lambda* (#:key outputs #:allow-other-keys)
1431 (wrap-script (string-append #$output "/bin/piglit")
1432 `("GUIX_PYTHONPATH" prefix
1433 (,(getenv "GUIX_PYTHONPATH")))))))))
1434 (inputs (list glslang
1435 guile-3.0 ; for wrap-script
1436 libxkbcommon
1437 python
1438 wayland-protocols
1439 vulkan-headers
1440 vulkan-loader
1441 waffle))
1442 (native-inputs (list pkg-config
1443 python-lxml
1444 python-mako
1445 python-numpy))
1446 (home-page "https://piglit.freedesktop.org/")
1447 (synopsis "Test OpenGL implementations")
1448 (description "Piglit is a collection of automated tests for OpenGL and
1449OpenCL implementations.")
1450 ;; A mix of licenses for various tests
1451 (license (list license:expat
1452 license:bsd-3
1453 license:gpl2+
1454 license:gpl3+)))))