diff --git a/pkgs/development/libraries/mesa/common.nix b/pkgs/development/libraries/mesa/common.nix index 9dca76dc44a4..84e68f87fa4b 100644 --- a/pkgs/development/libraries/mesa/common.nix +++ b/pkgs/development/libraries/mesa/common.nix @@ -5,14 +5,14 @@ # nix build .#legacyPackages.x86_64-darwin.mesa .#legacyPackages.aarch64-darwin.mesa rec { pname = "mesa"; - version = "25.1.7"; + version = "25.2.0"; src = fetchFromGitLab { domain = "gitlab.freedesktop.org"; owner = "mesa"; repo = "mesa"; rev = "mesa-${version}"; - hash = "sha256-dseMHUifLsszSAGCaZwgOwhj0/yfbRlBVVHQz25NdjY="; + hash = "sha256-is5CWcyC0O4Jn08makxowDAiloxYJmMrfuxecu12fyQ="; }; meta = { diff --git a/pkgs/development/libraries/mesa/default.nix b/pkgs/development/libraries/mesa/default.nix index bd64c3fa2430..f14e7bb1e9f5 100644 --- a/pkgs/development/libraries/mesa/default.nix +++ b/pkgs/development/libraries/mesa/default.nix @@ -26,6 +26,7 @@ ninja, pkg-config, python3Packages, + runCommand, rust-bindgen, rust-cbindgen, rustPlatform, @@ -44,41 +45,43 @@ enablePatentEncumberedCodecs ? true, withValgrind ? lib.meta.availableOn stdenv.hostPlatform valgrind-light, + # We enable as many drivers as possible here, to build cross tools + # and support emulation use cases (emulated x86_64 on aarch64, etc) galliumDrivers ? [ - "asahi" # Apple AGX, built on non-aarch64 for cross tools + "asahi" # Apple AGX + "crocus" # Intel legacy "d3d12" # WSL emulated GPU (aka Dozen) + "etnaviv" # Vivante GPU designs (mostly NXP/Marvell SoCs) + "freedreno" # Qualcomm Adreno (all Qualcomm SoCs) + "i915" # Intel extra legacy "iris" # new Intel (Broadwell+) + "lima" # ARM Mali 4xx "llvmpipe" # software renderer "nouveau" # Nvidia - "panfrost" # ARM Mali Midgard and up (T/G series), built on non-ARM for cross tools + "panfrost" # ARM Mali Midgard and up (T/G series) "r300" # very old AMD "r600" # less old AMD "radeonsi" # new AMD (GCN+) "softpipe" # older software renderer "svga" # VMWare virtualized GPU - "virgl" # QEMU virtualized GPU (aka VirGL) - "zink" # generic OpenGL over Vulkan, experimental - ] - ++ lib.optionals (stdenv.hostPlatform.isAarch64 || stdenv.hostPlatform.isAarch32) [ - "etnaviv" # Vivante GPU designs (mostly NXP/Marvell SoCs) - "freedreno" # Qualcomm Adreno (all Qualcomm SoCs) - "lima" # ARM Mali 4xx - "vc4" # Broadcom VC4 (Raspberry Pi 0-3) - ] - ++ lib.optionals stdenv.hostPlatform.isAarch64 [ "tegra" # Nvidia Tegra SoCs "v3d" # Broadcom VC5 (Raspberry Pi 4) - ] - ++ lib.optionals stdenv.hostPlatform.isx86 [ - "crocus" # Intel legacy, x86 only - "i915" # Intel extra legacy, x86 only + "vc4" # Broadcom VC4 (Raspberry Pi 0-3) + "virgl" # QEMU virtualized GPU (aka VirGL) + "zink" # generic OpenGL over Vulkan, experimental ], vulkanDrivers ? [ "amd" # AMD (aka RADV) - "asahi" # Apple AGX, built on non-aarch64 for cross tools + "asahi" # Apple AGX + "broadcom" # Broadcom VC5 (Raspberry Pi 4, aka V3D) + "freedreno" # Qualcomm Adreno (all Qualcomm SoCs) + "gfxstream" # Android virtualized GPU + "imagination-experimental" # PowerVR Rogue (currently N/A) + "intel_hasvk" # Intel Haswell/Broadwell, "legacy" Vulkan driver (https://www.phoronix.com/news/Intel-HasVK-Drop-Dead-Code) "intel" # new Intel (aka ANV) "microsoft-experimental" # WSL virtualized GPU (aka DZN/Dozen) "nouveau" # Nouveau (aka NVK) + "panfrost" # ARM Mali Midgard and up (T/G series) "swrast" # software renderer (aka Lavapipe) ] ++ @@ -88,16 +91,7 @@ # QEMU virtualized GPU (aka VirGL) # Requires ATOMIC_INT_LOCK_FREE == 2. "virtio" - ] - ++ lib.optionals stdenv.hostPlatform.isAarch64 [ - "broadcom" # Broadcom VC5 (Raspberry Pi 4, aka V3D) - "freedreno" # Qualcomm Adreno (all Qualcomm SoCs) - "imagination-experimental" # PowerVR Rogue (currently N/A) - "panfrost" # ARM Mali Midgard and up (T/G series) - ] - ++ lib.optionals stdenv.hostPlatform.isx86 [ - "intel_hasvk" # Intel Haswell/Broadwell, "legacy" Vulkan driver (https://www.phoronix.com/news/Intel-HasVK-Drop-Dead-Code) - ], + ], eglPlatforms ? [ "x11" "wayland" @@ -115,41 +109,28 @@ }: let - rustDeps = [ - { - pname = "paste"; - version = "1.0.14"; - hash = "sha256-+J1h7New5MEclUBvwDQtTYJCHKKqAEOeQkuKy+g0vEc="; - } - { - pname = "proc-macro2"; - version = "1.0.86"; - hash = "sha256-9fYAlWRGVIwPp8OKX7Id84Kjt8OoN2cANJ/D9ZOUUZE="; - } - { - pname = "quote"; - version = "1.0.33"; - hash = "sha256-VWRCZJO0/DJbNu0/V9TLaqlwMot65YjInWT9VWg57DY="; - } - { - pname = "syn"; - version = "2.0.68"; - hash = "sha256-nGLBbxR0DFBpsXMngXdegTm/o13FBS6QsM7TwxHXbgQ="; - } - { - pname = "unicode-ident"; - version = "1.0.12"; - hash = "sha256-KX8NqYYw6+rGsoR9mdZx8eT1HIPEUUyxErdk2H/Rlj8="; - } + rustDeps = lib.importJSON ./wraps.json; + + fetchDep = + dep: + fetchCrate { + inherit (dep) pname version hash; + unpack = false; + }; + + toCommand = dep: "ln -s ${dep} $out/${dep.pname}-${dep.version}.tar.gz"; + + packageCacheCommand = lib.pipe rustDeps [ + (builtins.map fetchDep) + (builtins.map toCommand) + (lib.concatStringsSep "\n") ]; - copyRustDep = dep: '' - cp -R --no-preserve=mode,ownership ${fetchCrate dep} subprojects/${dep.pname}-${dep.version} - cp -R subprojects/packagefiles/${dep.pname}/* subprojects/${dep.pname}-${dep.version}/ + packageCache = runCommand "mesa-rust-package-cache" { } '' + mkdir -p $out + ${packageCacheCommand} ''; - copyRustDeps = lib.concatStringsSep "\n" (builtins.map copyRustDep rustDeps); - needNativeCLC = !stdenv.buildPlatform.canExecute stdenv.hostPlatform; common = import ./common.nix { inherit lib fetchFromGitLab; }; @@ -175,8 +156,6 @@ stdenv.mkDerivation { exit 42 fi done - - ${copyRustDeps} ''; outputs = [ @@ -209,6 +188,8 @@ stdenv.mkDerivation { PATH=${lib.getDev llvmPackages.libllvm}/bin:$PATH ''; + env.MESON_PACKAGE_CACHE_DIR = packageCache; + mesonFlags = [ "--sysconfdir=/etc" @@ -223,13 +204,6 @@ stdenv.mkDerivation { (lib.mesonEnable "gbm" true) (lib.mesonBool "libgbm-external" true) - (lib.mesonBool "gallium-nine" false) # Direct3D9 in Wine, largely supplanted by DXVK - - # Only used by xf86-video-vmware, which has more features than VMWare's KMS driver, - # so we're keeping it for now. Should be removed when that's no longer the case. - # See: https://github.com/NixOS/nixpkgs/pull/392492 - (lib.mesonEnable "gallium-xa" true) - (lib.mesonBool "teflon" true) # TensorFlow frontend # Enable all freedreno kernel mode drivers. (For example, virtio can be @@ -237,9 +211,6 @@ stdenv.mkDerivation { # is ignored when freedreno is not being built. (lib.mesonOption "freedreno-kmds" "msm,kgsl,virtio,wsl") - # Enable Intel RT stuff when available - (lib.mesonEnable "intel-rt" stdenv.hostPlatform.isx86_64) - # Required for OpenCL (lib.mesonOption "clang-libdir" "${lib.getLib llvmPackages.clang-unwrapped}/lib") @@ -247,15 +218,16 @@ stdenv.mkDerivation { (lib.mesonBool "gallium-rusticl" true) (lib.mesonOption "gallium-rusticl-enable-drivers" "auto") - # meson auto_features enables this, but we do not want it - (lib.mesonEnable "android-libbacktrace" false) - (lib.mesonEnable "microsoft-clc" false) # Only relevant on Windows (OpenCL 1.2 API on top of D3D12) - # Enable more sensors in gallium-hud (lib.mesonBool "gallium-extra-hud" true) # Disable valgrind on targets where it's not available (lib.mesonEnable "valgrind" withValgrind) + + # meson auto_features enables these, but we do not want them + (lib.mesonEnable "gallium-mediafoundation" false) # Windows only + (lib.mesonEnable "android-libbacktrace" false) # Android only + (lib.mesonEnable "microsoft-clc" false) # Only relevant on Windows (OpenCL 1.2 API on top of D3D12) ] ++ lib.optionals enablePatentEncumberedCodecs [ (lib.mesonOption "video-codecs" "all") diff --git a/pkgs/development/libraries/mesa/opencl.patch b/pkgs/development/libraries/mesa/opencl.patch index 9d40da82f856..d71f168d83cf 100644 --- a/pkgs/development/libraries/mesa/opencl.patch +++ b/pkgs/development/libraries/mesa/opencl.patch @@ -1,23 +1,23 @@ diff --git a/meson.build b/meson.build -index c150bff74ff..37fa7f0531b 100644 +index 393f3ac1b93..fbc90b5645e 100644 --- a/meson.build +++ b/meson.build -@@ -1850,7 +1850,7 @@ endif +@@ -1836,7 +1836,7 @@ endif dep_clang = null_dep - if with_clc or with_gallium_clover + if with_clc - llvm_libdir = dep_llvm.get_variable(cmake : 'LLVM_LIBRARY_DIR', configtool: 'libdir') + llvm_libdir = get_option('clang-libdir') dep_clang = cpp.find_library('clang-cpp', dirs : llvm_libdir, required : false) -diff --git a/meson_options.txt b/meson_options.txt -index 82324617884..4bde97a8568 100644 +diff --git a/meson.options b/meson.options +index b1cdb06fcc9..3e8861979ae 100644 --- a/meson.options +++ b/meson.options -@@ -738,3 +738,10 @@ option( - 'none', 'dri2' - ], +@@ -856,3 +856,10 @@ option( + value : false, + description : 'Build virtgpu_kumquat (only useful with gfxstream currently)' ) + +option( @@ -26,24 +26,11 @@ index 82324617884..4bde97a8568 100644 + value : '', + description : 'Locations to search for clang libraries.' +) -diff --git a/src/gallium/targets/opencl/meson.build b/src/gallium/targets/opencl/meson.build -index ab2c83556a8..a59e88e122f 100644 ---- a/src/gallium/targets/opencl/meson.build -+++ b/src/gallium/targets/opencl/meson.build -@@ -56,7 +56,7 @@ if with_opencl_icd - configuration : _config, - input : 'mesa.icd.in', - output : 'mesa.icd', -- install : true, -+ install : false, - install_tag : 'runtime', - install_dir : join_paths(get_option('sysconfdir'), 'OpenCL', 'vendors'), - ) diff --git a/src/gallium/targets/rusticl/meson.build b/src/gallium/targets/rusticl/meson.build -index 35833dc7423..41a95927cab 100644 +index 2b214adbbf5..7f919397ad5 100644 --- a/src/gallium/targets/rusticl/meson.build +++ b/src/gallium/targets/rusticl/meson.build -@@ -63,7 +63,7 @@ configure_file( +@@ -64,7 +64,7 @@ configure_file( configuration : _config, input : 'rusticl.icd.in', output : 'rusticl.icd', diff --git a/pkgs/development/libraries/mesa/update-wraps.py b/pkgs/development/libraries/mesa/update-wraps.py new file mode 100644 index 000000000000..037dfc0397b2 --- /dev/null +++ b/pkgs/development/libraries/mesa/update-wraps.py @@ -0,0 +1,50 @@ +import base64 +import binascii +import configparser +import json +import pathlib +import sys +import urllib.parse + + +def to_sri(hash: str): + raw = binascii.unhexlify(hash) + b64 = base64.b64encode(raw).decode() + return f"sha256-{b64}" + + +def main(dir: str): + result = [] + for file in (pathlib.Path(dir) / "subprojects").glob("*.wrap"): + name = file.stem + parser = configparser.ConfigParser() + _ = parser.read(file) + sections = parser.sections() + if "wrap-file" not in sections: + continue + + url = parser.get("wrap-file", "source_url") + if "crates.io" not in url: + continue + + parsed = urllib.parse.urlparse(url) + path = parsed.path.split("/") + assert path[4] == name + version = path[5] + + hash = to_sri(parser.get("wrap-file", "source_hash")) + + result.append({ + "pname": name, + "version": version, + "hash": hash, + }) + + here = pathlib.Path(__file__).parent + with (here / "wraps.json").open("w") as fd: + json.dump(result, fd, indent=4) + _ = fd.write("\n") + + +if __name__ == '__main__': + main(*sys.argv[1:]) diff --git a/pkgs/development/libraries/mesa/wraps.json b/pkgs/development/libraries/mesa/wraps.json new file mode 100644 index 000000000000..5b185c2d5623 --- /dev/null +++ b/pkgs/development/libraries/mesa/wraps.json @@ -0,0 +1,137 @@ +[ + { + "pname": "errno", + "version": "0.3.12", + "hash": "sha256-zqFO+TVeO+qwY3A6qdqxWv0l8GZ8NBMQweUnS7HQ2hg=" + }, + { + "pname": "quote", + "version": "1.0.35", + "hash": "sha256-KR7Jq179k0qvUDpkZsXVJRU10QjudHRyw5d8xazIaO8=" + }, + { + "pname": "pest", + "version": "2.8.0", + "hash": "sha256-GY23RTHVjHCjYcQiAe/efiWR6XbVGMr3ZipH3Fcg57Y=" + }, + { + "pname": "equivalent", + "version": "1.0.1", + "hash": "sha256-VEOAfW3/aTc9Qzq571N4rY31DKYpjK8V3m5S4kqvVNU=" + }, + { + "pname": "syn", + "version": "2.0.87", + "hash": "sha256-JapM40bQOm3NaN2LQBC8t05U5iyQxXPzlMRurpmroy0=" + }, + { + "pname": "remain", + "version": "0.2.12", + "hash": "sha256-GtXgESMMrSdNBTJGDFq2mCjqR651aBtCqEFmPv/695Q=" + }, + { + "pname": "unicode-ident", + "version": "1.0.12", + "hash": "sha256-M1S5rD+uH/Z1XLbbU2g622YWNPZ1V5Qt6k+s6+wP7ks=" + }, + { + "pname": "cfg-if", + "version": "1.0.0", + "hash": "sha256-uvHeQzl2FYi8Bhnjy8ASDuWC67dLU7Tvv3kRe9LaQP0=" + }, + { + "pname": "bitflags", + "version": "2.9.1", + "hash": "sha256-G45WmF7GLRfpwQAdyJyI7NfcCOR+ul7Hwpx7Xu7N6Wc=" + }, + { + "pname": "pest_derive", + "version": "2.8.0", + "hash": "sha256-1yXZz9eeh9zMk0Gi7znRtvY1PWjEszwXf+u+GkAsl8U=" + }, + { + "pname": "rustc-hash", + "version": "2.1.1", + "hash": "sha256-NXcD1BNltLJ8WQ4+2R6rsbZj8HxMCECV5gy+1DYt/w0=" + }, + { + "pname": "ucd-trie", + "version": "0.1.6", + "hash": "sha256-7WRikv/IGI746k0eDgFQ+xWlwuEq2bj8GRrnqKfzxLk=" + }, + { + "pname": "indexmap", + "version": "2.2.6", + "hash": "sha256-Fo+3Fd2kchXjYJEsCWZJ0j1Yvzkqxi9zkZ6DF0XkDyY=" + }, + { + "pname": "paste", + "version": "1.0.14", + "hash": "sha256-3jFFrwgCTeqfqZFPOBoXuPxgNN+wDzqEAT9/9D8p7Uw=" + }, + { + "pname": "hashbrown", + "version": "0.14.1", + "hash": "sha256-ff2mKhL1Xa6uUBX4GwuuoUU5HLRSD4bCSPxhXXJkDRI=" + }, + { + "pname": "libc", + "version": "0.2.168", + "hash": "sha256-Wq6ymB4GBsoR15cY+LsBFk8dbtdQgBgtOr8Bfm0kS20=" + }, + { + "pname": "thiserror-impl", + "version": "2.0.11", + "hash": "sha256-Jq/BuuqKmJM37rUrbnKgOXgM5Fw+38ycW50RL+6xc8I=" + }, + { + "pname": "once_cell", + "version": "1.8.0", + "hash": "sha256-aS/LY7ZLF1gCngqW7mPgSc6MWUhYfy9yCN8EYl5fa1Y=" + }, + { + "pname": "rustix", + "version": "1.0.7", + "hash": "sha256-xx6D1q/n/2SJDsa3HWppu4phCreM42SzNSh2u0yAEmY=" + }, + { + "pname": "pest_generator", + "version": "2.8.0", + "hash": "sha256-230Bcmvoq2arMvnfRnrosRSJBmhbvnXILR5l1/Wz+EE=" + }, + { + "pname": "thiserror", + "version": "2.0.11", + "hash": "sha256-1FLyhLc+bXbdNnWKDIaEsdW+MfkridB/1YIhdXMiBvw=" + }, + { + "pname": "proc-macro2", + "version": "1.0.86", + "hash": "sha256-XnGejfZl3w0cj7/SOAFXRHNhUdREXsCDa45iiq4QO3c=" + }, + { + "pname": "zerocopy", + "version": "0.8.13", + "hash": "sha256-Z5FKtFHzv9Lmnl6dLvOFhITnB01j8gT9Fm7DkbVN4h0=" + }, + { + "pname": "roxmltree", + "version": "0.20.0", + "hash": "sha256-bCC2eTtcL6ZVOyUBVLeNbQ2zfnJwCuNfrZOHpG9IfJc=" + }, + { + "pname": "zerocopy-derive", + "version": "0.8.13", + "hash": "sha256-eYjXOkMDyiid8DMWvEkOk0rM83Gva8dFOTzzwsXE8l0=" + }, + { + "pname": "pest_meta", + "version": "2.8.0", + "hash": "sha256-f5+DJHBJSQbR/KUyn4q1eRzGC+sjDHSBXf9UHL0rXKA=" + }, + { + "pname": "log", + "version": "0.4.27", + "hash": "sha256-E9wt81HjICeDof4NRDdfcpX/tASSZ7DzAYNG3BIqHZQ=" + } +] diff --git a/pkgs/servers/x11/xorg/overrides.nix b/pkgs/servers/x11/xorg/overrides.nix index 55cc08171059..6fc024e55571 100644 --- a/pkgs/servers/x11/xorg/overrides.nix +++ b/pkgs/servers/x11/xorg/overrides.nix @@ -828,7 +828,6 @@ self: super: }); xf86videovmware = super.xf86videovmware.overrideAttrs (attrs: { - buildInputs = attrs.buildInputs ++ [ mesa ]; env.NIX_CFLAGS_COMPILE = toString [ "-Wno-error=address" ]; # gcc12 meta = attrs.meta // { platforms = [