From 58034eb5b0483cf0f8c24a2952a9303e408ee485 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sun, 26 Nov 2023 15:49:09 +0100 Subject: [PATCH] Use latest mesa --- kagami-air-m1/configuration.nix | 24 ++++++++ kagami-air-m1/mesa-asahi-edge/opencl.patch | 66 ++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 kagami-air-m1/mesa-asahi-edge/opencl.patch diff --git a/kagami-air-m1/configuration.nix b/kagami-air-m1/configuration.nix index 35fb2ca..f1f8861 100644 --- a/kagami-air-m1/configuration.nix +++ b/kagami-air-m1/configuration.nix @@ -13,6 +13,8 @@ ../modules/personal/fonts # Encrypted DNS ../modules/services/edns + # Override base mesa + ({ ... }: { nixpkgs.overlays = lib.mkBefore [ (final: prev: { mesa = prev.mesa.override { enableOpenCL = true; meson = final.unstable.meson; }; }) ]; }) ]; # time.timeZone = lib.mkForce "Asia/Ho_Chi_Minh"; @@ -28,6 +30,28 @@ useExperimentalGPUDriver = true; experimentalGPUInstallMode = "overlay"; }; + # Override mesa + nixpkgs.overlays = lib.mkAfter [ + (final: prev: { + mesa-asahi-edge = prev.mesa-asahi-edge.overrideAttrs (attrs: { + version = "24.0.0"; + # buildInputs = attrs.buildInputs ++ (with pkgslw; [ libclc cmake (spirv-llvm-translator.override { inherit (llvmPackages_15) llvm; }) ]); + # nativeBuildInputs = attrs.nativeBuildInputs ++ (with pkgs; [ pkgs.unstable.spirv-llvm-translator ]); + src = final.fetchFromGitLab { + # latest release + domain = "gitlab.freedesktop.org"; + owner = "asahi"; + repo = "mesa"; + rev = "asahi-20231121"; + hash = "sha256-IcKKe1RA8sCaUfWK71ELzF15YaBS3DjoYhNMIWiQ5Jw="; + }; + + patches = lib.forEach attrs.patches (p: + if lib.hasSuffix "opencl.patch" p + then ./mesa-asahi-edge/opencl.patch else p); + }); + }) + ]; ## Additional mesa-related packages environment.systemPackages = with pkgs; [ SDL2 ]; diff --git a/kagami-air-m1/mesa-asahi-edge/opencl.patch b/kagami-air-m1/mesa-asahi-edge/opencl.patch new file mode 100644 index 0000000..d04b08c --- /dev/null +++ b/kagami-air-m1/mesa-asahi-edge/opencl.patch @@ -0,0 +1,66 @@ +diff --git a/meson.build b/meson.build +index 04d89987311..babfe440973 100644 +--- a/meson.build ++++ b/meson.build +@@ -1812,7 +1812,7 @@ endif + + dep_clang = null_dep + 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 e885ba61a8a..29ce0270479 100644 +--- a/meson_options.txt ++++ b/meson_options.txt +@@ -1,6 +1,12 @@ + # Copyright © 2017-2019 Intel Corporation + # SPDX-License-Identifier: MIT + ++option( ++ 'clang-libdir', ++ type : 'string', ++ value : '', ++ description : 'Locations to search for clang libraries.' ++) + option( + 'platforms', + type : 'array', +diff --git a/src/gallium/targets/opencl/meson.build b/src/gallium/targets/opencl/meson.build +index 7c14135898e..74dc6850603 100644 +--- a/src/gallium/targets/opencl/meson.build ++++ b/src/gallium/targets/opencl/meson.build +@@ -39,7 +39,8 @@ if dep_llvm.version().version_compare('>=10.0.0') + polly_isl_dep = cpp.find_library('PollyISL', dirs : llvm_libdir, required : false) + endif + +-dep_clang = cpp.find_library('clang-cpp', dirs : llvm_libdir, required : false) ++clang_libdir = get_option('clang-libdir') ++dep_clang = cpp.find_library('clang-cpp', dirs : clang_libdir, required : false) + + # meson will return clang-cpp from system dirs if it's not found in llvm_libdir + linker_rpath_arg = '-Wl,--rpath=@0@'.format(llvm_libdir) +@@ -123,7 +124,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 b2963fe6dfa..99d6d801b94 100644 +--- a/src/gallium/targets/rusticl/meson.build ++++ b/src/gallium/targets/rusticl/meson.build +@@ -76,7 +76,7 @@ configure_file( + configuration : _config, + input : 'rusticl.icd.in', + output : 'rusticl.icd', +- install : true, ++ install : false, + install_tag : 'runtime', + install_dir : join_paths(get_option('sysconfdir'), 'OpenCL', 'vendors'), + )