From bb5b8d73c4b45a675dcd7244133f9859d9f31877 Mon Sep 17 00:00:00 2001 From: materus Date: Fri, 21 Jul 2023 03:13:51 +0200 Subject: [PATCH] swiftshader: init package | obs-studio: use swiftshader --- pkgs/apps/obs/default.nix | 6 +++++- pkgs/default.nix | 4 +++- pkgs/libs/swiftshader.nix | 29 +++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 pkgs/libs/swiftshader.nix diff --git a/pkgs/apps/obs/default.nix b/pkgs/apps/obs/default.nix index bdb8cf6..2f7a3f3 100644 --- a/pkgs/apps/obs/default.nix +++ b/pkgs/apps/obs/default.nix @@ -47,6 +47,8 @@ , websocketpp , amf-headers , libGL +, vulkan-loader +, swiftshader }: let @@ -107,6 +109,7 @@ stdenv.mkDerivation rec { libva srt qtwayland + swiftshader ] ++ optionals scriptingSupport [ luajit python3 ] ++ optional alsaSupport alsa-lib @@ -120,6 +123,7 @@ stdenv.mkDerivation rec { cp -r $i cef/Release/ cp -r $i cef/Resources/ done + cp -r ${swiftshader}/lib/libvk_swiftshader.so cef/Release/ cp -r ${libcef}/lib/libcef.so cef/Release/ cp -r ${libcef}/lib/libcef_dll_wrapper.a cef/libcef_dll_wrapper/ cp -r ${libcef}/include cef/ @@ -142,7 +146,7 @@ stdenv.mkDerivation rec { preFixup = '' qtWrapperArgs+=( --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ xorg.libX11 libvlc ]}" - --suffix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ libGL ]}" + --suffix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ libGL vulkan-loader ]}" --prefix LD_LIBRARY_PATH : "$out/lib" ''${gappsWrapperArgs[@]} ) diff --git a/pkgs/default.nix b/pkgs/default.nix index bede4cc..209014c 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -15,11 +15,13 @@ rec { VideoDecodeAcceleration VideoToolbox; }; - obs-amf = pkgs.qt6Packages.callPackage ./apps/obs { ffmpeg = ffmpeg6-amf-full; }; + obs-amf = pkgs.qt6Packages.callPackage ./apps/obs { ffmpeg = ffmpeg6-amf-full; inherit swiftshader;}; polymc = pkgs.qt6Packages.callPackage ./apps/games/polymc {}; vpk_fuse = callPackage ./apps/vpk_fuse.nix {}; + swiftshader = callPackage ./libs/swiftshader.nix {}; + } diff --git a/pkgs/libs/swiftshader.nix b/pkgs/libs/swiftshader.nix new file mode 100644 index 0000000..bb436e4 --- /dev/null +++ b/pkgs/libs/swiftshader.nix @@ -0,0 +1,29 @@ +{ pkgs, lib, stdenv, fetchFromGitHub, cmake, python3 }: + + +stdenv.mkDerivation rec { + pname = "swiftshader"; + version = "20072023"; + src = fetchFromGitHub { + owner = "google"; + repo = "SwiftShader"; + rev = "4a260c12b8c155103435a7b2b99b5227f6ce7594"; + sha256 = "sha256-WcA1EazeuRlFhIaAKgJHp+rUkCR2vqcINkTMYOgrbNI="; + fetchSubmodules = true; + }; + + buildInputs = [ cmake python3 ]; + + installPhase = '' + mkdir -p $out/lib + mv libvk_swiftshader.so $out/lib + ''; + + + meta = with lib; { + description = "SwiftShader is a high-performance CPU-based implementation of the Vulkan 1.3 graphics API"; + homepage = "https://swiftshader.googlesource.com/SwiftShader"; + license = licenses.asl20; + platforms = platforms.linux; + }; +}