From ba253276636a18cb9af0b7982cd7db34942d39e2 Mon Sep 17 00:00:00 2001
From: John Kehayias <john.kehayias@protonmail.com>
Date: Tue, 4 Jan 2022 17:02:31 -0500
Subject: [PATCH 4/4] gnu: Add mangohud.
* gnu/packages/graphics.scm (mangohud): New variable.
* gnu/packages/patches/mangohud-imgui.patch: New file.
* gnu/local.mk (dist_path_DATA): Add it.
---
gnu/local.mk | 1 +
gnu/packages/graphics.scm | 81 +++++++++++++++++++++++
gnu/packages/patches/mangohud-imgui.patch | 50 ++++++++++++++
3 files changed, 132 insertions(+)
create mode 100644 gnu/packages/patches/mangohud-imgui.patch
@@ -1466,6 +1466,7 @@ dist_patch_DATA = \
%D%/packages/patches/mcrypt-CVE-2012-4527.patch \
%D%/packages/patches/libmemcached-build-with-gcc7.patch \
%D%/packages/patches/libmhash-hmac-fix-uaf.patch \
+ %D%/packages/patches/mangohud-imgui.patch \
%D%/packages/patches/mercurial-hg-extension-path.patch \
%D%/packages/patches/mesa-opencl-all-targets.patch \
%D%/packages/patches/mesa-skip-tests.patch \
@@ -81,10 +81,12 @@ (define-module (gnu packages graphics)
#:use-module (gnu packages kde-frameworks)
#:use-module (gnu packages libusb)
#:use-module (gnu packages linux)
+ #:use-module (gnu packages logging)
#:use-module (gnu packages lua)
#:use-module (gnu packages maths)
#:use-module (gnu packages mp3)
#:use-module (gnu packages multiprecision)
+ #:use-module (gnu packages pciutils)
#:use-module (gnu packages pdf)
#:use-module (gnu packages perl)
#:use-module (gnu packages photo)
@@ -116,6 +118,7 @@ (define-module (gnu packages graphics)
#:use-module (guix build-system python)
#:use-module (guix build-system qt)
#:use-module (guix download)
+ #:use-module (guix gexp)
#:use-module (guix git-download)
#:use-module (guix hg-download)
#:use-module ((guix licenses) #:prefix license:)
@@ -1059,6 +1062,84 @@ (define-public alembic
distills complex, animated scenes into a set of baked geometric results.")
(license license:bsd-3)))
+(define-public mangohud
+ (package
+ (name "mangohud")
+ (version "0.6.6-1")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/flightlessmango/MangoHud/")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (patches (search-patches "mangohud-imgui.patch"))
+ (sha256
+ (base32 "0ka004wxkajmvs5vy60r4ckm7f169c61rrd46w6gywkaqf5yp1ab"))))
+ (build-system meson-build-system)
+ (arguments
+ (list
+ #:build-type "release"
+ #:configure-flags
+ #~(list "-Duse_system_vulkan=enabled"
+ "-Duse_system_spdlog=enabled"
+ "-Dwith_xnvctrl=disabled"
+ "-Dappend_libdir_mangohud=false"
+ (string-append "-Dvulkan_datadir="
+ #$(this-package-input "vulkan-headers")
+ "/share"))
+ #:phases
+ `(modify-phases %standard-phases
+ (add-after 'unpack 'patch-paths
+ (lambda* (#:key inputs #:allow-other-keys)
+ ;; Don't use $LIB.
+ (substitute* "src/meson.build"
+ (("\\\\\\$LIB")
+ "lib"))
+ ;; Adjust hardcoded paths.
+ (substitute* "src/loaders/loader_libdrm.cpp"
+ (("libdrm.so.2")
+ (search-input-file inputs "/lib/libdrm.so.2"))
+ (("libdrm_amdgpu.so.1")
+ (search-input-file inputs "/lib/libdrm_amdgpu.so.1")))
+ (substitute* "src/overlay.cpp"
+ (("glxinfo")
+ (search-input-file inputs "/bin/glxinfo")))
+ (substitute* "src/loaders/loader_x11.cpp"
+ (("libX11.so.6")
+ (search-input-file inputs "/lib/libX11.so.6")))
+ (substitute* "src/pci_ids.cpp"
+ (("/usr/share/hwdata/pci.ids")
+ (search-input-file inputs "share/hwdata/pci.ids")))
+ (substitute* "src/dbus.cpp"
+ (("libdbus-1.so.3")
+ (search-input-file inputs "lib/libdbus-1.so.3"))))))))
+ (inputs
+ (list dbus
+ dear-imgui
+ `(,dear-imgui "static") ;static imgui preferred
+ glslang
+ libdrm
+ libx11
+ mesa
+ mesa-utils
+ pciutils-no-zlib
+ python-mako
+ spdlog
+ vulkan-loader
+ vulkan-headers))
+ (native-inputs
+ (list pkg-config))
+ (synopsis "Vulkan and OpenGL overlay for monitoring framerate, temperatures and more")
+ (description
+ "MangoHud is a Vulkan and OpenGL overlay for monitoring FPS, temperatures,
+CPU/GPU load and more. Configuration is customizable though configuration
+files or the variable @code{MANGOHUD_CONFIG}, including position, color, media
+info, framerate logging, and so on. MangoHud can be run with @code{mangohud}
+or with @code{MANGOHUD=1} (for Vulkan only).")
+ (home-page "https://github.com/flightlessmango/MangoHud/")
+ (license license:expat)))
+
(define-public ogre
(package
(name "ogre")
new file mode 100644
@@ -0,0 +1,50 @@
+This patch removes trying to build the bundled dear-imgui library in favor of
+the input version. The static option is set in the dependency to mirror the
+upstream build (though dear-imgui is built with all available backends
+already).
+
+diff --git a/meson.build b/meson.build
+index e5cf395..7f8a8e1 100644
+--- a/meson.build
++++ b/meson.build
+@@ -220,39 +220,14 @@ util_files = files(
+ 'src/mesa/util/os_time.c',
+ )
+
+-imgui_options = [
+- 'default_library=static',
+- # use 'auto_features=disabled' once available: https://github.com/mesonbuild/meson/issues/5320
+- 'dx9=disabled',
+- 'dx10=disabled',
+- 'dx11=disabled',
+- 'dx12=disabled',
+- 'metal=disabled',
+- 'opengl=disabled',
+- 'vulkan=disabled',
+- 'glfw=disabled',
+- 'sdl2=disabled',
+- 'osx=disabled',
+- 'win=disabled',
+- 'marmalade=disabled',
+- 'allegro5=disabled',
+-]
+-
+ sizeof_ptr = cc.sizeof('void*')
+ if sizeof_ptr == 8
+ pre_args += '-DMANGOHUD_ARCH="64bit"'
+- if get_option('mangoapp')
+- imgui_options += [
+- 'opengl=enabled',
+- 'glfw=enabled',
+- ]
+- endif
+ elif sizeof_ptr == 4
+ pre_args += '-DMANGOHUD_ARCH="32bit"'
+ endif
+
+-dearimgui_sp = subproject('imgui', default_options: imgui_options)
+-dearimgui_dep = dearimgui_sp.get_variable('imgui_dep')
++dearimgui_dep = dependency('imgui', static: true)
+
+ spdlog_dep = cpp.find_library('spdlog', required: get_option('use_system_spdlog'))
+ if not spdlog_dep.found()
--
2.34.0