blender: add HIP RT support; improve HIP support; rocmPackages.hiprt: fix wrong lib paths (#441511)

This commit is contained in:
Dmitry Kalinkin
2025-09-10 10:25:03 -04:00
committed by GitHub
2 changed files with 15 additions and 6 deletions
+13 -6
View File
@@ -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}";
@@ -160,6 +161,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"
@@ -189,20 +191,25 @@ 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 hipSupport [
"-DHIPRT_INCLUDE_DIR=${rocmPackages.hiprt}/include"
"-DWITH_CYCLES_DEVICE_HIPRT=ON"
"-DWITH_CYCLES_HIP_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 = ''
@@ -267,6 +274,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
@@ -350,7 +358,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
''
@@ -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 = [