diff options
-rw-r--r-- | pkgs/development/libraries/directx-headers/default.nix | 25 | ||||
-rw-r--r-- | pkgs/development/libraries/libclc/default.nix | 4 | ||||
-rw-r--r-- | pkgs/development/libraries/mesa/default.nix | 107 | ||||
-rw-r--r-- | pkgs/development/libraries/mesa/opencl.patch | 51 | ||||
-rw-r--r-- | pkgs/top-level/all-packages.nix | 6 |
5 files changed, 130 insertions, 63 deletions
diff --git a/pkgs/development/libraries/directx-headers/default.nix b/pkgs/development/libraries/directx-headers/default.nix new file mode 100644 index 000000000000..3ac15bb85e24 --- /dev/null +++ b/pkgs/development/libraries/directx-headers/default.nix @@ -0,0 +1,25 @@ +{ lib, stdenv, fetchFromGitHub, meson, ninja }: +stdenv.mkDerivation rec { + pname = "directx-headers"; + version = "1.608.2"; + + src = fetchFromGitHub { + owner = "microsoft"; + repo = "DirectX-Headers"; + rev = "v${version}"; + hash = "sha256-F0riTDJpydqe4yhE9GKSSvnRI0Sl3oY2sOP+H/vDHG0="; + }; + + nativeBuildInputs = [ meson ninja ]; + + # tests require WSL2 + mesonFlags = [ "-Dbuild-test=false" ]; + + meta = with lib; { + description = "Official D3D12 headers from Microsoft"; + homepage = "https://github.com/microsoft/DirectX-Headers"; + license = licenses.mit; + maintainers = with maintainers; [ k900 ]; + platforms = platforms.all; + }; +} diff --git a/pkgs/development/libraries/libclc/default.nix b/pkgs/development/libraries/libclc/default.nix index 14a20a957967..647079ae2fb4 100644 --- a/pkgs/development/libraries/libclc/default.nix +++ b/pkgs/development/libraries/libclc/default.nix @@ -7,13 +7,13 @@ in stdenv.mkDerivation rec { pname = "libclc"; - version = "14.0.6"; + version = "15.0.7"; src = fetchFromGitHub { owner = "llvm"; repo = "llvm-project"; rev = "llvmorg-${version}"; - sha256 = "sha256-vffu4HilvYwtzwgq+NlS26m65DGbp6OSSne2aje1yJE="; + sha256 = "sha256-wjuZQyXQ/jsmvy6y1aksCcEDXGBjuhpgngF3XQJ/T4s="; }; sourceRoot = "source/libclc"; diff --git a/pkgs/development/libraries/mesa/default.nix b/pkgs/development/libraries/mesa/default.nix index 2225019d1d54..89526fbda7f4 100644 --- a/pkgs/development/libraries/mesa/default.nix +++ b/pkgs/development/libraries/mesa/default.nix @@ -6,11 +6,54 @@ , libelf, libvdpau , libglvnd, libunwind , vulkan-loader, glslang -, galliumDrivers ? ["auto"] -# upstream Mesa defaults to only enabling swrast (aka lavapipe) on aarch64 for some reason, so force building the others -, vulkanDrivers ? if (stdenv.isLinux && stdenv.isAarch64) then [ "swrast" "broadcom" "freedreno" "panfrost" ] else [ "auto" ] +, galliumDrivers ? + if stdenv.isLinux then + [ + "d3d12" # WSL emulated GPU (aka Dozen) + "kmsro" # helper driver for display-only devices + "nouveau" # Nvidia + "radeonsi" # new AMD (GCN+) + "r300" # very old AMD + "r600" # less old AMD + "swrast" # software renderer (aka LLVMPipe) + "svga" # VMWare virtualized GPU + "virgl" # QEMU virtualized GPU (aka VirGL) + "zink" # generic OpenGL over Vulkan, experimental + ] + ++ lib.optionals stdenv.isAarch64 [ + "etnaviv" # Vivante GPU designs (mostly NXP/Marvell SoCs) + "freedreno" # Qualcomm Adreno (all Qualcomm SoCs) + "lima" # ARM Mali 4xx + "panfrost" # ARM Mali Midgard and up (T/G series) + "tegra" # Nvidia Tegra SoCs + "v3d" # Broadcom VC5 (Raspberry Pi 4) + "vc4" # Broadcom VC4 (Raspberry Pi 0-3) + ] ++ lib.optionals stdenv.isx86_64 [ + "iris" # new Intel, could work on non-x86_64 with PCIe cards, but doesn't build as of 22.3.4 + "crocus" # Intel legacy, x86_64 only + ] + else [ "auto" ] +, vulkanDrivers ? + if stdenv.isLinux then + [ + "amd" # AMD (aka RADV) + "microsoft-experimental" # WSL virtualized GPU (aka DZN/Dozen) + "swrast" # software renderer (aka Lavapipe) + "virtio-experimental" # QEMU virtualized GPU (aka VirGL) + ] + ++ lib.optionals stdenv.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.isx86_64 [ + "intel" # Intel (aka ANV), could work on non-x86_64 with PCIe cards, but doesn't build as of 22.3.4 + "intel_hasvk" # Intel Haswell/Broadwell, experimental, x86_64 only + ] + else [ "auto" ] , eglPlatforms ? [ "x11" ] ++ lib.optionals stdenv.isLinux [ "wayland" ] -, vulkanLayers ? lib.optionals (!stdenv.isDarwin) [ "device-select" "overlay" ] # No Vulkan support on Darwin +, vulkanLayers ? lib.optionals (!stdenv.isDarwin) [ "device-select" "overlay" "intel-nullhw" ] # No Vulkan support on Darwin , OpenGL, Xplugin , withValgrind ? lib.meta.availableOn stdenv.hostPlatform valgrind-light && !valgrind-light.meta.broken, valgrind-light , enableGalliumNine ? stdenv.isLinux @@ -19,10 +62,12 @@ , enablePatentEncumberedCodecs ? true , libclc , jdupes -, cmake , rustc , rust-bindgen -, spirv-llvm-translator_14 +, spirv-llvm-translator +, zstd +, directx-headers +, udev }: /** Packaging design: @@ -44,12 +89,21 @@ let withLibdrm = lib.meta.availableOn stdenv.hostPlatform libdrm; + # Align all the Mesa versions used. Required to prevent explosions when + # two different LLVMs are loaded in the same process. + # FIXME: these should really go into some sort of versioned LLVM package set rust-bindgen' = rust-bindgen.override { rust-bindgen-unwrapped = rust-bindgen.unwrapped.override { clang = llvmPackages.clang; }; }; + spirv-llvm-translator' = spirv-llvm-translator.override { + inherit (llvmPackages) llvm; + }; + haveWayland = lib.elem "wayland" eglPlatforms; + haveZink = lib.elem "zink" galliumDrivers; + haveDozen = (lib.elem "d3d12" galliumDrivers) || (lib.elem "microsoft-experimental" vulkanDrivers); self = stdenv.mkDerivation { pname = "mesa"; inherit version; @@ -91,7 +145,11 @@ self = stdenv.mkDerivation { outputs = [ "out" "dev" "drivers" ] ++ lib.optional enableOSMesa "osmesa" ++ lib.optional stdenv.isLinux "driversdev" - ++ lib.optional enableOpenCL "opencl"; + ++ lib.optional enableOpenCL "opencl" + # the Dozen drivers depend on libspirv2dxil, but link it statically, and + # libspirv2dxil itself is pretty chonky, so relocate it to its own output + # in case anything wants to use it at some point + ++ lib.optional haveDozen "spirv2dxil"; # FIXME: this fixes rusticl/iris segfaulting on startup, _somehow_. # Needs more investigating. @@ -122,6 +180,7 @@ self = stdenv.mkDerivation { "-Domx-libs-path=${placeholder "drivers"}/lib/bellagio" "-Dva-libs-path=${placeholder "drivers"}/lib/dri" "-Dd3d-drivers-path=${placeholder "drivers"}/lib/d3d" + "-Dgallium-nine=${lib.boolToString enableGalliumNine}" # Direct3D in Wine "-Dosmesa=${lib.boolToString enableOSMesa}" # used by wine "-Dmicrosoft-clc=disabled" # Only relevant on Windows (OpenCL 1.2 API on top of D3D12) @@ -130,8 +189,15 @@ self = stdenv.mkDerivation { "-Dgbm-backends-path=${libglvnd.driverLink}/lib/gbm:${placeholder "out"}/lib/gbm" ] ++ lib.optionals stdenv.isLinux [ "-Dglvnd=true" + + # Enable RT for Intel hardware + "-Dintel-clc=enabled" ] ++ lib.optionals enableOpenCL [ - "-Dgallium-opencl=icd" # Enable the gallium OpenCL frontend + # Clover, old OpenCL frontend + "-Dgallium-opencl=icd" + "-Dopencl-spirv=true" + + # Rusticl, new OpenCL frontend "-Dgallium-rusticl=true" "-Drust_std=2021" "-Dclang-libdir=${llvmPackages.clang-unwrapped.lib}/lib" ] ++ lib.optional enablePatentEncumberedCodecs @@ -143,24 +209,23 @@ self = stdenv.mkDerivation { libX11 libXext libxcb libXt libXfixes libxshmfence libXrandr libffi libvdpau libelf libXvMC libpthreadstubs openssl /*or another sha1 provider*/ - ] ++ lib.optionals (lib.elem "wayland" eglPlatforms) [ wayland wayland-protocols ] - ++ lib.optionals stdenv.isLinux [ libomxil-bellagio libva-minimal ] + zstd + ] ++ lib.optionals haveWayland [ wayland wayland-protocols ] + ++ lib.optionals stdenv.isLinux [ libomxil-bellagio libva-minimal udev ] ++ lib.optionals stdenv.isDarwin [ libunwind ] - ++ lib.optionals enableOpenCL [ libclc llvmPackages.clang llvmPackages.clang-unwrapped rustc rust-bindgen' spirv-llvm-translator_14 ] + ++ lib.optionals enableOpenCL [ libclc llvmPackages.clang llvmPackages.clang-unwrapped rustc rust-bindgen' spirv-llvm-translator' ] ++ lib.optional withValgrind valgrind-light - # Mesa will not build zink when gallium-drivers=auto - ++ lib.optional (lib.elem "zink" galliumDrivers) vulkan-loader; + ++ lib.optional haveZink vulkan-loader + ++ lib.optional haveDozen directx-headers; depsBuildBuild = [ pkg-config ]; nativeBuildInputs = [ meson pkg-config ninja intltool bison flex file - python3Packages.python python3Packages.Mako + python3Packages.python python3Packages.Mako python3Packages.ply jdupes glslang - ] ++ lib.optionals (lib.elem "wayland" eglPlatforms) [ - wayland-scanner - ]; + ] ++ lib.optional haveWayland wayland-scanner; propagatedBuildInputs = with xorg; [ libXdamage libXxf86vm @@ -217,6 +282,10 @@ self = stdenv.mkDerivation { for js in $drivers/share/vulkan/{im,ex}plicit_layer.d/*.json; do substituteInPlace "$js" --replace '"libVkLayer_' '"'"$drivers/lib/libVkLayer_" done + '' + lib.optionalString haveDozen '' + mkdir -p $spirv2dxil/{bin,lib} + mv -t $spirv2dxil/lib $out/lib/libspirv_to_dxil* + mv -t $spirv2dxil/bin $out/bin/spirv2dxil ''; postFixup = lib.optionalString stdenv.isLinux '' @@ -253,6 +322,10 @@ self = stdenv.mkDerivation { NIX_CFLAGS_COMPILE = lib.optionals stdenv.isDarwin [ "-fno-common" ] ++ lib.optionals enableOpenCL [ "-UPIPE_SEARCH_DIR" "-DPIPE_SEARCH_DIR=\"${placeholder "opencl"}/lib/gallium-pipe\"" + + # Work around regression from https://github.com/NixOS/nixpkgs/pull/210004 + # TODO(trofi): remove + "--sysroot=/" ]; passthru = { diff --git a/pkgs/development/libraries/mesa/opencl.patch b/pkgs/development/libraries/mesa/opencl.patch index 02558aaa825d..fb4da5cf7a0a 100644 --- a/pkgs/development/libraries/mesa/opencl.patch +++ b/pkgs/development/libraries/mesa/opencl.patch @@ -1,8 +1,8 @@ diff --git a/meson.build b/meson.build -index e32338b3f9a..fae804fd41e 100644 +index 172c64a7c70..05961e56926 100644 --- a/meson.build +++ b/meson.build -@@ -1894,7 +1894,7 @@ endif +@@ -1900,7 +1900,7 @@ endif dep_clang = null_dep if with_clc @@ -29,51 +29,20 @@ index 6f307018815..ab84eb1006c 100644 'platforms', type : 'array', diff --git a/src/gallium/targets/opencl/meson.build b/src/gallium/targets/opencl/meson.build -index 7af210b5693..ff6ac8c61ca 100644 +index db3586bd7fb..4d914206d21 100644 --- a/src/gallium/targets/opencl/meson.build +++ b/src/gallium/targets/opencl/meson.build -@@ -30,6 +30,7 @@ if with_ld_version_script +@@ -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 - llvm_libdir = dep_llvm.get_variable(cmake : 'LLVM_LIBRARY_DIR', configtool: 'libdir') +-dep_clang = cpp.find_library('clang-cpp', dirs : llvm_libdir, required : false) +clang_libdir = get_option('clang-libdir') - opencl_libname = with_opencl_icd ? 'MesaOpenCL' : 'OpenCL' ++dep_clang = cpp.find_library('clang-cpp', dirs : clang_libdir, required : false) - polly_dep = null_dep -@@ -60,19 +61,19 @@ else - endif - if not _shared_llvm or not (dep_clang.found() and dep_clang_usable) - dep_clang = [ -- cpp.find_library('clangCodeGen', dirs : llvm_libdir), -- cpp.find_library('clangFrontendTool', dirs : llvm_libdir), -- cpp.find_library('clangFrontend', dirs : llvm_libdir), -- cpp.find_library('clangDriver', dirs : llvm_libdir), -- cpp.find_library('clangSerialization', dirs : llvm_libdir), -- cpp.find_library('clangParse', dirs : llvm_libdir), -- cpp.find_library('clangSema', dirs : llvm_libdir), -- cpp.find_library('clangAnalysis', dirs : llvm_libdir), -- cpp.find_library('clangAST', dirs : llvm_libdir), -- cpp.find_library('clangASTMatchers', dirs : llvm_libdir), -- cpp.find_library('clangEdit', dirs : llvm_libdir), -- cpp.find_library('clangLex', dirs : llvm_libdir), -- cpp.find_library('clangBasic', dirs : llvm_libdir), -+ cpp.find_library('clangCodeGen', dirs : clang_libdir), -+ cpp.find_library('clangFrontendTool', dirs : clang_libdir), -+ cpp.find_library('clangFrontend', dirs : clang_libdir), -+ cpp.find_library('clangDriver', dirs : clang_libdir), -+ cpp.find_library('clangSerialization', dirs : clang_libdir), -+ cpp.find_library('clangParse', dirs : clang_libdir), -+ cpp.find_library('clangSema', dirs : clang_libdir), -+ cpp.find_library('clangAnalysis', dirs : clang_libdir), -+ cpp.find_library('clangAST', dirs : clang_libdir), -+ cpp.find_library('clangASTMatchers', dirs : clang_libdir), -+ cpp.find_library('clangEdit', dirs : clang_libdir), -+ cpp.find_library('clangLex', dirs : clang_libdir), -+ cpp.find_library('clangBasic', dirs : clang_libdir), - polly_dep, polly_isl_dep, - ] - # check clang once more -@@ -119,7 +120,7 @@ if with_opencl_icd + # 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', diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 75b10cdbbf03..ca75840a82aa 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -15916,8 +15916,6 @@ with pkgs; spirv-llvm-translator = callPackage ../development/compilers/spirv-llvm-translator { }; - spirv-llvm-translator_14 = callPackage ../development/compilers/spirv-llvm-translator { llvm = llvm_14; }; - sqldeveloper = callPackage ../development/tools/database/sqldeveloper { jdk = oraclejdk; }; @@ -22038,7 +22036,7 @@ with pkgs; libGLU = mesa_glu; mesa = callPackage ../development/libraries/mesa { - llvmPackages = llvmPackages_latest; + llvmPackages = llvmPackages_15; stdenv = if stdenv.isDarwin then darwin.apple_sdk_11_0.stdenv else stdenv; inherit (darwin.apple_sdk_11_0.frameworks) OpenGL; inherit (darwin.apple_sdk_11_0.libs) Xplugin; @@ -24229,6 +24227,8 @@ with pkgs; diod = callPackage ../servers/diod { lua = lua5_1; }; + directx-headers = callPackage ../development/libraries/directx-headers {}; + directx-shader-compiler = callPackage ../tools/graphics/directx-shader-compiler {}; dkimproxy = callPackage ../servers/mail/dkimproxy { }; |