From 31125484bc728affa356c55ebbe77406444339d1 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 9 Sep 2025 10:16:21 -0400 Subject: [PATCH 1/6] blender: formatting --- pkgs/by-name/bl/blender/package.nix | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkgs/by-name/bl/blender/package.nix b/pkgs/by-name/bl/blender/package.nix index c56113252d9d..a12fd6147e77 100644 --- a/pkgs/by-name/bl/blender/package.nix +++ b/pkgs/by-name/bl/blender/package.nix @@ -189,20 +189,20 @@ stdenv'.mkDerivation (finalAttrs: { "-DALEMBIC_INCLUDE_DIR=${lib.getDev alembic}/include" "-DALEMBIC_LIBRARY=${lib.getLib alembic}/lib/libAlembic${stdenv.hostPlatform.extensions.sharedLibrary}" ] + ++ lib.optionals cudaSupport [ + "-DOPTIX_ROOT_DIR=${optix}" + "-DWITH_CYCLES_CUDA_BINARIES=ON" + ] ++ lib.optionals waylandSupport [ "-DWITH_GHOST_WAYLAND=ON" "-DWITH_GHOST_WAYLAND_DBUS=ON" "-DWITH_GHOST_WAYLAND_DYNLOAD=OFF" "-DWITH_GHOST_WAYLAND_LIBDECOR=ON" ] + ++ lib.optional stdenv.cc.isClang "-DPYTHON_LINKFLAGS=" # Clang doesn't support "-export-dynamic" ++ lib.optionals stdenv.hostPlatform.isDarwin [ "-DLIBDIR=/does-not-exist" "-DSSE2NEON_INCLUDE_DIR=${sse2neon}/lib" - ] - ++ lib.optional stdenv.cc.isClang "-DPYTHON_LINKFLAGS=" # Clang doesn't support "-export-dynamic" - ++ lib.optionals cudaSupport [ - "-DOPTIX_ROOT_DIR=${optix}" - "-DWITH_CYCLES_CUDA_BINARIES=ON" ]; preConfigure = '' From 76b046476aedcb0aa00bb3a0de18f0360bcf6ea2 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 9 Sep 2025 15:27:16 -0400 Subject: [PATCH 2/6] blender: remove redundant check This is already done by addDriverRunpath. --- pkgs/by-name/bl/blender/package.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/by-name/bl/blender/package.nix b/pkgs/by-name/bl/blender/package.nix index a12fd6147e77..f80ed56cde62 100644 --- a/pkgs/by-name/bl/blender/package.nix +++ b/pkgs/by-name/bl/blender/package.nix @@ -350,7 +350,6 @@ stdenv'.mkDerivation (finalAttrs: { postFixup = lib.optionalString cudaSupport '' for program in $out/bin/blender $out/bin/.blender-wrapped; do - isELF "$program" || continue addDriverRunpath "$program" done '' From fdceba8b15637d0482673774d326a34400c4110d Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 9 Sep 2025 09:40:29 -0400 Subject: [PATCH 3/6] blender: ensure that hipSupport enables HIP Without this, it might not get implicitly enabled. --- pkgs/by-name/bl/blender/package.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/by-name/bl/blender/package.nix b/pkgs/by-name/bl/blender/package.nix index f80ed56cde62..236fa7985fd8 100644 --- a/pkgs/by-name/bl/blender/package.nix +++ b/pkgs/by-name/bl/blender/package.nix @@ -160,6 +160,7 @@ stdenv'.mkDerivation (finalAttrs: { "-DWITH_CODEC_FFMPEG=ON" "-DWITH_CODEC_SNDFILE=ON" "-DWITH_CPU_CHECK=OFF" + "-DWITH_CYCLES_DEVICE_HIP=${if hipSupport then "ON" else "OFF"}" "-DWITH_CYCLES_DEVICE_OPTIX=${if cudaSupport then "ON" else "OFF"}" "-DWITH_CYCLES_EMBREE=${if embreeSupport then "ON" else "OFF"}" "-DWITH_CYCLES_OSL=OFF" From 3ff6d70d2ea5788d873a58d853c74b89c5d6dfaa Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 9 Sep 2025 11:20:49 -0400 Subject: [PATCH 4/6] blender: build hip kernels MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without this, things need to be built at runtime. This matches what is done for CUDA. Technically we are only using `hipcc` (gotten here via `clr`) at build time, however it is complicated in that Blender assumes all ROCm things are together, and so *just* having `hipcc` causes it to get confused a bit (especially later when we add hiprt support). While setting `HIP_ROOT_DIR` might help a bit, it’s all a bit fragile and we have `clr` in the closure already anyway so it doesn’t seem worth it to over-optimize. Using `clr` brings libraries and such, so add it to buildInputs instead of nativeBuildInputs to be a bit safe. --- pkgs/by-name/bl/blender/package.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/by-name/bl/blender/package.nix b/pkgs/by-name/bl/blender/package.nix index 236fa7985fd8..4d708eed8a1e 100644 --- a/pkgs/by-name/bl/blender/package.nix +++ b/pkgs/by-name/bl/blender/package.nix @@ -194,6 +194,9 @@ stdenv'.mkDerivation (finalAttrs: { "-DOPTIX_ROOT_DIR=${optix}" "-DWITH_CYCLES_CUDA_BINARIES=ON" ] + ++ lib.optionals hipSupport [ + "-DWITH_CYCLES_HIP_BINARIES=ON" + ] ++ lib.optionals waylandSupport [ "-DWITH_GHOST_WAYLAND=ON" "-DWITH_GHOST_WAYLAND_DBUS=ON" @@ -268,6 +271,7 @@ stdenv'.mkDerivation (finalAttrs: { zstd ] ++ lib.optional embreeSupport embree + ++ lib.optional hipSupport rocmPackages.clr ++ lib.optional openImageDenoiseSupport (openimagedenoise.override { inherit cudaSupport tbb; }) ++ ( if (!stdenv.hostPlatform.isDarwin) then From 9e2ef7a8e93dcff30c4c8a75dd6f5977961c6157 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 9 Sep 2025 15:52:28 -0400 Subject: [PATCH 5/6] rocmPackages.hiprt: fix dynamic loading from wrong lib paths --- pkgs/development/rocm-modules/6/hiprt/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/development/rocm-modules/6/hiprt/default.nix b/pkgs/development/rocm-modules/6/hiprt/default.nix index 2ba4cd5dcbfe..22622612b0fb 100644 --- a/pkgs/development/rocm-modules/6/hiprt/default.nix +++ b/pkgs/development/rocm-modules/6/hiprt/default.nix @@ -21,6 +21,8 @@ stdenv.mkDerivation (finalAttrs: { postPatch = '' g++ contrib/easy-encryption/cl.cpp -o contrib/easy-encryption/bin/linux/ee64 #replacing prebuilt binary + substituteInPlace contrib/Orochi/contrib/hipew/src/hipew.cpp --replace-fail '"/opt/rocm/hip/lib/' '"${clr}/lib' + substituteInPlace hiprt/hiprt_libpath.h --replace-fail '"/opt/rocm/hip/lib/' '"${clr}/lib/' ''; nativeBuildInputs = [ From f425ad63aff0af27afd56bb0b24e844cd4c4e02a Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 9 Sep 2025 11:22:00 -0400 Subject: [PATCH 6/6] blender: add HIP RT support --- pkgs/by-name/bl/blender/package.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/by-name/bl/blender/package.nix b/pkgs/by-name/bl/blender/package.nix index 4d708eed8a1e..e2606a869b68 100644 --- a/pkgs/by-name/bl/blender/package.nix +++ b/pkgs/by-name/bl/blender/package.nix @@ -142,6 +142,7 @@ stdenv'.mkDerivation (finalAttrs: { + (lib.optionalString hipSupport '' substituteInPlace extern/hipew/src/hipew.c --replace-fail '"/opt/rocm/hip/lib/libamdhip64.so.${lib.versions.major rocmPackages.clr.version}"' '"${rocmPackages.clr}/lib/libamdhip64.so"' substituteInPlace extern/hipew/src/hipew.c --replace-fail '"opt/rocm/hip/bin"' '"${rocmPackages.clr}/bin"' + substituteInPlace extern/hipew/src/hiprtew.cc --replace-fail '"/opt/rocm/lib/libhiprt64.so"' '"${rocmPackages.hiprt}/lib/libhiprt64.so"' ''); env.NIX_CFLAGS_COMPILE = "-I${python3}/include/${python3.libPrefix}"; @@ -195,6 +196,8 @@ stdenv'.mkDerivation (finalAttrs: { "-DWITH_CYCLES_CUDA_BINARIES=ON" ] ++ lib.optionals hipSupport [ + "-DHIPRT_INCLUDE_DIR=${rocmPackages.hiprt}/include" + "-DWITH_CYCLES_DEVICE_HIPRT=ON" "-DWITH_CYCLES_HIP_BINARIES=ON" ] ++ lib.optionals waylandSupport [